Class Image

Description

Allows advanced image processing.

Located in /gd2imaging.php (line 557)


	
			
Variable Summary
int $height
resource $image
mixed $position
int $width
Method Summary
Image __construct (string $fileName, [resource $image = null], [Point $position = null], [Dimensions $size = null])
string createImageMatrix ([int $size = 0],  &$ratio, int $ratio)
Image crop (Point $position, Dimensions $dimensions)
Image deskew ([int $backgroundColor = -1], [bool $turboMode = true], [bool $debugMode = false])
Image drawHoughLine (int $distance, int $theta, [ $color = 111111])
Image[] findObjects ([int $sortMode = 1])
mixed getBackgroundColor ([ $numberOfSamples = 1], [bool $turboMode = false], int $numberOfSampes)
string getBinaryBuffer (resource $image)
int getByteWidth ()
resource getGd2Handle ()
int getHeight ()
Image getHistogram ([int $channels = 0], [int $color = 0], [int $backgroundColor = 0xffffff], [bool $turboMode = true])
int getNextPowerOfTwo (int $number)
Color getPixelColor (int $x, int $y)
int getPixelRgb (int $x, int $y)
Color getPointColor (Point $position)
int getPointRgb (Point $position)
Position getPosition ()
int[] getSize ()
resource getSkewAngle ([int $numberOfSamples = 1], [int $matrixSize = 128], [bool $debugMode = false], [int $returnMode = 1])
Image getSubImage (Point $position, Dimensions $size)
Vector getVector ([Point $position = null], [Dimensions $size = null], [bool $round = false], [int $colorMask = 0])
int getWidth ()
bool isBinaryBufferEmpty ([double $threshold = 0.01])
Image rescale ( $x,  $y)
Image resize (mixed $widthOrDimensions, [int $height = null], [bool $useResampling = true])
Image resizeAndKeepAspect (mixed $widthOrDimensions, [int $height = null], [bool $useResampling = true])
Image rotate (int $angle, [int $backgroundColor = -1])
Image saveAsGif (string $fileName)
Image saveAsJpeg (string $fileName)
Image saveAsPng (string $fileName)
Image setGamma ( $level)
Image setPixelColor (int $x, int $y, Color $color)
Image setPixelRgb (int $x, int $y,  $rgb)
Image setPointColor ( $position, Color $color)
Image setPointRgb ( $position,  $rgb)
Image show ([bool $die = false])
Image toBinary ([bool $useEdgeDetection = false])
Image useMedian ([int $maskWidth = 3], [int $maskHeight = 3])
Variables
int $height (line 578)

A height of this image.

  • access: protected
resource $image (line 564)

A GD2 image resource.

  • access: protected
Image $parentImage (line 592)

Viewport's parent image [not implemented]

  • access: protected
mixed $position (line 585)

Viewport's position in the parent image.

  • access: protected
int $width (line 571)

A width of this image.

  • access: protected
Methods
Constructor __construct (line 601)

Creates new Image.

  • access: public
Image __construct (string $fileName, [resource $image = null], [Point $position = null], [Dimensions $size = null])
  • string $fileName: Image file name.
  • resource $image: Image data.
  • Point $position
  • Dimensions $size
createImageMatrix (line 1719)

Creates the image buffer used by the skew functions.

  • return: Binary frame buffer
  • access: protected
string createImageMatrix ([int $size = 0],  &$ratio, int $ratio)
  • int $size: Size of the matrix.
  • int $ratio: Rescale ratio of this image (value is returned by this method)
  • &$ratio
crop (line 1054)

Crops current image.

  • access: public
Image crop (Point $position, Dimensions $dimensions)
  • Point $position: Position of the upper left point of the area to crop.
  • Dimensions $dimensions: Size of the area to crop.
deskew (line 1189)

Deskews the image.

  • access: public
Image deskew ([int $backgroundColor = -1], [bool $turboMode = true], [bool $debugMode = false])
  • int $backgroundColor: Color of the background to use, or -1 (default) to use auto detection.
  • bool $turboMode: Set true to enable turbo mode (may be less accurate).
  • bool $debugMode: Set true to enable the debug mode.
drawHoughLine (line 1422)

Draws the Hough line.

  • access: protected
Image drawHoughLine (int $distance, int $theta, [ $color = 111111])
  • int $distance: Distance from the origin.
  • int $theta: Angle in degrees.
  • $color
findObjects (line 954)

Finds different shapes in the image.

  • access: public
