Removing "checks" dithering

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
BenjaminKim
Posts: 11
Joined: 2019-05-03T12:14:07-07:00
Authentication code: 1152

Removing "checks" dithering

Post by BenjaminKim »

Hello,

I have monotone images being generated outside of IM, and contain what's effectively the "ordered-dither=checks" dithering.

I've been trying to figure out a way to remove such dithering - what I'd like is to make any/all instances of such dithering fully black.

Example file is (Group 4 monochrome tiff):

https://drive.google.com/open?id=1hLP9h ... rjohtvWF82

And here is the up-close zoom of the dithering:

https://drive.google.com/open?id=1KqdK1 ... rECwvxYoV4

https://drive.google.com/open?id=14CBgt ... tyU-91jdNP

https://drive.google.com/open?id=1IGtFX ... 0vLY8hqMZ0


Ultimately, where dithering exists, I'd like to make it black. In the third close-up, I'd want to make it black up until there is a solid area of white.

I've been trying to leverage morphology to accomplish, but not having much luck. Any input or thoughts is greatly appreciated.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Removing "checks" dithering

Post by fmw42 »

One potential way is notch filtering via FFT processing. See http://www.fmwconcepts.com/imagemagick/ ... se_removal

Another way, might be to simply create a mask image that is black where the checkerboard does not exist and white where it does. Then use the mask to replace the checkerboard with a black image by 3 image compositing. See https://imagemagick.org/Usage/compose/#compose
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Removing "checks" dithering

Post by snibgo »

How about (Windows syntax):

Code: Select all

magick ^
  001.tif ^
  ( -clone 0 -morphology HMT 3x1:0,1,0 -negate ) ^
  ( -clone 0 -morphology HMT 1x3:0,1,0 -negate ) ^
  -background None ^
  -compose Darken -layers flatten ^
  out.png

snibgo's IM pages: im.snibgo.com
BenjaminKim
Posts: 11
Joined: 2019-05-03T12:14:07-07:00
Authentication code: 1152

Re: Removing "checks" dithering

Post by BenjaminKim »

Oh wow - perfect - thank you! I had not looked into FFT - but have definitely reviewed everything I could find you've written re Morphology. I had actually explored HMT for a bit to deal with something way earlier in the process, but ultimately took a different approach and forgot about it.

This is great - thank you so much!
Post Reply