ascii_generator.computation package¶
Submodules¶
ascii_generator.computation.image_processing module¶
image_processing.py: Contains functions for image processing.
- ascii_generator.computation.image_processing.brightness_matrix_to_ascii(matrix: ndarray) str¶
Convert a brightness matrix to ASCII.
- Parameters:
matrix (np.ndarray) – The brightness matrix.
- Returns:
The ASCII representation of the brightness matrix.
- Return type:
str
Examples
>>> brightness_matrix_to_ascii(np.array([[0.5, 0.5], [0.5, 0.5]]))
- ascii_generator.computation.image_processing.chunk_matrix_to_resolution(matrix: ndarray, resolution: tuple[int, int]) ndarray¶
Chunk a matrix into a resolution.
- Parameters:
matrix (np.ndarray) – The matrix to chunk.
resolution (tuple[int, int]) – The resolution to chunk the matrix to.
- Returns:
The chunked matrix.
- Return type:
np.ndarray
Examples
>>> chunk_matrix_to_resolution(np.array([[1, 2], [3, 4]]), (1, 1))
- ascii_generator.computation.image_processing.png_to_brightness_matrix(png_path: Path) ndarray¶
Convert a PNG image to a brightness matrix.
- Parameters:
png_path (Path) – The path to the PNG image.
- Returns:
The brightness matrix with normalised values in the range [0, 1].
- Return type:
np.ndarray
- Raises:
ValueError – If the image is not a PNG image.
Examples
>>> png_to_brightness_matrix(Path("test.png"))
Module contents¶
Computation package for the project.