Image[] findObjects ([int $sortMode = 1])
  • int $sortMode
getBackgroundColor (line 1646)

(Fast) Detects the background color of this image.

  • return: RGB representation of the color, array of samples: array(rgb => propability), or rgb value if one sample selected.
  • access: public
mixed getBackgroundColor ([ $numberOfSamples = 1], [bool $turboMode = false], int $numberOfSampes)
  • int $numberOfSampes: Number of detected colors (sorted by the propability).
  • bool $turboMode: Set true to use faster alghoritm (slightly less accurate).
  • $numberOfSamples
getBinaryBuffer (line 1452)

Returns binary frame buffer of the current image.

In case of color/grayscale images, use Image::toBinary() first.

  • return: String of chars.
  • access: protected
string getBinaryBuffer (resource $image)
  • resource $image: Image to binarize.
getByteWidth (line 1129)

Returns a number of bytes used to store a single row of the image binary buffer.

For example: 128 pixels = 16 bytes, 127 pixels = 16 bytes (127 bits of image + 1 bits of padding), 129 pixels = 17 bytes (129 bits of image + 7 bits of padding)

  • return: Number of bytes per image row.
  • access: protected
int getByteWidth ()
getCopy (line 833)

Returns copy of this image.

  • access: public
Image getCopy ()
getDimensions (line 1042)

Returns image dimensions.

  • access: public
Dimensions getDimensions ()
getGd2Handle (line 1500)

Returns GD2 resource handle of this image.

  • access: public
resource getGd2Handle ()
getHeight (line 646)

Gets image height.

  • access: public
int getHeight ()
getHistogram (line 1540)

Creates an image histogram.

  • todo: Add another
  • access: public
Image getHistogram ([int $channels = 0], [int $color = 0], [int $backgroundColor = 0xffffff], [bool $turboMode = true])
  • int $channels: Channels to draw, possibilities: Channel::RGB (default), Channel::RED, Channel::GREEN, Channel::BLUE
  • int $color: Foreground color.
  • int $backgroundColor: Background color.
  • bool $turboMode: Use turbo mode (less accurate).
getNextPowerOfTwo (line 623)

Returns next power of two representation of the given number.

  • return: Power of two representation.
  • access: protected
int getNextPowerOfTwo (int $number)
  • int $number: Number to convert.
getPixelColor (line 758)

Returns a color of the pixel at the X,Y coordinates.

  • return: Object describing the color of the pixel.
  • access: public
Color getPixelColor (int $x, int $y)
  • int $x: X-coordinate of the pixel to check.
  • int $y: Y-coordinate of the pixel to check.
getPixelRgb (line 747)

Returns a RGB value of the pixel at the X,Y coordinates.

  • return: RGB value of the pixel.
  • access: public
int getPixelRgb (int $x, int $y)
  • int $x: X-coordinate of the pixel to check.
  • int $y: Y-coordinate of the pixel to check.
getPointColor (line 778)

Returns a color of the pixel at the coordinates described in the Point object.

  • return: Object describing the color of the pixel.
  • access: public
Color getPointColor (Point $position)
  • Point $position: Position of the pixel to check.
getPointRgb (line 768)

Returns a RGB value of the pixel at the coordinates described in the Point object.

  • return: RGB value of the pixel.
  • access: public
int getPointRgb (Point $position)
  • Point $position: Position of the pixel to check.
getPosition (line 928)

Returns viewport's position.

  • access: public
Position getPosition ()
getSize (line 1207)

Calculates the size of this image.

  • return: An array containing a width and height of this image.
  • access: public
int[] getSize ()
getSkewAngle (line 1221)

Detects the skew angle of this image using the Hough normal transform.

  • access: public
resource getSkewAngle ([int $numberOfSamples = 1], [int $matrixSize = 128], [bool $debugMode = false], [int $returnMode = 1])
  • int $numberOfSamples: Number of different angles to detect (sorted by a number of votes).
  • int $matrixSize: Size of the pixel matrix used for detection, bigger matrix = slower, more accurate detection.
  • bool $debugMode: Draw detected Hough lines on this image? Works only in $returnMode = 1, default: false
  • int $returnMode: Return mode: 1 = array of detected angles (default), 2 = rendered transform results (Image instance), 3 = array of transform results
getSubImage (line 854)

Returns a sub image of this image.

  • access: public
Image getSubImage (Point $position, Dimensions $size)
getVector (line 867)

Creates a vector from a part of an image.

  • access: public
