Search Results for

    Show / Hide Table of Contents

    Class PixColormap

    Inheritance
    System.Object
    PixColormap
    Implements
    System.IDisposable
    Namespace: DynamicTesseract
    Assembly: IronOcr.dll
    Syntax
    public sealed class PixColormap : Object

    PixColormap manages the palette of a colormapped Leptonica image, the indexed table that maps each pixel value to an actual PixColor. It is the type code works through when an image stores colors by index rather than per pixel, for example a quantized scan whose palette must be inspected or edited before recognition. Most text OCR never touches it, but color cleanup and image-preparation steps do.

    A colormap is created through the static factories rather than a constructor: Create allocates an empty map of a given bit depth, while the two CreateLinear overloads build a ready-made grayscale ramp. Because the type holds a native handle and implements IDisposable, dispose it (or use using) once editing is finished. Count reports how many colors the map currently holds, FreeCount how many slots remain, and Depth the bit depth that bounds its capacity.

    Colors are added and queried through the palette methods. AddColor appends a PixColor, AddNewColor adds one only if it is not already present and returns its index, and AddNearestColor maps a requested color to the closest existing entry. AddBlackOrWhite and SetBlackOrWhite manage the black and white endpoints, IsUsableColor tests whether a color can be added within the depth limit, and the Item indexer reads an entry by position. Clear empties the map for reuse. Build each entry from a PixColor, the RGBA color this table indexes.

    using DynamicTesseract;
    
    using PixColormap map = PixColormap.Create(8);
    map.AddColor(new PixColor(0, 0, 0, 255));
    map.AddNewColor(new PixColor(255, 255, 255, 255), out int whiteIndex);

    The replace color example edits image colors before OCR, and the image color correction how-to covers color cleanup.

    Properties

    Count

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    System.Int32

    Depth

    Declaration
    public int Depth { get; }
    Property Value
    Type Description
    System.Int32

    FreeCount

    Declaration
    public int FreeCount { get; }
    Property Value
    Type Description
    System.Int32

    Item[Int32]

    Declaration
    public PixColor this[int index] { get; set; }
    Parameters
    Type Name Description
    System.Int32 index
    Property Value
    Type Description
    PixColor

    Methods

    AddBlackOrWhite(Int32, out Int32)

    Declaration
    public bool AddBlackOrWhite(int color, out int index)
    Parameters
    Type Name Description
    System.Int32 color
    System.Int32 index
    Returns
    Type Description
    System.Boolean

    AddColor(PixColor)

    Declaration
    public bool AddColor(PixColor color)
    Parameters
    Type Name Description
    PixColor color
    Returns
    Type Description
    System.Boolean

    AddNearestColor(PixColor, out Int32)

    Declaration
    public bool AddNearestColor(PixColor color, out int index)
    Parameters
    Type Name Description
    PixColor color
    System.Int32 index
    Returns
    Type Description
    System.Boolean

    AddNewColor(PixColor, out Int32)

    Declaration
    public bool AddNewColor(PixColor color, out int index)
    Parameters
    Type Name Description
    PixColor color
    System.Int32 index
    Returns
    Type Description
    System.Boolean

    Clear()

    Declaration
    public void Clear()

    Create(Int32)

    Declaration
    public static PixColormap Create(int depth)
    Parameters
    Type Name Description
    System.Int32 depth
    Returns
    Type Description
    PixColormap

    CreateLinear(Int32, Boolean, Boolean)

    Declaration
    public static PixColormap CreateLinear(int depth, bool firstIsBlack, bool lastIsWhite)
    Parameters
    Type Name Description
    System.Int32 depth
    System.Boolean firstIsBlack
    System.Boolean lastIsWhite
    Returns
    Type Description
    PixColormap

    CreateLinear(Int32, Int32)

    Declaration
    public static PixColormap CreateLinear(int depth, int levels)
    Parameters
    Type Name Description
    System.Int32 depth
    System.Int32 levels
    Returns
    Type Description
    PixColormap

    Dispose()

    Declaration
    public void Dispose()

    IsUsableColor(PixColor)

    Declaration
    public bool IsUsableColor(PixColor color)
    Parameters
    Type Name Description
    PixColor color
    Returns
    Type Description
    System.Boolean

    SetBlackOrWhite(Boolean, Boolean)

    Declaration
    public bool SetBlackOrWhite(bool setBlack, bool setWhite)
    Parameters
    Type Name Description
    System.Boolean setBlack
    System.Boolean setWhite
    Returns
    Type Description
    System.Boolean

    Implements

    System.IDisposable
    ☀
    ☾
    Downloads
    • Download with Nuget
    • Start for Free
    In This Article
    Back to top
    Install with Nuget
    %s requires a valid license key for further deployment. Get Trial Below.
    ironsuite
    Blue key in circleGet Started for Free
    30 days full access • No credit card required
    Test in a live environment

    Test in production without watermarks.
    Works wherever you need it to.

    Fully-functional product

    Get 30 days of fully functional product.
    Have it up and running in minutes.

    24/5 technical support

    Full access to our support engineering team during your product trial

    Grey key in circleGet Started for Free
    The trial form was submitted successfully.
    Grey check in circleTrial key delivered
    Your key has been issued and sent to your email.
    Calendar in circleBook Free Live Demo
    No cards • no pitches • no commitments Pick a time for a quick, personalized demo
    Get the most out of your 30-day trial with:

    Live product and key features walk-through

    Project-specific recommendations

    All your questions answered

    Grey key in circleBook Free Live Demo
    Your booking has been completed Check your e-mail for confirmation

    Want to deploy Iron Suite
    to a live project for FREE?

    What’s included?

    • Test in production without watermarks
    • 30 days fully functional product
    • 24/5 technical support during trial
    ironpdf Logo
    ironword Logo
    ironxl Logo
    ironppt Logo
    ironocr Logo
    ironbarcode Logo
    ironqr Logo
    ironprint Logo
    ironzip Logo
    ironwebscraper Logo
    Iron Software sales team
    Online 24/5
    Have Enterprise licensing requirements?
    Request Iron Suite Enterprise trial
    Key in blue circle

    Get your free 30-day Trial Key instantly

    Your trial license will be sent to your email address

    No limitations. 100% unlocked. No credit card.

    bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
    Or
    Key in blue circle

    Complete Your Trial Key Signup

    Tell us a little more about yourself.

    Key in blue circleNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
    Key in blue circle

    Your license key has been delivered to your inbox

    Can't find it? Check your spam folder.

    What’s next?
    Install with NuGet
    Add IronOCR to your project
    Quickstart Guide
    Helpful resources to get started

    Need help getting started?

    Book a Free Live Demo

    See IronOCR in action and get your licensing questions answered, or

    Key in blue circle

    Your demo request is in.

    You'll receive an invite via email shortly.

    What’s next?
    Explore Documentation
    Review Licensing Options
    badge_greencheck_in_yellowcircle
    Thank you
    Your trial key should be in the email.
    If it is not, please contact support@ironsoftware.com
    • Logo Aetna
    • Logo NASA
    • Logo GE
    • Logo Porsche
    • Logo USDA
    • Logo Qatar
    Join Millions of Engineers who’ve tried IronOCR
    Your trial key should be in the email.
    If it is not, please contact support@ironsoftware.com