Packagede.popforge.imageprocessing.core
Classpublic final class Image
ImplementsIImage

The Image class is a data-holder to work with fast imageprocessing algorithms. It represents a m x n Matrix P with P = p(ij) where i in 0..m and j in 0..n. p can be defined like the following:

Image formatElements
ImageFormat.BINARYp(ij) in {0;1}
ImageFormat.GRAYSCALEp(ij) in {0;...;0xff}
ImageFormat.RGBp(ij) = (r(ij);g(ij);b(ij)) with r(ij), g(ij) and b(ij) in {0;...;0xff}
ImageFormat.RGBAAnalog to ImageFormat.RGB with alpha-channel a(ij) in {0;...;0xff}

This class should be appreciated as a data-holder and nothing else.

See also

Histogram


Public Properties
 PropertyDefined by
  bitmapData : BitmapData
[read-only] The merged version of the image.
Image
  channels : Array
The channels property is an Array that contains a BitmapData object for each channel of the image.
Image
  format : int
[read-only] The format of the image.
Image
  grayscale : IFilter
[static] The filter used to convert to grayscale images.
Image
  height : int
[read-only] The height of the image in pixels.
Image
  histogram : Histogram
The histogram of the image.
Image
  numChannels : int
[read-only] The number of channels the image uses.
Image
  rect : Rectangle
[read-only] The rectangle that defines the size of the image.
Image
  threshold : IFilter
[static] The filter used to convert to binary images.
Image
  width : int
[read-only] The width of the image in pixels.
Image
Public Methods
 MethodDefined by
  
Image(width:int, height:int, format:int)
Creates a new Image object.
Image
  
Returns a new Image object that is a clone of the original instance with an exact copy of the contained information.
Image
  
dispose():void
Frees memory that is used to store the Image object.
Image
  
fromBitmapData(bitmap:BitmapData, format:int, convertToGrayscale:Boolean = false):Image
[static] This function creates a new Image object from a given BitmapData object.
Image
  
getMeanValue(channel:int):Number
Calculates the mean value of a channel.
Image
  
getPixel(x:int, y:int):int
Returns 24-BIT pixel in 0xRRGGBB order.
Image
  
getPixel32(x:int, y:int):int
Same as getPixel() but returns a 32-BIT integer in 0xAARRGGBB order.
Image
  
loadBitmapData(bitmap:BitmapData, convertToGrayscale:Boolean = false):void
This function loads the information a BitmapData provides.
Image
  
render(target:BitmapData):void
Renders the image merged on a given BitmapData object.
Image
  
toJPEG(quality:int = 80):ByteArray
Builds and returns a JPEG file of the merged image.
Image
  
toPNG(alpha:Boolean = true):ByteArray
Builds and returns a PNG file of the Image object.
Image
  
toString():String
Builds and returns a string that lists the properties of the Image object.
Image
  
Updates the histogram of the Image.
Image
Property detail
bitmapDataproperty
bitmapData:BitmapData  [read-only]

The merged version of the image. Never forget to free the memory you used since this propertie always returns a new BitmapData object.

Implementation
    public function get bitmapData():BitmapData
channelsproperty 
public var channels:Array

The channels property is an Array that contains a BitmapData object for each channel of the image.

formatproperty 
format:int  [read-only]

The format of the image.

Implementation
    public function get format():int
grayscaleproperty 
public static var grayscale:IFilter

The filter used to convert to grayscale images.

The default value is GrayscaleBT709.

See also

heightproperty 
height:int  [read-only]

The height of the image in pixels.

Implementation
    public function get height():int
histogramproperty 
public var histogram:Histogram

The histogram of the image.

See also

numChannelsproperty 
numChannels:int  [read-only]

The number of channels the image uses.

Implementation
    public function get numChannels():int
rectproperty 
rect:Rectangle  [read-only]

The rectangle that defines the size of the image.

Implementation
    public function get rect():Rectangle
thresholdproperty 
public static var threshold:IFilter

The filter used to convert to binary images.

The default value is Threshold.

See also

widthproperty 
width:int  [read-only]

