Matlab Image Size

I am trying to find the size of the image that I uploaded in matlab.

image=imread('text.jpg'); [x,y]=size(image); 

This returns an error:

Indexing cannot produce multiple results.

Doesn't imread read the image in a 2d array, so it should have two sizes?

+6
source share
6 answers

Is it possible that before this code you defined a variable called size ?

+9
source

For those who want to find the image size in Matlab, do not use:

 [height, width] = size(image); 

This is because imread stores RGB values ​​separately (for color images), resulting in a three-dimensional matrix.

For example, if you uploaded a color image with a width of 500p, 200p, this will result in a matrix of size 500x200x3.

The calling size () in this way will cause the dimension to be “collapsed” and tell that the height will be 500 and the width 600 (200 * 3).

Instead, using:

 [height, width, dim] = size(image); 

will return the correct values ​​500, 200, 3.

+13
source

You should use [height, width, colour_planes] = size(image); because the images have 3 dimensions. The third dimension is the number of color planes. If you do not need this value, you can replace ~ with ignore.

+3
source

Just use this whos and press enter.

 image=imread('text.jpg'); whos 
+1
source

[x, y, r] = size (image); is correct. x and y will give the length and width of the image, and z indicates the color.

The digital image consists of RGB, so z will be 3.

+1
source

You can try the following:

 image=imread('text.jpg'); [xy]=size(image); 
-3
source

Source: https://habr.com/ru/post/909936/


All Articles