Cleaning up noise around text

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?".
mark0978
Posts: 4
Joined: 2011-05-09T08:51:23-07:00
Authentication code: 8675308

Re: Cleaning up noise around text

Post by mark0978 »

I was kind of stunned at how well some of the cleanups worked. Thanks very much.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Cleaning up noise around text

Post by anthony »

Some of the clean up methods can be great, but the real problem is matching the right clean-up to the specific problem. It is not something that can be automated in a general case, only for a specific situation or sequence of image processing.

I was suprised I did not get any comment on the first use of a write-mask' to create a conditional-dilate (erode).

In any case I am glad we were able to help.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
HugoRune
Posts: 90
Joined: 2009-03-11T02:45:12-07:00
Authentication code: 8675309

Re: Cleaning up noise around text

Post by HugoRune »

It is a pretty nifty application for write masks. I had not known there were clip-masks in imagemagick before, they look like they could be useful for all sorts of things.

one application would be a canny-style edge detector
http://en.wikipedia.org/wiki/Canny_edge_detector

something like
convert lenna.png -edge 1 -threshold 70% edges_strong.png
convert lenna.png -edge 1 -threshold 10% -negate edges_weak.png
convert edges_strong.png -clip-mask edges_weak.png -morphology dilate:500 square +clip-mask edges.png

Image

That should be equivalent to the hysteresis thresholding part of the canny edge detector. A little slow due to the neccessity of a fixed iteration count, would probably be faster in im7

the non-maximum suppression part should be possible with a looong -fx expression, though it might need some nested IFs and would be very slow. Have to think about that a bit more
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Cleaning up noise around text

Post by anthony »

Nice example of using a pixel write mask.

the 500 is a little overboard for edge detection. 5 should be enough.

The alternative to that is some sort of external loop with 'change' detection to figure out when to terminate.
probably best done in a actual API so you don't need to re-initialise every time after checking for more changes.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Cleaning up noise around text

Post by anthony »

Update...

IMv7 an images write mask will definitely be visible to operational pixel processing loops. As such things that do major calculations such as morphology and convolutions can see the write mask of an image, and as such 'skip' the calculations for pixels that are not actually writeable!

That should make write masks MUCH faster, and even allow morphology with infinite iterations to abort when no more 'writable' pixels change.

NOTE even in IMv6 write masks are used internally to implement 'masked compostions'.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply