简体   繁体   中英

matlab error using CAT, Dimensions of matrices being concatenated are not consistent

I am trying to compute the PURE BLUE COLOR from an image and compare it to the original blue channel. Then I have to explain the advantages of using pure colors instead of RGB channels.

This Is my code:

>> RGB = double( imread('players.jpeg'))/255;
>> imagesc(RGB);

在此处输入图片说明

>> red = RGB( :,:,1);
>> green = RGB( :,:,2);
>> blue = RGB( :,:,3);
>> pure_BLUE = blue ./ (red+green+blue);
>> imagesc(pure_BLUE);

在此处输入图片说明

however when I use this:

>> imagesc(cat(3,pure_BLUE,zeros(240,320),zeros(240,320)));

I get the following error:

Error using cat Dimensions of matrices being concatenated are not consistent.

Not quite sure what goes wrong here and How I can fix this!!!!

It looks like the two arrays you're trying to concatenate are the wrong size compared to the image. The image appears to be 176x241 so you should try:

imagesc(cat(3,pure_BLUE,zeros(176,241),zeros(176,241)));

or a more general way is to use the size of the array itself:

imagesc(cat(3,pure_BLUE,zeros([size(pure_BLUE) 2])));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM