Io Reference







Graphics   /   Image   /   Image





The Image object can read and draw images and provide the image data as a buffer. Example use:
	
image = Image clone open("curly.png")
image draw
image scaleTo(image width / 2, image height / 2)
image save("curly.tiff")
When loading an attempt will be made to convert the image into whichever of the following formats it is closest to: L8, LA8, RGB8, RGBA8.

Currently supported formats include PNG(which supports alpha), JPG and TIFF.

 
 
 



addAlpha

Adds an opaque alpha component if the image is in RGB format and does not already contain one. Returns self.
averageColor

Returns the average RGB color of all pixels in the image.
baselineHeight

Returns the pixel height (relative to the bottom of the image) which first contains a non-white pixel or -1 if no baseline is found.
bitPlain(component, bit)

Replaces contents with black-and-white image where white appears if and only if specified component contained 1 on the specified bit plain. Returns self.
bounds(cutoff)

Returns an object continaing the bounds of the image. Cutoff is max bound color value for any color component. If it is negative, it is the min bound color value.
componentCount

Returns the number of color components in the receiver as a Number.
componentPlain(component)

Removes other components except specified from the image. Returns self.
crop(x, y, width, height)

Crops the image to the specified values. Returns self. Raises an exception on error.
data

Returns a Buffer primitive containing the image data (loading it first if needed). Manipulating this data will affect what is drawn when the receiver's draw method is called.
decodingHeightHint

Returns the decoding height hint.
decodingWidthHint

Returns the decoding width hint.
encodingQuality

Returns the encodingQuality setting.
equalizeHistogram(mode)

Performs histogram equalization. Mode denotes quality factor and processing speed. Mode should be in range [0..3]. Returns self.
error

Returns a String containing the current error or nil if there is no error.
filterGauss(sigma)

Returns new image as a result of applying filter. Implements Gauss smoothing filtering with parameter sigma.
filterKirsch(a)

Returns new image as a result of applying Kirsch filter. The argument denotes direction: 0, 1, 2, ... -> 0, pi / 4, pi / 2, ...
filterLinear(filterSizeX, filterSizeY, filter)

Returns new image as a result of applying filter.
filterMax(filterSizeX, filterSizeY)

Returns new image as a result of applying filter.
filterMedian(filterSizeX, filterSizeY)

Returns new image as a result of applying filter.
filterMin(filterSizeX, filterSizeY)

Returns new image as a result of applying filter.
filterNonlinearGradients

Returns new image as a result of applying filter. Calculates abs(f'x) + abs(f'y).
filterSobel(a)

Returns new image as a result of applying Sobel filter. The argument denotes direction: 0, 1, 2, ... -> 0, pi / 4, pi / 2, ...
filterUniformAverage(filterSizeX, filterSizeY)

Returns new image as a result of applying filter. Implements low pass filtering.
filterUnsharpMask(a)

Returns new image as a result of applying filter. Implements unsharp mask filtering. The result is sharpened image. The parameter value may by any but it makes sense if it is > 0.
filterWeightedMedian(filterSizeX, filterSizeY, filter)

Returns new image as a result of applying filter.
flipX

Flips the image on the horizonal plane (left/right mirror). Returns self.
flipY

Flips the image on the vertical plane (top/bottom mirror). Returns self.
height

Returns the image hieght.
histogram

Returns array with histogram values interleaved by channels.
isL8

Returns true if the receiver is in L8 (8bit Luminance) format, false otherwise.
isLA8

Returns true if the receiver is in LA8 (8bit Luminance-Alpha) format, false otherwise.
isRGB8

Returns true if the receiver is in RGB8 format, false otherwise.
isRGBA8

Returns true if the receiver is in RGBA8 format, false otherwise.
linearContrast

Performs contrast linarization. Per-pixel per-channel transformation that extends intensity to its full range. Returns self.
makeGrayscale

Converts color model to Luminance or Luminance-Alpha 8bit (grayscale). Returns self.
makeL8

Converts color model to Luminance 8bit (grayscale). Returns self.
makeRGBA8

Converts color model to RGBA 8bit. Returns self.
open(optionalPathString)

Sets the path to optionalPathString if provided and opens the image file. Returns self on success, Nil on failure.
path

Returns the image path.
removeAlpha

Removes the alpha component if the image contains one. Returns self.
resizedTo(newWidth, newHeight)

Scales the image up to newWidth x newHeight. Returns the newly scaled image.
resizedTo(width, height)

Returns a new image of the receiver resized to the given width and height. Raises an exception on error.
save(optionalPathString)

Sets the path to optionalPathString if provided and saves the image in the format specified by the path extension. Returns self on success, nil on failure.
setDataWidthHeightComponentCount(aSequence, width, height, componentCount)

Sets the image data and its parameters. Returns self.
setDecodingHeightHint(width)

Sets the decoding height hint. Returns self.
setDecodingWidthHint(width)

Sets the decoding width hint. Returns self.
setEncodingQuality(aNumber)

Sets the image encoding quality (range is 0.0 - 1.0, 1.0 with being the highest).
setPath(aString)

Sets the image path. Returns self.
thresholdByGradient

Performs thresholding. Threshold value is finded using Otsu's method. Returns self.
width

Returns the image width.