Edge detection when the boundaries are clearly marked

2 次查看(过去 30 天)
I have an image like this and I need to extract the regions marked by the boundaries highlighted by the color. How do I do it? This may be a simple question, but I realize no question is simple in image processing. Thanks.
CD63_W1-1-2-K.1.04_101698569.jpg
  2 个评论
Kasthuri Kannan
Kasthuri Kannan 2019-11-6
Yes, like the black boundary is one region, green another etc. In general, there could be as many as 9 such boundaries and I want to mark them separately. Thanks.

请先登录,再进行评论。

回答(1 个)

darova
darova 2019-11-6
Try this:
A = imread('test.jpeg');
subplot(1,2,1)
imshow(A)
RGB = [140 224 226]; % color you want (cyan)
% RGB = [226 129 226]; % color you want (magenta)
% RGB = [150 240 120]; % color you want (green)
% RGB = [120 120 120]; % color you want (grey)
% RGB = [120 120 190]; % color you want (violet)
% RGB = [230 170 140]; % color you want (orange)
e = 20; % color shift
c1 = abs(RGB(1)-double(A(:,:,1))) < e;
c2 = abs(RGB(2)-double(A(:,:,2))) < e;
c3 = abs(RGB(3)-double(A(:,:,2))) < e;
B = (c1+c2+c3)==3;
B1 = bwareaopen(B,10); % remove small areas
I = repmat(B1,[1 1 3]);
I = uint8(I).*A;
subplot(1,2,2)
imshow(I)

Community Treasure Hunt

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

Start Hunting!

Translated by