The Dectris Image class. More...
Public Member Functions | |
| def | DImage |
| Default constructor. More... | |
| def | DImage |
| Construct image of given size. More... | |
| def | DImage |
| Construct image of given size filled with a specific value. More... | |
| def | DImage |
| Construct DImage from existing DImage or numpy array. More... | |
| def | DImage |
| Construct image from an existing DImage but set all pixels to value. More... | |
| def | resize |
| Resize image. More... | |
| def | dataType |
| Data type string. More... | |
| def | width |
| Width of the image: Number of pixels in X. More... | |
| def | height |
| Height of the image: Number of pixels in Y. More... | |
| def | data |
| NumPy array keeping a copy of the image data. More... | |
| def | fromData |
| Sets the image data from a numpy array. More... | |
| def | pixel |
| Returns the pixel value at iX,iY. More... | |
| def | pixel |
| Returns the pixel value at iX,iY. More... | |
| def | setPixel |
| Sets the pixel value at (x,y) More... | |
| def | optionalData |
| optionalData() returns a reference to a DImageOptionalData object containing header information of the image. More... | |
| def | setOptionalData |
| set the DImageOptionalData object containing the header data More... | |
| def | mean |
| Calculate the mean pixel value of the image given a mask, a rectangle, a lower and an upper count limit. More... | |
| def | variance |
| Calculate the variance of the image given a mask, a rectangle, a lower and an upper count limit. More... | |
| def | rms |
| Calculate the rms pixel value of the image given a mask, a rectangle, a lower and an upper count limit. More... | |
| def | median |
| Calculate the median pixel value of the image providing a mask image. More... | |
| def | lowCut |
| Replace all pixels with counts less than cutValue with cutValue. More... | |
| def | lowCut |
| Replace all pixels with counts less than the pixel value of img with the pixel value of img. More... | |
| def | highCut |
| Replace all pixels with counts greater than cutValue with cutValue. More... | |
| def | highCut |
| Replace all pixels with counts greater than the pixel value of img with the pixel value of img. More... | |
| def | numberOfPixelsInInterval |
| Calculate the number of pixels with values below, above and inside the interval [lowerLimit,uppperLimit]. More... | |
| def | fill |
| Fill pixels of the image providing a mask image. More... | |
| def | extract |
| Extrakt a region of the image to a new image. More... | |
| def | createMask |
| Creates a mask from an image. More... | |
| def | splineFit |
| Fit a 2 dimensional spline to the image. More... | |
| def | medianFilter |
| Apply median filter to image providing a mask file. More... | |
| def | meanFilter |
| Apply mean filter to image providing a mask file. More... | |
| def | varianceFilter |
| Apply variance filter to image providing a mask file. More... | |
The Dectris Image class.
Slicing or indexing operator.
Class DImage provides functionality to manipulate detector images.
class DImage provides the following operations:
| -DImage | Unary minus operator of an image | ||
| DImage += img | The += operator for an image | ||
| DImage -= img | The -= operator for an image | ||
| DImage *= img | The *= operator for an image | ||
| DImage /= img | The /= operator for an image | ||
| DImage += value | The += operator for a value | ||
| DImage -= value | The -= operator for a value | ||
| DImage *= value | The *= operator for a value | ||
| DImage /= value | The /= operator for a value | ||
| DImage + img | The + operator for an image | ||
| DImage - img | The - operator for an image | ||
| DImage * img | The * operator for an image | ||
| DImage + value | The + operator for a value | ||
| DImage - value | The - operator for a value | ||
| DImage * value | The * operator for a value | ||
| DImage[ position ] |
DImage supports indexing and slicing. img[x,y] returns the pixel value at (x,y), img[x:x+width,y:y+height] returns the subimage at (x,y) of the given width and height. In addition a third slicing parameter denotes the step size of the subimage, e.g. img[x0:x1:xstep,y0:y1:xstep] returns a subimage where in the x direction (y direction) every xstep'th (ystep'th) pixel is taken into account. If optionalData() has a pixel mask the returned image has a pixel mask as well (see DImageOptionalData.pixel_mask()). The indexing operation can be used to set pixel values. E.g. sets pixels between [0,100) and [100:200) to value, where value may be either a numeric value or a DImage object. If value is a DImage its dimensions must coincide with the dimensions of the replaced region, else DRuntimeException is thrown. If slicing parameters are outside image border DOutOfRangeException is thrown.
|
| def dectris.albula.DImage.DImage | ( | dataType = "int32" | ) |
Default constructor.
Construct empty DImage of the type defined by dataType.
| dataType | String defining the data type: "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64", "float32", "float64" |
| def dectris.albula.DImage.DImage | ( | width, | |
| height, | |||
dataType = "int32" |
|||
| ) |
Construct image of given size.
| width | |
| height | |
| dataType | String defining the data type: "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64", "float32", "float64" |
| def dectris.albula.DImage.DImage | ( | width, | |
| height, | |||
| value | |||
| ) |
Construct image of given size filled with a specific value.
The type of value must be Integer or Float resulting in a "int32" or "float32" image.
| width | Width of the image |
| height | Height of the image |
| value | Integer or Float. This value defines the image datatype and will be assigned to all pixels |
| def dectris.albula.DImage.DImage | ( | image, | |
dataType = None |
|||
| ) |
Construct DImage from existing DImage or numpy array.
| image | DImage or 2-dimensional numpy array of type int, uint of float. |
| dataType | Either None or one of the following: "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64", "float32", "float64". If dataType is None the type of the new image is the same as image. |
| def dectris.albula.DImage.DImage | ( | image, | |
| value | |||
| ) |
Construct image from an existing DImage but set all pixels to value.
The shape of the constructed image is taken from image but the data type and the pixels values are taken from value. The type of value must be Integer or Float resulting in a "int32" or "float32" image.
| image | DImage whose shape defines the shape of constructed image |
| value | Integer or Float. This value defines the image datatype and will be assigned to all pixels |
| def dectris.albula.DImage.createMask | ( | lowerLimit, | |
| upperLimit, | |||
inverse = False |
|||
| ) |
Creates a mask from an image.
Pixels within [lowerLimit, upperLimit] will be unmasked (i.e set to 0). If inverse flag is true, pixels within [lowerLimit, upperLimit] will be masked (i.e. set to 1). Unmasked pixels get the value 0, masked pixels get the value 1.
| lowerLimit | Integer or Float |
| upperLimit | Integer or Float |
| inverse | Bool |
| def dectris.albula.DImage.data | ( | ) |
NumPy array keeping a copy of the image data.
The returned array is a two dimensional array in row major order. Hence the row (y-position) is accessed by the first index and the column (x-position) by the second index. Note: This is different to pixel() and setPixel().
Note: Starting from version 3.0 data() contains a copy to the image data rather than a reference. Hence it is no longer possible to change the image data by data(). Use fromData() instead.
| def dectris.albula.DImage.dataType | ( | ) |
Data type string.
| def dectris.albula.DImage.extract | ( | rect | ) |
Extrakt a region of the image to a new image.
| rect | DRect object. Subregion to take into account |
| def dectris.albula.DImage.fill | ( | value, | |
rect = None, |
|||
mask = None |
|||
| ) |
| def dectris.albula.DImage.fromData | ( | numpyArray | ) |
Sets the image data from a numpy array.
numpyArray will be casted to the data type of the image.
| numpyArray | 2-dimensional numpy array of type int, uint of float. |
| def dectris.albula.DImage.height | ( | ) |
Height of the image: Number of pixels in Y.
| def dectris.albula.DImage.highCut | ( | cutValue | ) |
Replace all pixels with counts greater than cutValue with cutValue.
| cutValue | Float or Integer |
| def dectris.albula.DImage.highCut | ( | img | ) |
Replace all pixels with counts greater than the pixel value of img with the pixel value of img.
| img | DImage |
| def dectris.albula.DImage.lowCut | ( | cutValue | ) |
Replace all pixels with counts less than cutValue with cutValue.
| cutValue | FLoat, Integer or DImage |
| def dectris.albula.DImage.lowCut | ( | img | ) |
Replace all pixels with counts less than the pixel value of img with the pixel value of img.
| img | DImage |
| def dectris.albula.DImage.mean | ( | rect = None, |
|
mask = None, |
|||
lowerCountLimit = - 1e30, |
|||
upperCountLimit = 1e30 |
|||
| ) |
Calculate the mean pixel value of the image given a mask, a rectangle, a lower and an upper count limit.
| def dectris.albula.DImage.meanFilter | ( | m, | |
| n, | |||
mask = None |
|||
| ) |
Apply mean filter to image providing a mask file.
Every pixel is set to the mean of a square of size m*n around the pixel. Eventually throws an DException.
| m | width of the filter region. Must to be odd. |
| n | height of the filter region. Must to be odd. |
| mask | DImage object. If not None, do not take into account pixels masked with values different from zero |
| def dectris.albula.DImage.median | ( | rect = None, |
|
mask = None |
|||
| ) |
| def dectris.albula.DImage.medianFilter | ( | m, | |
| n, | |||
mask = None |
|||
| ) |
Apply median filter to image providing a mask file.
Every pixel is set to the median of a square of size m*n around the pixel. Eventually throws an DException.
| m | width of the filter region. Must to be odd. |
| n | height of the filter region. Must to be odd. |
| mask | DImage object. If not None, do not take into account pixels masked with values different from zero |
| def dectris.albula.DImage.numberOfPixelsInInterval | ( | lowerLimit, | |
| upperLimit, | |||
rect = None, |
|||
mask = None |
|||
| ) |
Calculate the number of pixels with values below, above and inside the interval [lowerLimit,uppperLimit].
| lowerLimit | lower limit of the interval |
| upperLimit | upper limit ot the interval |
| rect | DRect object. If not None, subregion to take into account |
| mask | DImage object. If not None, do not take into account pixels masked with values different from zero |
| def dectris.albula.DImage.optionalData | ( | ) |
optionalData() returns a reference to a DImageOptionalData object containing header information of the image.
The returned reference must not live longer than the parent DImage object. Changes applied to the returned object apply to the images optional data as well, because it is a reference.
| def dectris.albula.DImage.pixel | ( | iX, | |
| iY | |||
| ) |
Returns the pixel value at iX,iY.
If iX,iY is outside the image borders 0 is returned.
| iX | x position |
| iY | y position |
| def dectris.albula.DImage.pixel | ( | iX, | |
| iY, | |||
| defaultReturn | |||
| ) |
Returns the pixel value at iX,iY.
If iX,iY is outside the image borders defaultReturn is returned.
| iX | x position |
| iY | y position |
| defaultReturn |
| def dectris.albula.DImage.resize | ( | width, | |
| height | |||
| ) |
Resize image.
All data is destroyed.
| width | New image width |
| height | New image height |
| def dectris.albula.DImage.rms | ( | rect = None, |
|
mask = None, |
|||
lowerCountLimit = - 1e30, |
|||
upperCountLimit = 1e30 |
|||
| ) |
Calculate the rms pixel value of the image given a mask, a rectangle, a lower and an upper count limit.
| def dectris.albula.DImage.setOptionalData | ( | optionalData | ) |
set the DImageOptionalData object containing the header data
| optionalData | DImageOptionalData object |
| def dectris.albula.DImage.setPixel | ( | x, | |
| y, | |||
| value | |||
| ) |
Sets the pixel value at (x,y)
| x | Integer value denoting the x position |
| y | Integer value denoting the y position |
| value | Integer or Float |
| def dectris.albula.DImage.splineFit | ( | nGridX, | |
| nOrderX, | |||
| nGridY, | |||
| nOrderY, | |||
| skipNModuleBorderPix, | |||
mask = None |
|||
| ) |
Fit a 2 dimensional spline to the image.
| nGridX | |
| nOrderX | |
| nGridY | |
| nOrderY | |
| skipNModuleBorderPix | |
| mask | DImage object. If not None, do not take into account pixels masked with values different from zero |
| def dectris.albula.DImage.variance | ( | rect = None, |
|
mask = None, |
|||
lowerCountLimit = - 1e30, |
|||
upperCountLimit = 1e30 |
|||
| ) |
Calculate the variance of the image given a mask, a rectangle, a lower and an upper count limit.
| rect | DRect object. If not None, subregion to take into account |
| mask | DImage object. If not None, do not take into account pixels masked with values different from zero |
| lowerCountLimit | |
| upperCountLimit |
| def dectris.albula.DImage.varianceFilter | ( | m, | |
| n, | |||
mask = None |
|||
| ) |
Apply variance filter to image providing a mask file.
Every pixel is set to the variance of a square of size m*n around the pixel. Eventually throws an DException.
| m | width of the filter region. Must to be odd. |
| n | height of the filter region. Must to be odd. |
| mask | DImage object. If not None, do not take into account pixels masked with values different from zero |
| def dectris.albula.DImage.width | ( | ) |
Width of the image: Number of pixels in X.