How can I mark a defects with lines in a image?

조회 수: 3 (최근 30일)
Ayberk Ay
Ayberk Ay 2020년 3월 14일
댓글: Ayberk Ay 2020년 3월 15일
Hey everyone! I already asked something about this question but I deleted it because I don't have that problem anymore about that.Anyways,
I detected a defect (scratch) in my image and I want to show detected scratch on the original image and to this I want to mark it with lines (red lines or whatever).Maybe I can use regionprops but I don't know how to do. Finally if you manage to solve my question with a code, please add it to my main code.They should be only a code.
The attached is image and Gradients function.
Code:
im1 = imresize(imread('5817292-5_yellow_WRL.bmp'),0.5);
gSize = 15;
im1 = imfilter(im1,fspecial('gaussian',[gSize,gSize],gSize/2),'replicate');
[~,~,mag,~] = Gradients(im1);
imshow(mag);
mgBw = mag > 0.5*max(mag(:));
imshow(mgBw);
mgBw1 = imclose(mgBw,strel('disk',1));
imshow(mgBw1);
mgBw2 = bwareaopen(mgBw1,500);
imshow(mgBw2);
mgBw3 = imclose(mgBw2,strel('disk',2));
imshow(mgBw3);
mgBw4 = imfill(mgBw3,'holes');
imshow(mgBw4);

채택된 답변

Image Analyst
Image Analyst 2020년 3월 15일
편집: Image Analyst 2020년 3월 15일
Hopefully you deleted your prior question before anyone commented on it or answered it. People don't take kindly to that. People also like it if you vote for or Accept their answers to give them "reputation points" for helping you.
Try imoverlay()
rgbImage = imoverlay(im1, mgBw4);
imshow(rgbImage);
I'd also suggest you take a look at applying stdfilt() to your image and then thresholding to find the scratches.
  댓글 수: 1
Ayberk Ay
Ayberk Ay 2020년 3월 15일
I couldn't delete my prior question because there is no deleting options for that question but at least I accepted the answer.
Also thanks so much for this solution, I tried imoverlay() and the result is really good.
I'll try stdfilt() and then thresholding also, thanks again!

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by