How can I mark a defects with lines in a image?
조회 수: 3 (최근 30일)
이전 댓글 표시
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);
댓글 수: 0
채택된 답변
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.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!