This document is for OpenStructure version 1.7.1, the latest version is 2.7 !

Point, Size, Extent

This document describes some of the classes used in the :mod`~ost.img` module to describe image properties such as size, pixel coordinates and extents.

Point

class Point(x=0, y=0, z=0)
class Point(vec)
class Point(size)
class Point(point)
Parameters:
  • x (int) – integral x coordinate
  • y (int) – integral y coordinate
  • z (int) – integral z coordinate
  • vec (Vec3, Vec4) – The vectors coordinates will be rounded to the next integral value. In case of a Vec4, the coordinates will be divided by the homogenous coordinate.
  • point (Initialize from point) –

This class represents an image pixel. It is defined using three integer numbers, corresponding to the pixel’s indexes along the width, height and depth dimensions respectively.

__getitem__(index)

Read-write access to the coordinates.

..code-block:: python

p=img.Point(1,2,3) print p p[1]=5
ToVec3()

Converts the point to a Vec3

ToVec2()

Converts the point to a Vec2. The z coordinate of the point is ommitted.

ToVec4()

Converts the point to a Vec4, with the homogenous coordinate set to 1.

Size

class Size(width, height, depth)
class Size(width, height)

This property describes the size of an image. It is defined using three integer numbers: When depth is not specified, the size is assumed to refer to a 2D image two-dimensional (depth=1).

The Size class can be passed to the CreateImage() function to define the size of the image being created.

# uses the size class to create an image
s=img.Size(40,20,30)
i=img.CreateImage(s)
# uses a temporary instance of the Size class
i=img.CreateImage(img.Size(40,20,30))

Extent

class Extent(first_point, last_point)
class Extent(first_point, size)
class Extent(size, center_point)

This class describes the extent of an image in pixels. The image extent is a rectangle in 2d and a cuboid in 3d, and can be defined in a number of ways: giving the first and the last point of the extent, specifying the first point and the size of the extent, or listing the size of the extent and its central point.

Some examples:

# defines a rectangular extent that goes from pixel (2,4) to pixel (5,10)
s=img.Extent(img.Point(2,4),img.Point(5,10))
# defines the same extent using its first point and its size
s=img.Extent(img.Point(2,4),img.Size(4,7))
# again the same extent using its size and central pixel
s=img.Extent(img.Size(4,7),img.Point(3,7))

The Extent class can be passed to the CreateImage() function to create an image with a specific extent.

# uses the Extent class to create an image
e=img.Extent(img.Point(2,4),img.Size(4,7))
i=img.CreateImage(e)
# uses a temporary instance of the Extent class
i=img.CreateImage(img.Extent(img.Point(2,4),img.Size(4,7)))

Given an Extent, is it possible to recover its full size, and also the length of each of its dimensions separately.

Examples:

# gets the size of an extent (e is a 3D extent)
s=e.GetSize()
# gets the three dimensions separately
w=e.GetWidth()
h=e.GetHeight()
d=e.GetDepth()

When one needs to visit all the image pixels belonging to an Extent in sequence, one can use an ExtentIterator:

# defines an iterator over an extent e
ei=ExtentIterator(e)
# visits all the pixels in the extent and
# prints out their values
for pixel in ei:
  print i.GetReal(pixel)

Search

Enter search terms or a module, class or function name.

Contents

Documentation is available for the following OpenStructure versions:

dev / 2.7 / 2.6 / 2.5 / 2.4 / 2.3.1 / 2.3 / 2.2 / 2.1 / 2.0 / 1.9 / 1.8 / (Currently viewing 1.7.1) / 1.7 / 1.6 / 1.5 / 1.4 / 1.3 / 1.2 / 1.11 / 1.10 / 1.1

This documentation is still under heavy development!
If something is missing or if you need the C++ API description in doxygen style, check our old documentation for further information.