How to find and draw boundary on some parts of an object in image?

4 ビュー (過去 30 日間)
Baisseyev Miram
Baisseyev Miram 2018 年 5 月 29 日
コメント済み: Image Analyst 2018 年 5 月 30 日
Hi, i have an image of an object and i wanted to find boundary of parts that shown on image in red boundary. Is it possible to find boundary that exactly repeat the region that i need? If possible share some code or function that can help me? Thanks
  1 件のコメント
Image Analyst
Image Analyst 2018 年 5 月 30 日
Image, showing outlines around defects:

サインインしてコメントする。

回答 (2 件)

Anton Semechko
Anton Semechko 2018 年 5 月 29 日
Is this what you are looking for?
im=imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/119409/Image.JPG');
bw=im(:,:,1)>150 & im(:,:,2)<100 & im(:,:,3)<100; % segment-out the red contours
bw=imfill(bw,'holes'); % fill-in contour interiors
bw=imopen(bw,strel('disk',2)); % remove jagged edges
B=bwboundaries(bw,8,'noholes'); % contour coordinates
figure('color','w')
imshow(im)
hold on
for i=1:numel(B)
h=fill(B{i}(:,2),B{i}(:,1),'r');
set(h,'FaceAlpha',0.2,'LineWidth',2,'EdgeColor','b')
end
  1 件のコメント
Baisseyev Miram
Baisseyev Miram 2018 年 5 月 30 日
Thanks, and no i used red lines just to show object but i want to repear exactly the forms of region in image, for example bottom left has some defect in rhomb shape so i want exactly rhomb shape.

サインインしてコメントする。


Image Analyst
Image Analyst 2018 年 5 月 29 日
You have lots of "defects" there - ridges, edges, specks, chips, dents, bumps, or whatever. The software doesn't necessarily know what is normal/OK and what is not normal/bad unless you tell it. The best way is to have a reference image - an image of a perfect part that you can then subtract from or divide by the test image. Do you have that?
  6 件のコメント
Baisseyev Miram
Baisseyev Miram 2018 年 5 月 30 日
Is it possible to play with light to make region with defects for example be darker or brighter and then turn image to binary and find boundary?
Image Analyst
Image Analyst 2018 年 5 月 30 日
Yes, if that's how you want to define defects, then that's perfectly fine. See my Image Segmentation Tutorial for a full demo on how to do that. https://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862&sort=downloads_desc

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGet Started with Image Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by