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

조회 수: 4 (최근 30일)

채택된 답변

David Fletcher
David Fletcher 2021년 5월 22일
편집: David Fletcher 2021년 5월 22일
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);
  댓글 수: 10
Moe Makki
Moe Makki 2021년 5월 23일
oops my bad there was an error with imshow i replaced it with the same picture

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2021년 5월 22일
Try this:
% Find where red value is more than 200.
mask = rgbImage(:, :, 1) > 200;
% Mask the image using bsxfun() function to multiply the mask by each channel individually.
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask, 'like', rgbImage));
  댓글 수: 6
Image Analyst
Image Analyst 2021년 5월 24일
편집: Image Analyst 2021년 5월 24일
In the future, please "Tag" the post as homework if it's homework (I've done it for you now). That tells us not to post full working code, that, if you turn in as your own, may get you into trouble for plagiarism. We wouldn't want you to get into trouble.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Red에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by