Check 21 Conversion from RGB Photo

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Locked
genuinerex
Posts: 3
Joined: 2020-03-12T11:18:13-07:00
Authentication code: 1152

Check 21 Conversion from RGB Photo

Post by genuinerex »

I am looking for a reliable method to convert an RGB Color photo from an iphone/android phone to a Check21 compliant B&W TIFF image.

I am using a simple 50% threshold conversion and that is about 60-75% accurate. I need a little AI to determine if I should adjust the threshold up or down by up to 10%. I am looking for any pointers as to how to determine the amount of black in the image easily or how to determine the correct threshold for any given image.

Thank you in advance,
Rex

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Check 21 Conversion from RGB Photo

Post by snibgo »

Do you have ImageMagick? If so, what version, on what platform?

What is a "Check21 compliant B&W TIFF image"?
snibgo's IM pages: im.snibgo.com

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

Re: Check 21 Conversion from RGB Photo

Post by fmw42 »

I suspect it is just a TIFF B&W (bilevel) image with special Check21 tags. ImageMagick will ignore such tags.

genuinerex
Posts: 3
Joined: 2020-03-12T11:18:13-07:00
Authentication code: 1152

Re: Check 21 Conversion from RGB Photo

Post by genuinerex »

Check21 is a US law regulating the conversion of a paper (or color photo) check to a Federal Reserve compliant B&W substitute check image that can be sent in an Image Cash Letter.

I am using Magick.NET version Q8 7.15.4 AnyCPU

Here is my simple solution:

// frontImage and backImage are byte[] arrays of the PNG image from the phone

var bmp = new MagickImage(page == 0 ? frontImage : backImage);

bmp.Format = MagickFormat.Tif;
bmp.Depth = 1;
bmp.Resample(200, 200);
bmp.Threshold(new ImageMagick.Percentage(55)); // 50-60 covers 90% of cases

This works in 60-75% of cases. There are some where this drops out critical items like the name and dollar amount fields. I am guessing that I need a more stable method to convert to B&W that does not lose these key elements.

All paper and ink on US bank checks are required to be compatible with this conversion. This is why most checks have very light printing (converts to white).

https://en.wikipedia.org/wiki/Substitut ... ted_States

genuinerex
Posts: 3
Joined: 2020-03-12T11:18:13-07:00
Authentication code: 1152

Re: Check 21 Conversion from RGB Photo

Post by genuinerex »

I apologize - I am using Magick.NET which is possibly not exactly what this forum is for.

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

Re: Check 21 Conversion from RGB Photo

Post by fmw42 »

Try using the Magick.NET equivalent of -negate -lat 20x20+10% -negate as an adaptive threshold. See my textcleaner script at my link below. That is the basis of the script. Adjust the -lat arguments as desired.

Post an example image if you can showing your input. You can post to some free image hosting service and put the URL(s) here.

Locked