Edge feature detection on 'noisy', low-contrast images

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?".
Post Reply
mkeveney
Posts: 5
Joined: 2019-04-19T16:44:40-07:00
Authentication code: 1152

Edge feature detection on 'noisy', low-contrast images

Post by mkeveney »

I want to isolate the 'wavy line' feature of the attached image.

I thought the approach should be to somehow blur or average the pixel colors first; then apply a threshold operation of some sort. I'd ideally like a black & white image when done.

The problem seems to be that the background (for both light and dark regions) is quite noisy, which, seems to interfere.. or maybe it's something else. I haven't even got close.

Can someone take a stab at it or at least suggest an approach?

http://keveney.com/forum-sample.png
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Edge feature detection on 'noisy', low-contrast images

Post by snibgo »

I'm not sure what result you want. Can you sketch the required result, eg with Gimp?

If this is a photo, the lighting is uneven. The first step might be to correct that.

There is almost no variation in hue or saturation, so I suppose you could grayscale the image. There is overlap in lightness between the "light" stripes and the "dark" stripes.

There is a reasonable contrast at the left edges of the light strips, but poorer contrast at the right edges.

"-statistic median" might be useful.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Edge feature detection on 'noisy', low-contrast images

Post by fmw42 »

Try something like this. Adjust or increase the arguments as desired.

Code: Select all

convert forum-sample.png -colorspace gray -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle -statistic median 15x15 -sharpen 0x15 -canny 0x1+5%+20% result.png
See viewtopic.php?f=4&t=25405

It is not great, but best I can think of at the moment.
mkeveney
Posts: 5
Joined: 2019-04-19T16:44:40-07:00
Authentication code: 1152

Re: Edge feature detection on 'noisy', low-contrast images

Post by mkeveney »

snibgo:
> Can you sketch the required result, eg with Gimp?

Here's what I had in mind, though I could do with simple outlines, as produced by fmw42's attempt.

Image

> If this is a photo, the lighting is uneven. The first step might be to correct that.

The ideal process would tolerate this unevenness, though I can more carefully control the photography if necessary.

fmw42: thanks for your example. I'll experiment with it too. Gratified to see that it's not something easy I was missing, anyway.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Edge feature detection on 'noisy', low-contrast images

Post by fmw42 »

Try

Code: Select all

convert forum-sample.png -colorspace gray -statistic median 51x51 -brightness-contrast 0x50 -sharpen 0x51 result.png
Post Reply