Most image processing methods act on an image in memory, which means that the changes become permanent when you save the image in a file. Some low-level methods act on a buffer that you manage, for example when you process data as it is loaded.
Changing the Data Format
You can change the color resolution (bits-per-pixel) or reduce the color of the image (for segmentation purposes) using a number of high-level and low-level methods and classes. These methods and classes include the following:
Automated color reduction:
Main color Resolution (Changing the bitmap bits-per-pixel):
Support for dithering to a custom palette:
Specialized resolution functions:
Low-level color resolution methods and classes:
Windows always uses the RGB color-space model, and when loading or saving a file, LEADTOOLS converts image data to or from RGB, 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 raw 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 an Image using LoadCmykPlanes. To save the planes as TIFF CMYK, call SaveCmykPlanes. For more information, refer to Handling CMYK Files as Separate Images.
Doing Geometric Transformations
Geometric transformations include resizing, trimming, rotating, shearing, flipping, or reversing an image. Some geometric transformation methods are designed mainly for document imaging. For example, DeskewCommand lets you automatically straighten scanned documents. For resizing any kind of image, the SizeCommand class provides the most up-to-date 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. However, only certain file formats are supported at this time. This method provides better results than loading an image, transforming it using the RotateCommand, or FlipCommand and resaving it. It uses the CodecsTransformMarkerCallback callback for processing the file and for writing any updated markers within the file. For more information, refer to Transform and the CodecsTransformMarkerCallback callback.
The following is a list of methods that can be used for doing geometric transformations:
High-level resizing alternatives:
High-level trimming alternatives:
Other high-level transformation classes:
Low-level resizing methods:
For information about memory allocation when an image gets bigger, refer to Resizing Considerations.
LEADTOOLS provides the following command classes that can automatically straighten scanned documents:
For more information, refer to Deskewing.
Lightening, Darkening, Filtering, and So Forth
A number of image processing methods let you change the values of pixels across an image (or a region in the image) using various algorithms and filters. You might do this to improve the appearance of the image, to analyze details in the image, or to apply artistic effects. The following topics provide details:
Adding Another Image to an Image
The CombineCommand class lets you add all or part of another image to the target image. You can pass flags to control whether the new pixels simply replace the old ones or are combined with the old ones in a specific way. You can also define regions in either or both of the images, and if you do, the class affects only the intersection of the regions. The CombineCommand class extends the capabilities of the CombineFastCommand class by letting the user combine images of different bits per pixel and 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 has a much more specific purpose. It combines two images so that one appears to be an underlying texture for the other.
LEADTOOLS provides two classes for picturizing an image. The PicturizeListCommand replaces an image with a new image created by combining images present 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 BumpMapCommand class lets you combine an image with a bump image to create a three-dimensional texture pattern.
A number of other methods let you 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 Methods and Classes:
Treating the image as a device context opens up many possibilities. The CreateLeadDC method lets you get the device context. You can then use Windows GDI methods to draw lines, text, or images on the image. Alternatively, you can create a GDI+ Graphics object for drawing, using the Leadtools.Drawing.RasterImageGdiPlusGraphicsContainer method.
TheTextureAlphaBlendCommand 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 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.
Window-leveling (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. Two methods are provided for window-leveling. WindowLevel provides "on demand" window-leveling for the paint methods and does not alter the image, and WindowLevel converts the image to a window leveled 8 or 24 bit RGB image. The bit range is passed to the methods through nLowBit and nHighBit parameters and the user-defined color map is passed through the pLUT parameter. To help set up a bit range and a color map, 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 the user-allocated LUT with a color gradient based on the specified values. For more information, refer to the individual entries for the methods.
Only TIFF and DICOM file formats are capable of saving images that have 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 before being saved. For more information, refer to Saving Window-Leveled Bitmaps.
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.
Products | Support | Feedback: Introduction to Image Processing With LEADTOOLS | Introduction | Help Version 19.0.2017.3.23