Click or drag to resize
Accord.NET (logo)

ArrayToImage Class

Jagged array to Bitmap converter.
Inheritance Hierarchy
SystemObject
  Accord.Imaging.ConvertersArrayToImage

Namespace:  Accord.Imaging.Converters
Assembly:  Accord.Imaging (in Accord.Imaging.dll) Version: 3.8.0
Syntax
public class ArrayToImage : IConverter<double[], Bitmap>, 
	IConverter<double[], UnmanagedImage>, IConverter<double[][], Bitmap>, 
	IConverter<double[][], UnmanagedImage>, IConverter<float[], Bitmap>, 
	IConverter<float[], UnmanagedImage>, IConverter<float[][], Bitmap>, 
	IConverter<float[][], UnmanagedImage>, IConverter<byte[], Bitmap>, 
	IConverter<byte[], UnmanagedImage>, IConverter<byte[][], Bitmap>, 
	IConverter<byte[][], UnmanagedImage>, IConverter<Color[], Bitmap>, 
	IConverter<Color[], UnmanagedImage>
Request Example View Source

The ArrayToImage type exposes the following members.

Constructors
  NameDescription
Public methodArrayToImage(Int32, Int32)
Initializes a new instance of the ArrayToImage class.
Public methodArrayToImage(Int32, Int32, Double, Double)
Initializes a new instance of the ArrayToImage class.
Top
Properties
  NameDescription
Public propertyHeight
Gets or sets the height of the image stored in the double array.
Public propertyMax
Gets or sets the maximum double value in the double array associated with the brightest color.
Public propertyMin
Gets or sets the minimum double value in the double array associated with the darkest color.
Public propertyWidth
Gets or sets the width of the image stored in the double array.
Top
Methods
  NameDescription
Public methodConvert(Byte, UnmanagedImage)
Converts an image from one representation to another. For byte transformations, the Min and Max properties are ignored.
Public methodConvert(Byte, Bitmap)
Converts an image from one representation to another. For byte transformations, the Min and Max properties are ignored.
Public methodConvert(Byte, UnmanagedImage)
Converts an image from one representation to another. For byte transformations, the Min and Max properties are ignored.
Public methodConvert(Byte, Bitmap)
Converts an image from one representation to another. For byte transformations, the Min and Max properties are ignored.
Public methodConvert(Double, UnmanagedImage)
Converts an image from one representation to another.
Public methodConvert(Double, Bitmap)
Converts an image from one representation to another.
Public methodConvert(Double, UnmanagedImage)
Converts an image from one representation to another.
Public methodConvert(Double, Bitmap)
Converts an image from one representation to another.
Public methodConvert(Color, UnmanagedImage)
Converts an image from one representation to another.
Public methodConvert(Color, Bitmap)
Converts an image from one representation to another. For byte transformations, the Min and Max properties are ignored. The resulting image from upon calling this method will always be 32-bit ARGB.
Public methodConvert(Single, UnmanagedImage)
Converts an image from one representation to another.
Public methodConvert(Single, Bitmap)
Converts an image from one representation to another.
Public methodConvert(Single, UnmanagedImage)
Converts an image from one representation to another.
Public methodConvert(Single, Bitmap)
Converts an image from one representation to another.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(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.)
Public Extension MethodToTOverloaded.
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.)
Top
Remarks

This class can convert double and float arrays to either Grayscale or color Bitmap images. Color images should be represented as an array of pixel values for the final image. The actual dimensions of the image should be specified in the class constructor.

When this class is converting from byte or Color, the values of the Max and Min properties are ignored and no scaling operation is performed.

Examples

This example converts a single array of double-precision floating- point numbers with values from 0 to 1 into a grayscale image.

// Create an array representation 
// of a 4x4 image with a inner 2x2
// square drawn in the middle

double[] pixels = 
{
    0, 0, 0, 0, 
    0, 1, 1, 0, 
    0, 1, 1, 0, 
    0, 0, 0, 0, 
};

// Create the converter to create a Bitmap from the array
ArrayToImage conv = new ArrayToImage(width: 4, height: 4);

// Declare an image and store the pixels on it
Bitmap image; conv.Convert(pixels, out image);

// Show the image on screen
image = new ResizeNearestNeighbor(320, 320).Apply(image);
ImageBox.Show(image, PictureBoxSizeMode.Zoom);

The resulting image is shown below.

See Also