MATLAB: How do i scan pixel from an rgb image and then if red value is higher than 200 show red only and if its lower = all 3 colors = 0

color segmentationhomeworkImage Processing Toolboximage rgb

Best Answer

May not be the best answer - I don't do much image manipulation work
%load and display image
imageData=imread('test.jpeg');
subplot(2,1,1)
imshow(imageData);
%Create mask for red colour data >200
redMask=imageData(:,:,1)>200;
%Apply mask to red channel
red=imageData(:,:,1);
red=red.*cast(redMask,'like',imageData);
%Clear colour data from all channels
imageData=imageData*0;
%Replace red channel with the masked data
imageData(:,:,1)=red;
%Show image with red channel mask mask
subplot(2,1,2)
imshow(imageData);
Related Question