Vector getVector ([Point $position = null], [Dimensions $size = null], [bool $round = false], [int $colorMask = 0])
  • Point $position: X,Y-coordinates of the left upper-most point of the image.
  • Dimensions $size: Width and height of the image.
  • bool $round: Round the values?
  • int $colorMask: Color bitmask.
getWidth (line 637)

Gets image width.

  • access: public
int getWidth ()
isBinaryBufferEmpty (line 1485)

Detects if the binary buffer of this image is empty after conversion to two-colors mode.

Empty buffer may mean that the conversion failed.

  • return: True if empty, false otherwise.
  • access: public
bool isBinaryBufferEmpty ([double $threshold = 0.01])
  • double $threshold: The threshold.
rescale (line 726)

Scales this image.

  • access: public
Image rescale ( $x,  $y)
  • $x
  • $y
resize (line 668)

Resizes this image.

  • access: public
Image resize (mixed $widthOrDimensions, [int $height = null], [bool $useResampling = true])
  • mixed $widthOrDimensions: New width (or Dimensions) of the this image.
  • int $height: New height of this image (used only if $widthOrDimensions is not an instance of Dimensions class)
  • bool $useResampling: Use resampling? Default: true (slower)
resizeAndKeepAspect (line 695)

Resizes this image and keeps the image aspect.

  • access: public
Image resizeAndKeepAspect (mixed $widthOrDimensions, [int $height = null], [bool $useResampling = true])
  • mixed $widthOrDimensions: New width (or Dimensions) of the this image.
  • int $height: New height of this image (used only if $widthOrDimensions is not an instance of Dimensions class)
  • bool $useResampling: Use resampling? Default: true (slower)
rotate (line 939)

Rotates image by a given angle.

  • access: public
Image rotate (int $angle, [int $backgroundColor = -1])
  • int $angle: Angle in degrees (not radians).
  • int $backgroundColor: Backround color used to fill empty spaces after rotation (or -1 for autodetection).
saveAsGif (line 1165)

Saves this image to the disk.

  • access: public
Image saveAsGif (string $fileName)
  • string $fileName: File name.
saveAsJpeg (line 1176)

Saves this image to the disk.

  • access: public
Image saveAsJpeg (string $fileName)
  • string $fileName: File name.
saveAsPng (line 1154)

Saves this image to the disk.

  • access: public
Image saveAsPng (string $fileName)
  • string $fileName: File name.
setGamma (line 655)

Sets image gamma.

  • access: public
Image setGamma ( $level)
  • $level
setPixelColor (line 811)

Sets a color of the pixel at the X,Y coordinates.

  • access: public
Image setPixelColor (int $x, int $y, Color $color)
  • int $x: X-coordinate of the pixel to set.
  • int $y: Y-coordinate of the pixel to set.
  • Color $color
setPixelRgb (line 823)

Sets a RGB value of the pixel at the X,Y coordinates.

  • access: public
Image setPixelRgb (int $x, int $y,  $rgb)
  • int $x: X-coordinate of the pixel to set.
  • int $y: Y-coordinate of the pixel to set.
  • $rgb
setPointColor (line 788)

Sets a color of the pixel at the coordinates described in the Point object.

  • access: public
Image setPointColor ( $position, Color $color)
  • Point $position: Position of the pixel to set.
  • Color $color
setPointRgb (line 799)

Sets a RGB value of the pixel at the coordinates described in the Point object.

  • access: public
Image setPointRgb ( $position,  $rgb)
  • Point $position: Position of the pixel to set.
  • $rgb
show (line 1139)

Displays the image.

  • access: public
Image show ([bool $die = false])
  • bool $die: Die after displaying an image? Default: false
toBinary (line 1510)

Reduces color palette of this image to two colors (1 = pixel set, 0 = background).

  • access: public
Image toBinary ([bool $useEdgeDetection = false])
  • bool $useEdgeDetection: Use edge detection before converting to two colors?
toGrayScale (line 842)

Converts this image to grayscale.

  • access: public
Image toGrayScale ()
toNegative (line 1114)

Reverses all colors of the image.

  • access: public
Image toNegative ()
useMedian (line 1599)

Uses median filter to reduce image noise.

  • access: public
Image useMedian ([int $maskWidth = 3], [int $maskHeight = 3])
  • int $maskWidth: Width of the median mask (default: 3)
  • int $maskHeight: Height of the median mask (default: 3)

Documentation generated on Fri, 04 Nov 2011 17:56:15 +0100 by phpDocumentor 1.4.2