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.