file.ppm_handler

Author: Ismael Seidel (ismael.seidel@ufsc.br) Affiliation: Embedded Computing Lab (ECL), Federal University of Santa Catarina (UFSC) Contributors:

  • André Filipe da Silva Fernandes

Description:

This module is used to read and write PPM files. See: https://netpbm.sourceforge.net/doc/ppm.html

class PPMHeader(width: int, height: int, depth: int)[source]

Bases: object

Parameters:
  • width (int)

  • height (int)

  • depth (int)

width: int
height: int
depth: int
class PPMHandler[source]

Bases: object

Handler for reading and writing PPM image files.

read(path)[source]

Reads a PPM file and returns the image data as a numpy array.

Parameters:

path (Union[str, Path]) – Path to the PPM file

Returns:

Image data as 3D numpy array (height, width, channels)

Return type:

np.ndarray

write(path, data, depth=10)[source]

Writes image data to a PPM file.

Parameters:
  • path (Union[str, Path]) – Path to the output PPM file

  • data (np.ndarray) – Image data as 3D numpy array (height, width, channels)

  • depth (int) – Bit depth for output, defaults to 10

Returns:

None

Return type:

None