Submodule extending the vtkImageActor object functionality.


class vedo.picture.Picture(obj=None, channels=(), flip=False)[source]

Bases: vtkmodules.vtkRenderingCore.vtkImageActor, vedo.base.Base3DProp

Derived class of vtkImageActor. Used to represent 2D pictures. Can be instantiated with a path file name or with a numpy array.

Use Picture.shape to access the number of pixels in x and y.

rotateImage.py rotateImage.py

  • channels (list) – only select these specific rgba channels (useful to remove alpha)

  • flip (bool) – flip xy axis convention (when input is a numpy array)


Set/get picture’s transparency.

append(pictures, axis='z', preserveExtents=False)[source]

Append the input images to the current one along the specified axis. Except for the append axis, all inputs must have the same extent. All inputs must have the same number of scalar components. The output has the same origin and spacing as the first input. The origin and spacing of all other inputs are ignored. All inputs must have the same scalar type.

  • axis (int,str) – axis expanded to hold the multiple images.

  • preserveExtents (bool) – if True, the extent of the inputs is used to place the image in the output. The whole extent of the output is the union of the input whole extents. Any portion of the output not covered by the inputs is set to zero. The origin and spacing is taken from the first input.

from vedo import Picture, dataurl
pic = Picture(dataurl+'dog.jpg').pad()
pic.append([pic,pic,pic], axis='y')
pic.append([pic,pic,pic,pic], axis='x')
blend(pic, alpha1=0.5, alpha2=0.5)[source]

Take L, LA, RGB, or RGBA images as input and blends them according to the alpha values and/or the opacity setting for each input.


Make it black and white


Return an exact copy of the input Picture. If transform is True, it is given the same scaling and position.

crop(top=None, bottom=None, right=None, left=None, pixels=False)[source]

Crop picture.

  • top (float) – fraction to crop from the top margin

  • bottom (float) – fraction to crop from the bottom margin

  • left (float) – fraction to crop from the left margin

  • right (float) – fraction to crop from the right margin

  • pixels (bool) – units are pixels


Enhance a b&w picture using the laplacian, enhancing high-freq edges.


import vedo
p = vedo.Picture(vedo.dataurl+'images/dog.jpg').bw()
vedo.show(p, p.clone().enhance(), N=2, mode='image')

Get or set the physical extent that the picture spans. Format is ext=[minx, maxx, miny, maxy].

fft(mode='magnitude', logscale=12, center=True)[source]

Fast Fourier transform of a picture.

  • logscale (float) – if non-zero, take the logarithm of the intensity and scale it by this factor.

  • mode (str) – either [magnitude, real, imaginary, complex], compute the point array data accordingly.

  • center (bool) – shift constant zero-frequency to the center of the image for display. (FFT converts spatial images into frequency space, but puts the zero frequency at the origin)

frequencyPassFilter(lowcutoff=None, highcutoff=None, order=3)[source]

Low-pass and high-pass filtering become trivial in the frequency domain. A portion of the pixels/voxels are simply masked or attenuated. This function applies a high pass Butterworth filter that attenuates the frequency domain image with the function


The gradual attenuation of the filter is important. A simple high-pass filter would simply mask a set of pixels in the frequency domain, but the abrupt transition would cause a ringing effect in the spatial domain.

  • lowcutoff (list) – the cutoff frequencies

  • highcutoff (list) – the cutoff frequencies

  • order (int) – order determines sharpness of the cutoff curve


Return the underlying vtkImagaData object.


Get/Set the image color level (brightness).


Median filter that preserves thin lines and corners. It operates on a 5x5 pixel neighborhood. It computes two values initially: the median of the + neighbors and the median of the x neighbors. It then computes the median of these two values plus the center pixel. This result of this second median is the output pixel value.


Mirror picture along x or y axis.


Use in conjunction with tonumpy() to update any modifications to the picture array

pad(pixels=10, value=255)[source]

Add the specified number of pixels at the picture borders. Pixels can be a list formatted as [left,right,bottom,top].

  • pixels (int,list , optional) – number of pixels to be added (or a list of length 4). The default is 10.

  • value (int, optional) – intensity value (gray-scale color) of the padding. The default is 255.


Resize the image resolution by specifying the number of pixels in width and height. If left to zero, it will be automatically calculated to keep the original aspect ratio.


newsize (list,float) – shape of picture as [npx, npy], or as a fraction.


Reverse Fast Fourier transform of a picture.

rotate(angle, center=(), scale=1, mirroring=False, bc='w', alpha=1)[source]

Rotate an image by an angle (anticlockwise).

  • angle (float) – rotation angle in degrees.

  • center (list) – center of rotation (x,y) in pixels.


Select one single component of the rgb image

smooth(sigma=3, radius=None)[source]

Smooth a Picture with Gaussian kernel.

  • sigma (int, optional) – number of sigmas in pixel units. The default is 3.

  • radius (TYPE, optional) – how far out the gaussian kernel will go before being clamped to zero. The default is None.

text(txt, pos=(0, 0, 0), s=1, c=None, alpha=1, bg=None, font='Theemim', dpi=500, justify='bottom-left')[source]

Build an image from a string.

threshold(value=None, flip=False)[source]

Create a polygonal Mesh from a Picture by filling regions with pixels luminosity above a specified value.

  • value (float, optional) – The default is None, e.i. 1/3 of the scalar range.

  • flip (bool, optional) – Flip polygon orientations


A polygonal mesh.

Return type


tiling(nx=4, ny=4, shift=(0, 0))[source]

Generate a tiling from the current picture by mirroring and repeating it.

  • nx (float, optional) – number of repeats along x. The default is 4.

  • ny (float, optional) – number of repeats along x. The default is 4.

  • shift (list, optional) – shift in x and y in pixels. The default is 4.


Convert an image to polygonal data (quads), with each polygon vertex assigned a RGBA value.


Get read-write access to pixels of a Picture object as a numpy array. Note that the shape is (nrofchannels, nx, ny).

When you set values in the output image, you don’t want numpy to reallocate the array but instead set values in the existing array, so use the [:] operator. Example: arr[:] = arr - 15

If the array is modified call: picture.modified() when all your modifications are completed.

warp(sourcePts=(), targetPts=(), transform=None, sigma=1, mirroring=False, bc='w', alpha=1)[source]

Warp an image using thin-plate splines.

  • sourcePts (list, optional) – source points.

  • targetPts (list, optional) – target points.

  • transform (TYPE, optional) – a vtkTransform object can be supplied. The default is None.

  • sigma (float, optional) – stiffness of the interpolation. The default is 1.

  • mirroring (TYPE, optional) – fill the margins with a reflection of the original image. The default is False.

  • bc (TYPE, optional) – fill the margins with a solid color. The default is ‘w’.

  • alpha (TYPE, optional) – opacity of the filled margins. The default is 1.


Get/Set the image color window (contrast).


Write picture to file as png or jpg.