Previous topic

Python modules

Next topic

color_utilities

This Page

image_utilities

This file contains some useful wrappers over Yayi basic image processing functions.

Yayi.image_utilities.AAbsSub(im1, im2)[source]

Returns the absolute difference of the two input images

\[\forall p \in \mathcal{D}(im_1) \cap \mathcal{D}(im_2), im_o(p) = \left|im_1(p) - im_2(p)\right|\]
Yayi.image_utilities.AInvert(im_i)[source]

Returns the bitwise complement of the input image

\[\forall p \in \mathcal{D}(im_i), im_o(p) = \sim im_i(p)\]
Yayi.image_utilities.AOr(im1, im2)[source]

Returns the bitwise union (or) of the two input images

\[\forall p \in \mathcal{D}(im_1) \cap \mathcal{D}(im_2), im_o(p) = im_1(p)\ |\ im_2(p)\]
Yayi.image_utilities.ASub(im1, im2)[source]

Returns the difference of the two images

\[\forall p \in \mathcal{D}(im_1) \cap \mathcal{D}(im_2), im_o(p) = im_1(p) - im_2(p)\]

Warning

The underflow is not checked with this function. Consider ASubClip() instead.

See also

ASubClip()

Yayi.image_utilities.ASubClip(im1, im2, clip=0)[source]

Returns the bounded difference of the two input images

\[\forall p \in \mathcal{D}(im_1) \cap \mathcal{D}(im_2), im_o(p) = (im_1(p) - im_2(p)) \vee clip\]
Yayi.image_utilities.copy(im)[source]

Quick copy of an image into a new one.

Parameters:im – input image
Return type:image
Returns:a exact copy of the input image (same type, dimensions and content).

Example:

imout = copy(imin)
Yayi.image_utilities.copy_to_double(im)[source]

Quick copy of an image into a new ‘double’ one

Yayi.image_utilities.copy_to_float(im)[source]

Quick copy of an image into a new ‘float’ one

Yayi.image_utilities.copy_to_pixel3(im)[source]

Quick copy of a scalar image into a new 3 channels’ one. The scalar is duplicated on each channel.

Yayi.image_utilities.copy_to_uint16(im)[source]

Quick copy of an image into a new unsigned 16 bits one

Yayi.image_utilities.copy_to_uint32(im)[source]

Quick copy of an image into a new unsigned 32 bits one

Yayi.image_utilities.copy_to_uint8(im)[source]

Quick copy of an image into a new unsigned 8 bits one

Yayi.image_utilities.crop_window(im, hyperrectangle=None)[source]

Crops the input image to keep the specified hyperrectangle. If hyperrectangle is None, a copy of the input is returned (see copy()).

Parameters:
  • im (image) – the input image that should be cropped
  • hyperrectangle (tuple) – the window from im that should be extracted.
Returns:

a cropped image

Return type:

image

Note

the hyperrectangle parameter is a pair of two coordinate elements, which are respectively the starting and ending point of the rectangle. The ending point is not included.

Warning

the input window is not checked directly in python.

See also

copy()

Example:

im = YACORE.ImageFactory(YAYI.COM.c_scalar, 2)
im.Size = (20, 30)
im.AllocateImage()
cropped_image = crop_window(im, ((10, 5), (15, 20)))
Yayi.image_utilities.get_black_image(original_im)[source]

Creates a scalar black image of the same geometry than the input image.

Note

this function is mainly intended for drawing

Yayi.image_utilities.randomize(im, excluded_value=[])[source]

Assigns to each pixel value of the input image one randomly chosen color image. This function is useful for viewing label images for instance.

Parameters:
  • im (image) – input image
  • excluded_value (list) – a list of values that should remain unchanged
Returns:

the input image with randomized colors

Return type:

image

Note

the input image format should be scalar integer (float/double images are not supported)