I am trying to find the size of an image I have loaded into matlab.
image=imread('text.jpg');
[x,y]=size(image);
This return the error:
Indexing cannot yield multiple results.
Does imread not read the image into a 2d array, which should therefore have two sizes?
For those looking to find the size of an image in matlab, don't use:
[height, width] = size(image);
This is because imread stores the RGB values separately (for colour images), resulting in a three dimensional matrix.
For example, if you loaded a 500p high, 200p wide colour image, this would result in a 500x200x3 matrix.
Calling size() in this way would result in the dimensionality being 'rolled up', and would report the height to be 500, but the width to be 600 (200 * 3).
Instead, using:
[height, width, dim] = size(image);
would return correct values of 500, 200, 3.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With