Welcome Guest! To enable all features, please Login or Register.



Last Go to last post Unread Go to first unread post
#1 Posted : Friday, February 24, 2017 12:07:52 PM(UTC)


Groups: Registered, Tech Support, Administrators
Posts: 161

Was thanked: 9 time(s) in 9 post(s)

This shows how to use the ColorSeparateCommand in conjunction with the AddCommand to drop a specific color from an image. This particular code block shows how the black form can be removed from the image, leaving only a 1-bit image of the colored text. This can subsequently be used to mask out the text or for OCR purposes.

Note the ColorSeparateCommand produces four pages in the output rasterimage, one each for cyan, magenta, yellow, and black, in that order. By removing the last (black) page prior to calling AddCommand, only the CMY planes are added together. This can be modified to keep or drop different combinations of colors. As the ColorSeparateCommand returns planes based on intensity, the resultant images are white-on-black, hence using the InvertCommand to create black-on-white before saving the output.

Here's links to the RasterCommands of interest used here.


      private static void DoColorPlaneSeparation(string input)
         string outPath = Path.GetDirectoryName(input);
         string outFile = Path.GetFileName(input);

         using (RasterCodecs codecs = new RasterCodecs())
            RasterImage image = codecs.Load(input);
            ColorSeparateCommand csc = new ColorSeparateCommand(ColorSeparateCommandType.Cmyk);



            AddCommand ac = new AddCommand(AddCommandType.Add);

            InvertCommand ic = new InvertCommand();

            AutoBinarizeCommand abc = new AutoBinarizeCommand();

            string outputFile = Path.Combine(outPath, "output_" + outFile);
            codecs.Save(ac.DestinationImage, outputFile, image.OriginalFormat, image.BitsPerPixel);

File Attachment(s):
output_label.tif (12kb) downloaded 282 time(s).

File Attachment(s):
label.tif (176kb) downloaded 274 time(s).

Edited by user Friday, June 1, 2018 10:37:51 AM(UTC)  | Reason: Updating links to v20

Nick Crook
Developer Support Engineer
LEAD Technologies, Inc.

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.056 seconds.