Introduction to Image Processing With LEADTOOLS

Show in webframe

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) of an image using a number of high-level and low-level methods and classes. These methods and classes include the following:

Automated color reduction:

Dithering method

Main color resolution:

ColorResolutionCommand class

Support for dithering to a custom palette:

Leadtools.ImageProcessing.RasterUserMatchTable class

Specialized resolution functions:

AutoBinarizeCommand class,

AutoBinaryCommand class,

ChannelMixerCommand class,

ConvertToColoredGrayCommand class,

DesaturateCommand class,

DynamicBinaryCommand class,

GrayscaleCommand class,

GrayScaleToDuotoneCommand class,

GrayScaleToMultitoneCommand class,

HalfToneCommand class,

SampleTargetCommand class,

SegmentCommand class,

WindowLevelCommand class,

Low-level color resolution methods and classes:

Convert method,

DitherLine method,

StartDithering method and

StopDithering method

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.

For more information, refer to Introduction and Dithering Methods.

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:

ResizeCommand class and

SizeCommand class

High-level trimming alternatives:

AutoCropCommand class,

AutoCropRectangleCommand class and

CropCommand class

Other high-level transformation classes:

BendCommand class,

ChangeViewPerspectiveCommand class,

CylinderCommand class,

DeskewCommand class,

FlipCommand class,

FreeHandShearCommand class,

FreeHandWaveCommand class,

FreePlaneBendCommand class,

FreeRadialBendCommand class,

ImpressionistCommand class,

PlaneBendCommand class,

PlaneCommand class,

PolarCommand class,

PunchCommand class,

RadialBlurCommand class,

RadialWaveCommand class,

RippleCommand class,

RotateCommand class,

RotateViewPerspective method,

ShearCommand class,

SphereCommand class,

SwirlCommand class,

RasterCodecs.Transform method,

TunnelCommand class,

WaveCommand class,

WindCommand class,

ZoomBlurCommand class and

ZoomWaveCommand class

Low-level resizing methods:

ResizeBuffer method,

Start method and

Stop method

For information about memory allocation when an image gets bigger, refer to Resizing Considerations.

Deskewing

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:

Changing Brightness and Contrast

Removing Noise

Detecting and Enhancing Edges and Lines

Applying Artistic Effects

Correcting Colors

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:

ClearCommand class ClearNegativePixelsCommand class ColorReplaceCommand class ColorThresholdCommand class ConvertSignedToUnsignedCommand class FillCommand class RemoveRedeyeCommand class

Low-Level:

GetPixelColor method GetPixelData method GetRowColumn method GetRow method LineProfileCommand class SetPixelColor method SetPixelData method SetRow method SetRowColumn method

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):RasterProDocMed

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.

Comparing Images

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.

Window-leveling applied with the WindowLevelCommand class can be saved to TIF or DICOM formats without changing the image data. For more information, refer to Saving Window-Leveled Images.

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.