HI so im changing the color of the image to green and blue but its not working one of them gives an error and the other gives a red color
조회 수: 1 (최근 30일)
이전 댓글 표시
채택된 답변
DGM
2022년 12월 12일
편집: DGM
2022년 12월 12일
What is the size of app.Image? If it's not MxNx3, then you'll have to find out why it's not.
For example, it's possible that app.Image started out as MxNx1. If you then tried to operate on it with the blueButton CBF, then it would be implicitly expanded to MxNx2.
My guess is that you're working with single channel (MxNx1) images and that this is your problem. If so, you'll have to provide all the missing channels when you expand it to a color image.
% a single-channel image
Agray = imread('cameraman.tif'); % mxnx1
% generate simple colorized copies by concatenation
zerochan = zeros(size(Agray),class(Agray)); % blank channel
Ared = cat(3,Agray,zerochan,zerochan);
Agreen = cat(3,zerochan,Agray,zerochan);
Ablue = cat(3,zerochan,zerochan,Agray);
montage({Ared Agreen Ablue},'size',[1 3])
Alternatively, you could do the same thing by channel insertion.
% generate simple colorized copies by channel insertion
Ared = zeros([size(Agray,1) size(Agray,2) 3],class(Agray)); % blank image
Ared(:,:,1) = Agray;
% ... and so on
See also:
추가 답변 (1개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!