Submodule extending the
vtkImageActor object functionality.
- class vedo.picture.Picture(obj=None, channels=(), flip=False)
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.
Set/get picture’s transparency.
- append(pictures, axis='z', preserveExtents=False)
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.
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') pic.show(axes=1)
- blend(pic, alpha1=0.5, alpha2=0.5)
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)
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)
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)
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.
Return the underlying
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)
Add the specified number of pixels at the picture borders. Pixels can be a list formatted as [left,right,bottom,top].
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.
Reverse Fast Fourier transform of a picture.
- rotate(angle, center=(), scale=1, mirroring=False, bc='w', alpha=1)
Rotate an image by an angle (anticlockwise).
Select one single component of the rgb image
- smooth(sigma=3, radius=None)
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')
Build an image from a string.
- threshold(value=None, flip=False)
Create a polygonal Mesh from a Picture by filling regions with pixels luminosity above a specified value.
- tiling(nx=4, ny=4, shift=(0, 0))
Generate a tiling from the current picture by mirroring and repeating it.
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)
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.