Crack Separation and Analysis using ImageMagick

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Posts: 1
Joined: 2019-06-30T01:36:40-07:00
Authentication code: 1152

Crack Separation and Analysis using ImageMagick

Post 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:

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:

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
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP

Posts: 69
Joined: 2010-08-06T05:37:36-07:00
Authentication code: 8675308

Re: Crack Separation and Analysis using ImageMagick

Post 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
Windows 10 user

User avatar
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Crack Separation and Analysis using ImageMagick

Post 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