Page 1 of 1

Crack Separation and Analysis using ImageMagick

Posted: 2019-06-30T02:55:06-07:00
by booklooker
I'm new to this community, so hello to everyone here.

I want to use ImageMagick to separate cracks in a specimen, because it's fast, lightweight and easy to use.
I googled a lot yesterday but couldn't figure out existing posts regarding this topic.

That's my starting picture I got from a scanner:
https://ibb.co/XYFPx3b

Since I found no post on exactly crack detection, I tried to use methods that (I thought) would be useful, including:
- lat
- edge / cann-edge-detector
- sobel / gaussian
- improving contrast by sigmoidal function
- masks
and maybe some more I forgot about at the moment.

Combining some of these methods, I got the best result with:

Code: Select all

convert  test.png  -colorspace gray  -auto-level test1.png
convert  test1.png  -sigmoidal-contrast 30,55%  test2.png
convert test2.png -edge 1 -negate test3.png 
Getting this result:
https://ibb.co/gP0m2hP

One can see the crack but there is a lot of noise around (could be some dirt on the surface).
As a starting point for my analysis I only want to see the outline of the specimen and the crack in black with as few noise as possible.

Do you have any ideas, how I can improve my result?
Thanks in advance!

------

I'm running Kubuntu 16.04 LTS with the following version of ImageMagick:

Version: ImageMagick 6.8.9-9 Q16 x86_64 2018-09-28 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP

Re: Crack Separation and Analysis using ImageMagick

Posted: 2019-06-30T05:27:41-07:00
by Werty
Not perfect but close, mess around with it.

Code: Select all

convert test.png -colorspace gray -canny 0x1+10%+20% -negate testresult.png

Re: Crack Separation and Analysis using ImageMagick

Posted: 2019-07-01T16:20:01-07:00
by fmw42
Try this to clean it up some. Adjust the area-threshold as desired

Code: Select all

convert test4.png -auto-level -threshold 0 -morphology open diamond:1 -type bilevel -define connected-components:area-threshold=5 -define connected-components:mean-color=true -connected-components 4 result.png