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 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Walter Roberson
Walter Roberson il 20 Mag 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)

Più risposte (1)

Yanitsa Stancheva
Yanitsa Stancheva il 20 Mag 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

Categorie

Scopri di più su Image Processing Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by