The above code seems to be assuming that the images are two dimensional only. Is this a valid assumption, or are the images (or matrices) 1200x900x3?
The error message is telling you that there is dimension mismatch in your assignment at line
In this case, the code is trying to insert a vector (once the colon is used in img(:)) that is larger than the destination row of images. As you have stated, the size of any image is 1200x900 (so 1080000 elements) BUT images has only been sized a matrix with n rows and 3072=48*64 columns…which is considerably smaller than 1080000. Hence the error.
In the line prior to this assignment, there is an attempt to reshape the data which has been commented out since this line probably generated the error To RESHAPE the number of elements must not change. Since you want to resize, the code should use the imresize command instead:
img = imresize(img,[48 64]);
Using imresize will reduce the image to the 48x64 size which can then be assigned to images.
Best Answer