The width of the image in pixels.

Implementation
    public function get width():int
Constructor detail
Image()constructor
public function Image(width:int, height:int, format:int)

Creates a new Image object. Calling the constructor will result in a black image. Most internal write-protected variables will be set here.

Parameters
width:int — Width of image in pixel
 
height:int — Height of image in pixel
 
format:int — May be any kind of de.popforge.imageprocessing.core.ImageFormat
Method detail
clone()method
public function clone():Image

Returns a new Image object that is a clone of the original instance with an exact copy of the contained information.

Returns
Image — A new Image object that is identical to the original.
dispose()method 
public function dispose():void

Frees memory that is used to store the Image object.

fromBitmapData()method 
public static function fromBitmapData(bitmap:BitmapData, format:int, convertToGrayscale:Boolean = false):Image

This function creates a new Image object from a given BitmapData object. The BitmapData is taken and a new image will be created with respect to the size of the BitmapData object. After that loadBitmapData gets called to copy all channels.

Parameters
bitmap:BitmapData — BitmapData object which will be used for the new Image object.
 
format:int — The image format which may be any kind of ImageFormat.
 
convertToGrayscale:Boolean (default = false) — If your BitmapData source is not already a grayscale image you can convert it by setting convertToGrayscale to true..

Returns
Image — A new Image object with information from given BitmapData.

See also


Example
Image.fromBitmapData( bitmap, ImageFormat.RGB, false );

getMeanValue()method 
public function getMeanValue(channel:int):Number

Calculates the mean value of a channel.

Parameters
channel:int — Any kind of ImageChannel.

Returns
Number — The mean value of given channel.

See also

getPixel()method 
public function getPixel(x:int, y:int):int

Returns 24-BIT pixel in 0xRRGGBB order. Optional x is 0 <= x < image.width and y with 0 <= y < image.height. Remember that a binary pixel will be converted from {0;1} to {0x000000;0xffffff}

Parameters
x:int — The x coordinate of the pixel in cartesian format.
 
y:int — The y coordinate of the pixel in cartesian format.

Returns
int — 24-BIT integer with the color information of given (x|y) coordinates
getPixel32()method 
public function getPixel32(x:int, y:int):int

Same as getPixel() but returns a 32-BIT integer in 0xAARRGGBB order. If the ImageFormat does not support an alpha channel the alpha value will be set to 0xff.

Parameters
x:int — The x coordinate of the pixel in cartesian format.
 
y:int — The y coordinate of the pixel in cartesian format.

Returns
int — 32-BIT integer with the color information of given (x|y) coordinates
loadBitmapData()method 
public function loadBitmapData(bitmap:BitmapData, convertToGrayscale:Boolean = false):void

This function loads the information a BitmapData provides. The BitmapData has to be in the same dimension as the Image.

Parameters
bitmap:BitmapData — BitmapData object that will be loaded.
 
convertToGrayscale:Boolean (default = false) — This indicates if BitmapData the BitmapData is already grayscale or not.
render()method 
public function render(target:BitmapData):void

Renders the image merged on a given BitmapData object. Since the Image class should not be used to visualize the information an image provides we use a BitmapData object to do the job. A binary image will be converted from the {0x00;0x01} palette to {0x00;0xff}.

Parameters
target:BitmapData — BitmapData object which is used to render the Image object.
toJPEG()method 
public function toJPEG(quality:int = 80):ByteArray

Builds and returns a JPEG file of the merged image.

Parameters
quality:int (default = 80)

Returns
ByteArray — A ByteArray containing the JPEG file.
toPNG()method 
public function toPNG(alpha:Boolean = true):ByteArray

Builds and returns a PNG file of the Image object.

Parameters
alpha:Boolean (default = true)

Returns
ByteArray — A ByteArray containing the PNG file.
toString()method 
public function toString():String

Builds and returns a string that lists the properties of the Image object.

Returns
String — A string listing the value of each of the following properties of the Image object: width, height, format
updateHistogram()method 
public function updateHistogram():void

Updates the histogram of the Image.