API

class pycimg.pycimg.CImg(*args, **kwargs)[source]

CImg is a wrapper class for the CImg library:

__eq__(img)[source]

Return self==value.

__init__(*args, **kwargs)[source]

Create CImg with given data type.

Supported datatypes are int8, int16, int32, uint8, uint16, uint32, float32, and float64.

Examples

1. Create empty image with default type float32 im = CImg()

2. Create image from file. im = CImg(“filename.png”)

3. Create image from numpy array arr = np.zeros((100,2)) im = CImg(arr)

4. Create image of size 100x200 with data type uint8 im = CImg((100, 200), dtype=uint8)

Parameters:image filename, numpy array, or image size. (Either) –
Keyword Arguments:
 dtype – Data type of CImg.
Raises:RuntimeError – For unsupported data types.
__repr__()[source]

Return repr(self).

__str__()[source]

Return str(self).

__weakref__

list of weak references to the object (if defined)

asarray(copy=False)[source]

Returns image data as a numpy array.

Parameters:copy (bool) – False.
depth

Return depth of image.

height

Return height of image.

isempty()[source]

Return true if image is empty.

shape

Return shape of image data.

size

Return the total number of pixel values in the image.

spectrum

Return spectrum (number of channels) of image.

width

Return width of image.