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!