MATLAB: What does the following message mean?”Unable to perform assignment because the size of the left side is 50-by-150 and the size of the right side is 50-by-150-by-3.”

imageprocessing

Hi everyone, I am new to matlab and currently working on image processing and I have the following issue: I am trying to insert an image 50×150 onto another image, but it shows that error "Unable to perform assignment because the size of the left side is 50-by-150 and the size of the right side is 50-by-150-by-3." I am really puzzled what this means? The image I am trying to insert is called "july" in the work space and it appears 50x150x3 which I have no clue what the "3" is???Any help will be greatly appreciated.

Best Answer

50x150x3 means 50 rows, 150 columns, and 3 color planes. Your image july is an RGB image, even if it looks grayscale. You probably read it from a JPEG image, and JPEG images are almost always RGB.
You are trying to store an RGB image into a space that is only set up to receive a grayscale or pseudocolor image.
If you expect to be working with grayscale then use rgb2gray(july)