Class Image (version 0.20)

Description: An image to be stored as a layout annotation

Images can be put onto the layout canvas as annotations, along with rulers and markers. Images can be monochrome (represent scalar data) as well as color (represent color images). The display of images can be adjusted in various ways, i.e. color mapping (translation of scalar values to colors), geometrical transformations (including rotation by arbitrary angles) and similar. Images are always based on floating point data. The actual data range is not fixed and can be adjusted to the data set (i.e. 0..255 or -1..1). This gives a great flexibility when displaying data which is the result of some measurement or calculation for example. The basic parameters of an image are the width and height of the data set, the width and height of one pixel, the geometrical transformation to be applied, the data range (min_value to max_value) and the data mapping which is described by an own class, ImageDataMapping.

Class overview

Index

Method Overview

[static] Image newCreate a new image with the default attributes
[static] Image new( string filename )Constructor from a image file
[static] Image new( string filename, DCplxTrans trans )Constructor from a image file
[static] Image new( unsigned int w, unsigned int h, double data[ ] )Constructor for a monochrome image with the given pixel values
[static] Image new( unsigned int w, unsigned int h, DCplxTrans trans, double data[ ] )Constructor for a monochrome image with the given pixel values
[static] Image new( unsigned int w, unsigned int h, double red[ ], double green[ ], double blue[ ] )Constructor for a color image with the given pixel values
[static] Image new( unsigned int w, unsigned int h, DCplxTrans trans, double red[ ], double green[ ], double blue[ ] )Constructor for a color image with the given pixel values
[const] DBox boxGet the bounding box of the image
[const] Image transformed( DTrans t )Transform the ruler or marker with the given simple transformation
[const] Image transformed( DTrans t )Transform the image with the given simple transformation
[const] Image transformed_cplx( DCplxTrans t )Transform the image with the given complex transformation
[const] unsigned int widthGet the width of the image in pixels
[const] unsigned int heightGet the height of the image in pixels
[const] string filenameGet the name of the file loaded of an empty string if not file is loaded
[const] bool is_empty?Returns true, if the image does not contain any data (i.e. is default constructed)
[const] bool is_color?Returns true, if the image is a color image
set_pixel( unsigned int x, unsigned int y, double v )Set one pixel (monochrome)
set_pixel( unsigned int x, unsigned int y, double r, double g, double b )Set one pixel (color)
[const] double get_pixel( unsigned int x, unsigned int y )Accessor to one pixel (monochrome and color)
[const] double get_pixel( unsigned int, unsigned int, unsigned int )Accessor to one pixel (monochrome and color)
set_data( unsigned int w, unsigned int h, double d[ ] )Write the image data field (monochrome)
set_data( unsigned int w, unsigned int h, double r[ ], double g[ ], double b[ ] )Write the image data field (color)
pixel_width=( double w )Set the pixel width
[const] double pixel_widthGet the pixel width
pixel_height=( double h )Set the pixel height
[const] double pixel_heightGet the pixel height
trans=( DCplxTrans t )Set the transformation
[const] const ref DCplxTrans transReturn the pixel-to-micron transformation
min_value=( double v )Set the minimum value
[const] double min_valueGet the upper limit of the values in the data set
max_value=( double v )Get the upper limit of the values in the data set
[const] double max_valueSet the maximum value
visible=( bool v )Set the visibility
[const] bool is_visible?Gets a flag indicating whether the image object is visible
[const] int idGet the Id
data_mapping=( ImageDataMapping data_mapping )Set the data mapping object
[const] const ref ImageDataMapping data_mappingGet the data mapping
[const] string to_sConver the image to a string
assign( Image other )Assign the contents of another object to self
[const] Image dupCreates a copy of self.
destroyExplicitly destroy the object
[const] bool destroyedTell, if the object was destroyed

assign( Image other )

Description: Assign the contents of another object to self

This method assigns the contents of another object to self. This is a deep copy that does not only copy the reference but the actual content.

[const] DBox box

Description: Get the bounding box of the image

returns:The bounding box

[const] const ref ImageDataMapping data_mapping

Description: Get the data mapping

The data mapping describes the transformation of a pixel value (any double value) into pixel data which can be sent to the graphics cards for display. See ImageDataMapping for a more detailed description.

returns:The data mapping object

data_mapping=( ImageDataMapping data_mapping )

Description: Set the data mapping object

The data mapping describes the transformation of a pixel value (any double value) into pixel data which can be sent to the graphics cards for display. See ImageDataMapping for a more detailed description.

destroy

Description: Explicitly destroy the object

