Clear Filters
Clear Filters

How can I convert my image to a red image

5 views (last 30 days)
rama
rama on 13 Dec 2022
Answered: DGM on 13 Dec 2022
this is my code:
function redImage(app, event)
a=getappdata(0,'a');
red=a;
red(:,:,2:3)=0;
setappdata(0,'filename',red);
imshow(red,'Parent',app.UIAxes2);
end

Accepted Answer

DGM
DGM on 13 Dec 2022
That would work if you wanted a red image. It would even work if your input image were single-channel.
inpict = imread('cameraman.tif'); % MxNx1
inpict(:,:,2:3) = 0; % create red image by implicit expansion
imshow(inpict)
... but it wouldn't work if you wanted to do a green or blue image using the same method.
inpict(:,:,[1 3]) = 0; % create green image the same way?
imshow(inpict) % it's black because we just zeroed channel 1
See this thread:

More Answers (0)

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!