How to Create Defect Class for Image Processing?

Good day everyone, I have a code to inspect part's surface using image processing. And i want one of my output to show the scratches class such as:
class 1 scratch;
class 2 scratch;
class 3 scratch.
I've already calculate the total area of the image for this system. How can I generate the coding for this kind of output? Thank you so much for your replies.

Respuestas (2)

Image Analyst
Image Analyst el 30 de Nov. de 2021

0 votos

Maybe try thresholding with the 'adaptive' option in imbinarize().
Or try a bottomhat filter with imbothat().
Or try getting a standard deviation image with stdfilt() and then thresholding.
Once you have the binary image you can measure all kinds of features with regionprops, like area, perimeter, maximum length, etc. Then you can train it with the Classification Learner app to take all those features and make a prediction as to what kind of defect (Class 1 scratch, class 2 scratch, etc.) it is.

3 comentarios

Afrena Azman
Afrena Azman el 1 de Dic. de 2021
Thank you for your reply. Just for a knowledge, can I use something like
for X = total
if any(0<X)&&(X<100)
disp("class 1 scratch")
elseif any(101<X)&&(X<300)
disp("class 2 scratch")
elseif any(301<X)&&(X<500)
disp("class 3 scratch")
elseif any(501<X)&&(X<700)
disp("class 4 scratch")
elseif any(701<X)&&(X<900)
disp("class 5 scratch")
end
end
for this? But seems like my coding would become longer am I right
I doubt that will work. Your scratches might have lots of gray levels in them so it might just pop into the first case. Plus, it doesn't take into account the size of the scratch, it only cares about what the gray levels are.
Afrena Azman
Afrena Azman el 1 de Dic. de 2021
Understood sir, thank you so much for your help.

Iniciar sesión para comentar.

yanqi liu
yanqi liu el 1 de Dic. de 2021

0 votos

yes,sir,may be use regionprops to get some properties,such as
Boundingbox,Area,Circularity
then make judge rule to classify

1 comentario

Afrena Azman
Afrena Azman el 1 de Dic. de 2021
Noted that. I tried using the Classification Learner Apps and it works. Thank you so much

Iniciar sesión para comentar.

Preguntada:

el 30 de Nov. de 2021

Comentada:

el 1 de Dic. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by