Separating yellow from red in the image

조회 수: 4 (최근 30일)
Kamil Brzoska
Kamil Brzoska 2020년 3월 26일
답변: Image Analyst 2020년 3월 27일
Hi,
I have an excersise in which i have to separate the red circles from the rest of the picture. I have the problem, because in the picture are also yellow circles, if I set Blue and green channel to 1, then yellow circles are also red, while if I set Green channel to 0.99 then there are still yellow circles in the picture. I want only red circles to be visible.
This is original picture:
This is original picture
This is code I wrote:
clc
clear all
I=imread('M.png');
I=im2double(I);
R=imhist(I(:,:,1));
G=imhist(I(:,:,2));
B=imhist(I(:,:,3));
R1=(I(:,:,1));
G1=(I(:,:,2));
B1=(I(:,:,3));
figure()
subplot(2,4,1)
imshow(I)
subplot(2,4,2)
imhist(R1);
xlabel('Próg TR=0.1')
subplot(2,4,3)
imhist(G1);
xlabel('Próg TG=0.2')
subplot(2,4,4)
imhist(B1);
xlabel('Próg TB=0.1')
subplot(2,4,5)
T1=0.95
BW = imbinarize(R1, T1);
L = bwlabel(BW);
T2=1
BW1 = imbinarize(G1, T2);
L1 = bwlabel(BW1);
T3=1
BW2 = imbinarize(B1,T3);
L2 = bwlabel(BW2);
i1(:,:,1)=L;
i1(:,:,2)=L1;
i1(:,:,3)=L2;
imshow(i1)
This is what happen if i set RGB as below:
And if i change G to 0.99
I know that yellow is [1 1 0] and I suppose, that when I change G to 1 then yellow is [1 0 0] (red). I would be very grateful for help in creating a processed image without yellow circles

채택된 답변

Image Analyst
Image Analyst 2020년 3월 27일
Why don't you use the Color Thresholder on the Apps tab and see what values it uses?

추가 답변 (0개)

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by