Explicitly destroy the object on C++ side if it was owned by the Ruby interpreter. Subsequent access to this object will throw an exception. If the object is not owned by Ruby, this method will do nothing.

[const] bool destroyed

Description: Tell, if the object was destroyed

This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself.

[const] Image dup

Description: Creates a copy of self.

[const] string filename

Description: Get the name of the file loaded of an empty string if not file is loaded

returns:The file name (path)

[const] double get_pixel( unsigned int x, unsigned int y )

Description: Accessor to one pixel (monochrome and color)

If the component index, x or y value exceeds the image bounds, this method returns 0.0. For monochrome images, the component index is ignored.

x:The x coordinate of the pixel (0..width()-1)
y:The y coordinate of the pixel (mathematical order: 0 is the lowest, 0..height()-1)
component:0 for red, 1 for green, 2 for blue.

[const] double get_pixel( unsigned int, unsigned int, unsigned int )

Description: Accessor to one pixel (monochrome and color)

If the component index, x or y value exceeds the image bounds, this method returns 0.0. For monochrome images, the component index is ignored.

x:The x coordinate of the pixel (0..width()-1)
y:The y coordinate of the pixel (mathematical order: 0 is the lowest, 0..height()-1)
component:0 for red, 1 for green, 2 for blue.

[const] unsigned int height

Description: Get the height of the image in pixels

returns:The height in pixels

[const] int id

Description: Get the Id

The Id is an arbitrary integer that can be used to track the evolution of an image object. The Id is not changed when the object is edited. On initialization, a unique Id is given to the object. The Id cannot be changed. This behaviour has been modified in version 0.20.

[const] bool is_color?

Description: Returns true, if the image is a color image

returns:True, if the image is a color image

[const] bool is_empty?

Description: Returns true, if the image does not contain any data (i.e. is default constructed)

returns:True, if the image is empty

[const] bool is_visible?

Description: Gets a flag indicating whether the image object is visible

An image object can be made invisible by setting the visible property to false.

This method has been introduced in version 0.20.

[const] double max_value

Description: Set the maximum value

See the max_value method for the description of the maximum value property.

max_value=( double v )

Description: Get the upper limit of the values in the data set

This value determines the upper end of the data mapping (i.e. white value etc.). It does not necessarily correspond to the maximum value of the data set but it must be larger than that.

[const] double min_value

Description: Get the upper limit of the values in the data set

This value determines the upper end of the data mapping (i.e. white value etc.). It does not necessarily correspond to the minimum value of the data set but it must be larger than that.

min_value=( double v )

Description: Set the minimum value

See min_value for the description of the minimum value property.

[static] Image new( string filename, DCplxTrans trans )

Description: Constructor from a image file

This constructor creates an image object from a file (which can have any format supported by Qt) and a transformation. The image will originally be put to position 0, 0 (lower left corner) and each pixel will have a size of 1. The transformation describes how to transform this image into micron space.

filename:The path to the image file to load.
trans:The transformation to apply to the image when displaying it.

[static] Image new( string filename )

Description: Constructor from a image file

This constructor creates an image object from a file (which can have any format supported by Qt) and a unit transformation. The image will originally be put to position 0, 0 (lower left corner) and each pixel will have a size of 1 (micron).

filename:The path to the image file to load.

[static] Image new( unsigned int w, unsigned int h, double data[ ] )

Description: Constructor for a monochrome image with the given pixel values

This constructor creates an image from the given pixel values. The values have to be organized line by line. Each line must consist of "w" values where the first value is the leftmost pixel. Note, that the rows are oriented in the mathematical sense (first one is the lowest) contrary to the common convention for image data. Initially the pixel width and heigt will be 1 micron and the data range will be 0 to 1.0 (black to white level). To adjust the data range use the min_value and max_value properties.

w:The width of the image
h:The height of the image
d:The data set which will become owned by the image

[static] Image new( unsigned int w, unsigned int h, DCplxTrans trans, double data[ ] )

Description: Constructor for a monochrome image with the given pixel values

This constructor creates an image from the given pixel values. The values have to be organized line by line. Each line must consist of "w" values where the first value is the leftmost pixel. Note, that the rows are oriented in the mathematical sense (first one is the lowest) contrary to the common convention for image data. Initially the pixel width and heigt will be 1 micron and the data range will be 0 to 1.0 (black to white level). To adjust the data range use the min_value and max_value properties.

w:The width of the image
h:The height of the image
trans:The transformation from pixel space to micron space
d:The data set which will become owned by the image

[static] Image new( unsigned int w, unsigned int h, double red[ ], double green[ ], double blue[ ] )

