UnmanagedImage Class |
Namespace: Accord.Imaging
The UnmanagedImage type exposes the following members.
Name | Description | |
---|---|---|
UnmanagedImage(BitmapData) |
Initializes a new instance of the UnmanagedImage class.
| |
UnmanagedImage(IntPtr, Int32, Int32, Int32, PixelFormat) |
Initializes a new instance of the UnmanagedImage class.
|
Name | Description | |
---|---|---|
Bytes |
Gets the image size, in bytes.
| |
Height |
Image height in pixels.
| |
ImageData |
Pointer to image data in unmanaged memory.
| |
Offset | ||
PixelFormat |
Image pixel format.
| |
PixelSize |
Gets the size of the pixels in this image, in bytes. For
example, a 8-bpp grayscale image would have pixel size 1.
| |
Size |
Gets the image size, in pixels.
| |
Stride |
Image stride (line size in bytes).
| |
Width |
Image width in pixels.
|
Name | Description | |
---|---|---|
Clone |
Clone the unmanaged images.
| |
Collect16bppPixelValues |
Collect pixel values from the specified list of coordinates.
| |
Collect8bppPixelValues |
Collect pixel values from the specified list of coordinates.
| |
CollectActivePixels |
Collect coordinates of none black pixels in the image.
| |
CollectActivePixels(Rectangle) |
Collect coordinates of none black pixels within specified rectangle of the image.
| |
Copy |
Copy unmanaged image.
| |
Create(Int32, Int32, PixelFormat) |
Allocate new image in unmanaged memory.
| |
Create(Int32, Int32, Int32, PixelFormat) |
Allocate new image in unmanaged memory.
| |
Dispose |
Dispose the object.
| |
Dispose(Boolean) |
Dispose the object.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize |
Destroys the instance of the UnmanagedImage class.
(Overrides ObjectFinalize.) | |
FromByteArray |
Create unmanaged image from the specified byte array.
| |
FromManagedImage(Bitmap) |
Create unmanaged image from the specified managed image.
| |
FromManagedImage(BitmapData) |
Create unmanaged image from the specified managed image.
| |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetPixel(IntPoint) |
Get color of the pixel with the specified coordinates.
| |
GetPixel(Int32, Int32) |
Get color of the pixel with the specified coordinates.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
SetPixel(IntPoint, Color) |
Set pixel with the specified coordinates to the specified color.
| |
SetPixel(Int32, Int32, Byte) |
Set pixel with the specified coordinates to the specified value.
| |
SetPixel(Int32, Int32, Color) |
Set pixel with the specified coordinates to the specified color.
| |
SetPixels |
Set pixels with the specified coordinates to the specified color.
| |
ToByteArray |
Converts the image into a sequence of bytes.
| |
ToManagedImage |
Create managed image from the unmanaged.
| |
ToManagedImage(Boolean) |
Create managed image from the unmanaged.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
GetPixelFormatSize |
Gets the color depth used in an image, in number of bits per pixel.
(Defined by Image.) | |
GetPixelFormatSizeInBytes |
Gets the color depth used in an image, in number of bytes per pixel.
(Defined by Image.) | |
HasMethod |
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) | |
IsEqual |
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.) | |
Max | Overloaded.
Computes the maximum pixel value in the given image.
(Defined by Tools.) | |
Max(Rectangle) | Overloaded.
Computes the maximum pixel value in the given image.
(Defined by Tools.) | |
Max(Int32) | Overloaded.
Computes the maximum pixel value in the given image.
(Defined by Tools.) | |
Mean | Overloaded.
Computes the arithmetic mean of the pixels in a given image.
(Defined by Tools.) | |
Mean(Rectangle) | Overloaded.
Computes the arithmetic mean of the pixels in a given image.
(Defined by Tools.) | |
Min | Overloaded.
Computes the minimum pixel value in the given image.
(Defined by Tools.) | |
Min(Int32) | Overloaded.
Computes the maximum pixel value in the given image.
(Defined by Tools.) | |
Min(Rectangle) | Overloaded.
Computes the minimum pixel value in the given image.
(Defined by Tools.) | |
StandardDeviation(Double) | Overloaded.
Computes the standard deviation of image pixels.
(Defined by Tools.) | |
StandardDeviation(Rectangle, Double) | Overloaded.
Computes the standard deviation of image pixels.
(Defined by Tools.) | |
Sum | Overloaded.
Computes the sum of the pixels in a given image.
(Defined by Tools.) | |
Sum(Rectangle) | Overloaded.
Computes the sum of the pixels in a given image.
(Defined by Tools.) | |
To(Type) | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) | |
ToT | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) |
The class represents wrapper of an image in unmanaged memory. Using this class it is possible as to allocate new image in unmanaged memory, as to just wrap provided pointer to unmanaged memory, where an image is stored.
Usage of unmanaged images is mostly beneficial when it is required to apply multiple image processing routines to a single image. In such scenario usage of .NET managed images usually leads to worse performance, because each routine needs to lock managed image before image processing is done and then unlock it after image processing is done. Without these lock/unlock there is no way to get direct access to managed image's data, which means there is no way to do fast image processing. So, usage of managed images lead to overhead, which is caused by locks/unlock. Unmanaged images are represented internally using unmanaged memory buffer. This means that it is not required to do any locks/unlocks in order to get access to image data (no overhead).
Sample usage:
// sample 1 - wrapping .NET image into unmanaged without // making extra copy of image in memory BitmapData imageData = image.LockBits( new Rectangle( 0, 0, image.Width, image.Height ), ImageLockMode.ReadWrite, image.PixelFormat ); try { UnmanagedImage unmanagedImage = new UnmanagedImage( imageData ) ); // apply several routines to the unmanaged image } finally { image.UnlockBits( imageData ); } // sample 2 - converting .NET image into unmanaged UnmanagedImage unmanagedImage = UnmanagedImage.FromManagedImage( image ); // apply several routines to the unmanaged image ... // conver to managed image if it is required to display it at some point of time Bitmap managedImage = unmanagedImage.ToManagedImage( );