Effacer les filtres
Effacer les filtres

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

3 vues (au cours des 30 derniers jours)
Ayberk Ay
Ayberk Ay le 14 Mar 2020
Commenté : Ayberk Ay le 15 Mar 2020
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);

Réponse acceptée

Image Analyst
Image Analyst le 15 Mar 2020
Modifié(e) : Image Analyst le 15 Mar 2020
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 commentaire
Ayberk Ay
Ayberk Ay le 15 Mar 2020
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!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by