Introduction to Image Processing With LEADTOOLS

Most image processing methods act on an image in memory, which means that the changes become permanent when you save the image to a file. Some low-level methods act on a buffer that you manage; for example, when you process data as it is loaded.

Color Depth and Data Structure

You can change the color resolution (bits per pixel) or reduce the number of colors in an image (for segmentation purposes) by using a number of high-level and low-level methods and classes. These methods and classes include the following:

Automated Color Reduction

Color Resolution (Change a Bitmap's Bits per Pixel)

Reduce and Map to a Custom Palette

Specialized Color Resolution Command Classes

Low-level Color Resolution Methods

Color Space Classes and Methods

Windows uses the BGR color-space model. When loading or saving a file, LEADTOOLS automatically converts image data to or from BGR, as necessary. Nevertheless, LEADTOOLS provides methods for other color-space models. You can use the high-level ColorSeparateCommand and ColorMergeCommand classes to create and merge color separations using a number of color-space models, including RGB, CMYK, CMY, HSV, and HLS. You can also use the low-level RasterColorSpace class to convert data in a buffer from one color-space model to another, including RGB, YUV, CMYK, CMY, YIQ, HSV, and HLS.

Note that LEADTOOLS also supports loading TIFF CMYK files without converting the data to BGR. This is done by loading each CMYK plane as a separate page in a RasterImage using LoadCmykPlanes. To save the planes as TIFF CMYK, call SaveCmykPlanes. For more information, refer to Handling CMYK Files as Separate Images.

For more information, refer to Introduction and Dithering Methods.

Lightening, Darkening, Filtering, Detection, and Correction Topics

A number of image processing methods change the values of pixels in an image (or a region in the image) using various algorithms and filters. These may be used to improve the appearance of the image, to analyze details in the image, or to apply artistic effects. The refer to the following topics for more details:

Window-Leveling (Document and Medical only):

Window-leveling is only valid for 12 and 16-bit grayscale images and is used to map grayscale intensities by specifying the bit range and/or a user-defined color map. WindowLevel provides two modes: Paint for "on demand" window-leveling that affects the paint methods and does not alter the underlying image data, and PaintAndProcessing that converts the image to a window-leveled 8 or 24-bit RGB image. The bit range and palette are passed to the method through parameters. To help set up a bit range and a palette, LEADTOOLS provides the MinMaxBitsCommand class and the MinMaxValuesCommand class. The MinMaxBitsCommand class gets the minimum and maximum bits of the values present in a 12 or 16-bit grayscale image. MinMaxValuesCommand class gets the minimum and maximum intensity values of the image. WindowLevelFillLookupTable fills a user-allocated LUT with a color gradient based on the specified values.

Only TIFF and DICOM file formats are capable of storing image data that has been window-leveled. Images can be window-leveled by using WindowLevel and specifying RasterWindowLevelMode.PaintAndProcessing for the flags parameter or by loading an image from a file format that supports window-leveling. If a window-leveled image is saved as any other file format, the image data will be converted. For more information, refer to Saving Window-Leveled Bitmaps.

Geometric Transformations

Geometric transformations include resizing, trimming, rotating, shearing, flipping, or reversing. Some geometric transformation methods are designed for specifically for document imaging applications. For example, the DeskewCommand class automatically straightens images of scanned documents. For resizing any kind of image, the SizeCommand class provides useful options, but you may also find the alternative and low-level methods useful.

LEADTOOLS also provides the Transform method for performing lossless flips, rotations, and reversals of compressed image files. However, only certain file formats are supported. This method is faster and provides better results than loading an image, transforming it, and re-saving it. Repeated re-saving of an image using lossy compression will cause image degradation, but calling this method will not cause any image degradation. It uses the CodecsTransformMarkerCallback for processing the file and for writing any updated markers within the file. For more information, refer to Transform and CodecsTransformMarkerCallback.

The following are geometric transformations methods:

High-Level Resizing Methods

High-Level Trimming Methods

Other High-Level Transformation Classes

Low-Level Resizing Methods

For information about memory allocation when an image becomes larger, refer to Resizing Considerations.

Deskewing and Unwarping Methods

An image can be skewed when it is scanned and the document is not perfectly aligned on the scanned. Additionally, image skew can occur if a camera (smart phone) is used to capture an image, and the camera is not on a perfectly parallel to the document. To overcome this common problem in scanned and captured document images, LEADTOOLS provides the following command classes. Document images include bank checks and forms. For more information, refer to Deskewing:

Combine or Compare Multiple Images

The CombineCommand class lets you perform mathematical operations on all or part of another image to the target image. You can pass flags to control whether the new pixels simply replace the target ones or are combined with the target ones in a specific way. You can also define regions in either or both of the images, and if you do, the class only affects the intersection of the regions. The CombineCommand class extends the capabilities of the CombineFastCommand class by supporting the combine images of different bits per pixel and parameters to specify which color planes to use when combining the images.

Source and destination images may be combined by warping all or part of a source image into part of a destination image. To combine images in this manner, use the CombineWarpCommand class.

The Underlay method also combines images, but it also has a much more specific purpose. It combines two images so that one appears to be an underlying texture for the other.

The PicturizeListCommand replaces an image with a new image created by combining images in a list. The PicturizeSingleCommand class picturizes an image using various versions of a single image.

Two images can also be blended by combining the images with an opacity value. The AlphaBlendCommand class combines two images with a fixed opacity value to create a new blended image. The FeatherAlphaBlendCommand class combines two images with feathering by using a variable opacity that depends on a fade mask. A fade mask image can be created using the FadedMaskCommand class. The TextureAlphaBlendCommand class combines image data from a mask image and an underlay image with an underlay effect. The result is used as a fade mask that will be used to combine the source and destination images with variable opacity. The result is combined again with the destination image using a constant opacity.

The BumpMapCommand class combines an image with a bump image to create a three-dimensional texture pattern.

Two images or parts of two images can be compared using the CorrelationCommand class. This class compares all or part of one image with all the areas of the same dimensions in another image and finds those areas that match according to the measure of correlation.

The DigitalSubtractCommand class does not combine images, but subtracts the live (destination) image from the mask (source) image to show the differences between the two images.

Access and Update Pixel Data

A number of other methods get and put pixel data. For example, you can fill an image with a color, and you can get and put individual pixel values. These include the following:

High-Level Classes

Low-Level Class and Methods

Windows GDI and GDI+

Treating the image as a device context opens up many possibilities. The CreateLeadDC method creates a device context. You can then use Windows GDI methods to draw lines, text, or images onto the image. Alternatively, you can create a GDI+ Graphics object for drawing by using the Leadtools.Drawing.RasterImageGdiPlusGraphicsContainer method.

See Also

Manipulating Image Data

ImageProcessing.GrayScaleCommand

WindowLevelCommand

Help Version 20.0.2020.4.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Imaging, Medical, and Document