Description: Constructor for a color image with the given pixel values

This constructor creates an image from the given pixel values. The values have to be organized line by line and separated by color channel. Each line must consist of "w" values where the first value is the leftmost pixel. Note, that the rows are oriented in the mathematical sense (first one is the lowest) contrary to the common convention for image data. Initially the pixel width and heigt will be 1 micron and the data range will be 0 to 1.0 (black to white level). To adjust the data range use the min_value and max_value properties.

w:The width of the image
h:The height of the image
red:The red channel data set which will become owned by the image
green:The green channel data set which will become owned by the image
blue:The blue channel data set which will become owned by the image

[static] Image new( unsigned int w, unsigned int h, DCplxTrans trans, double red[ ], double green[ ], double blue[ ] )

Description: Constructor for a color image with the given pixel values

This constructor creates an image from the given pixel values. The values have to be organized line by line and separated by color channel. Each line must consist of "w" values where the first value is the leftmost pixel. Note, that the rows are oriented in the mathematical sense (first one is the lowest) contrary to the common convention for image data. Initially the pixel width and heigt will be 1 micron and the data range will be 0 to 1.0 (black to white level). To adjust the data range use the min_value and max_value properties.

w:The width of the image
h:The height of the image
trans:The transformation from pixel space to micron space
red:The red channel data set which will become owned by the image
green:The green channel data set which will become owned by the image
blue:The blue channel data set which will become owned by the image

[static] Image new

Description: Create a new image with the default attributes

This will create an empty image without data and no particular pixel width or related. Use the read_file or set_data methods to set image properties and pixel values.

[const] double pixel_height

Description: Get the pixel height

See pixel_height= for a description of that property.

pixel_height=( double h )

Description: Set the pixel height

The pixel height determines the height of on pixel in the original space which is transformed to micron space with the transformation.

[const] double pixel_width

Description: Get the pixel width

See pixel_width= for a description of that property.

pixel_width=( double w )

Description: Set the pixel width

The pixel width determines the width of on pixel in the original space which is transformed to micron space with the transformation.

set_data( unsigned int w, unsigned int h, double r[ ], double g[ ], double b[ ] )

Description: Write the image data field (color)

See the constructor description for the data organisation in that field.

w:The width of the new data
h:The height of the new data
r:The red channel data to load into the image
g:The green channel data to load into the image
b:The blue channel data to load into the image

set_data( unsigned int w, unsigned int h, double d[ ] )

Description: Write the image data field (monochrome)

See the constructor description for the data organisation in that field.

w:The width of the new data
h:The height of the new data
d:The (monochrome) data to load into the image

set_pixel( unsigned int x, unsigned int y, double v )

Description: Set one pixel (monochrome)

If the component index, x or y value exceeds the image bounds of the image is a color image, this method does nothing.

x:The x coordinate of the pixel (0..width()-1)
y:The y coordinate of the pixel (mathematical order: 0 is the lowest, 0..height()-1)
v:The value

set_pixel( unsigned int x, unsigned int y, double r, double g, double b )

Description: Set one pixel (color)

If the component index, x or y value exceeds the image bounds of the image is not a color image, this method does nothing.

x:The x coordinate of the pixel (0..width()-1)
y:The y coordinate of the pixel (mathematical order: 0 is the lowest, 0..height()-1)
red:The red component
green:The green component
blue:The blue component

[const] string to_s

Description: Conver the image to a string

returns:The string

[const] const ref DCplxTrans trans

Description: Return the pixel-to-micron transformation

This transformation converts pixel coordinates (0,0 being the lower left corner and each pixel having the dimension of pixel_width and pixel_height) to micron coordinates. The coordinate of the pixel is the lower left corner of the pixel.

trans=( DCplxTrans t )

Description: Set the transformation

This transformation converts pixel coordinates (0,0 being the lower left corner and each pixel having the dimension of pixel_width and pixel_height) to micron coordinates. The coordinate of the pixel is the lower left corner of the pixel.

[const] Image transformed( DTrans t )

Description: Transform the ruler or marker with the given simple transformation

t:The transformation to apply
returns:The transformed object

[const] Image transformed( DTrans t )

Description: Transform the image with the given simple transformation

t:The transformation to apply
returns:The transformed object

[const] Image transformed_cplx( DCplxTrans t )

Description: Transform the image with the given complex transformation

t:The magnifying transformation to apply
returns:The transformed object

visible=( bool v )

Description: Set the visibility

See the is_visible? method for a description of this property.

This method has been introduced in version 0.20.

[const] unsigned int width

Description: Get the width of the image in pixels

returns:The width in pixels