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."

1 view (last 30 days)
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 50x150 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.

Accepted Answer

Walter Roberson
Walter Roberson on 20 May 2019
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)

More Answers (1)

Yanitsa Stancheva
Yanitsa Stancheva on 20 May 2019
Hi walter, thank you for your answer, the image is bmp one and I am trying to place it on another bmp image, the following code is:
a=imread('C:\Assignments\Matlab\images\basis.bmp');
july=imread('C:\Assignments\Matlab\images\june2018.bmp');
a(100:150,250:400)=july;
imshow(a);
The image 'f' is 480x340 if that helps?
Many MANY thanks

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!