Cleaning up noise around text
Re: Cleaning up noise around text
I was kind of stunned at how well some of the cleanups worked. Thanks very much.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Cleaning up noise around text
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.
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/
https://imagemagick.org/Usage/
Re: Cleaning up noise around text
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
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
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
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
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Cleaning up noise around text
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.
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/
https://imagemagick.org/Usage/
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Cleaning up noise around text
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'.
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/
https://imagemagick.org/Usage/