How can I mark a defects with lines in a image?
1 次查看(过去 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 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!