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.
source share