GraphicsObject displaying an image. Optimized for rapid update (ie video display). This item displays either a 2D numpy array (height, width) or a 3D array (height, width, RGBa). This array is optionally scaled (see
setLevels) and/or colored with a lookup table (see
setLookupTable) before being displayed.
Return the transform that maps from this image’s input array to its local coordinate system.
This transform corrects for the transposition that occurs when image data is interpreted in row-major order.
getHistogram(bins='auto', step='auto', perChannel=False, targetImageSize=200, targetHistogramSize=500, **kwds)¶
Returns x and y arrays containing the histogram values for the current image. For an explanation of the return format, see numpy.histogram().
The step argument causes pixels to be skipped when computing the histogram to save time. If step is ‘auto’, then a step is chosen such that the analyzed data has dimensions roughly targetImageSize for each axis.
The bins argument and any extra keyword arguments are passed to np.histogram(). If bins is ‘auto’, then a bin number is automatically chosen based on the image characteristics:
- Integer images will have approximately targetHistogramSize bins, with each bin having an integer width.
- All other types will have targetHistogramSize bins.
If perChannel is True, then the histogram is computed once per channel and the output is a list of the results.
This method is also used when automatically computing levels.
Return the transform that maps from this image’s local coordinate system to its input array.
See dataTransform() for more information.
return scene-size of a single pixel in the image
Estimate the min/max values of the image data by subsampling.
Save this image to file. Note that this saves the visible image (after scale/color changes), not the original data.
Set the automatic downsampling mode for this ImageItem.
Added in version 0.9.9
Change the composition mode of the item (see QPainter::CompositionMode in the Qt documentation). This is useful when overlaying multiple ImageItems.
Most common arguments: QtGui.QPainter.CompositionMode_SourceOver Default; image replaces the background if it is opaque. Otherwise, it uses the alpha channel to blend the image with the background. QtGui.QPainter.CompositionMode_Overlay The image color is mixed with the background color to reflect the lightness or darkness of the background. QtGui.QPainter.CompositionMode_Plus Both the alpha and color of the image and background pixels are added together. QtGui.QPainter.CompositionMode_Multiply The output is the image color multiplied by the background.
setImage(image=None, autoLevels=None, **kargs)¶
Update the image displayed by this item. For more information on how the image is processed before displaying, see
Arguments: image (numpy array) Specifies the image data. May be 2D (width, height) or 3D (width, height, RGBa). The array dtype must be integer or floating point of any bit depth. For 3D arrays, the third dimension must be of length 3 (RGB) or 4 (RGBA). See notes below. autoLevels (bool) If True, this forces the image to automatically select levels based on the maximum and minimum values in the data. By default, this argument is true unless the levels argument is given. lut (numpy array) The color lookup table to use when displaying the image. See
levels (min, max) The minimum and maximum values to use when rescaling the image data. By default, this will be set to the minimum and maximum values in the image. If the image array has dtype uint8, no rescaling is necessary. opacity (float 0.0-1.0) compositionMode See
border Sets the pen used when drawing the image border. Default is None. autoDownsample (bool) If True, the image is automatically downsampled to match the screen resolution. This improves performance for large images and reduces aliasing. If autoDownsample is not specified, then ImageItem will choose whether to downsample the image based on its size.
For backward compatibility, image data is assumed to be in column-major order (column, row). However, most image data is stored in row-major order (row, column) and will need to be transposed before calling setImage():
This requirement can be changed by calling
image.setOpts(axisOrder='row-major')or by changing the
imageAxisOrderglobal configuration option.
Set image scaling levels. Can be one of:
- [blackLevel, whiteLevel]
- [[minRed, maxRed], [minGreen, maxGreen], [minBlue, maxBlue]]
Only the first format is compatible with lookup tables. See
makeARGBfor more details on how levels are applied.
Set the lookup table (numpy array) to use for this image. (see
makeARGBfor more information on how this is used). Optionally, lut can be a callable that accepts the current image as an argument and returns the lookup table to use.
Set whether the item ignores transformations and draws directly to screen pixels. If True, the item will not inherit any scale or rotation transformations from its parent items, but its position will be transformed as usual. (see GraphicsItem::ItemIgnoresTransformations in the Qt documentation)
Scale and translate the image to fit within rect (must be a QRect or QRectF).