braille#
This module defines a drawer for the Braille style.
Example
Consider the following image:
Apple Computer [Rob Janoff, 1977]
Here's what it should look like:
DEFAULT_THRESHOLD: int #
The default threshold grayscale intensity.
BrailleDrawer #
A drawer for the Braille style.
Inherits BaseDrawer.
Attributes:
| Name | Type | Description |
|---|---|---|
threshold | int | Threshold grayscale intensity for pixels to be considered. |
kernel | numpy.ndarray | A hard-coded matrix relating the intensity to the Unicode values for Braille characters. |
charset_array | numpy.ndarray | A matrix of all Braille characters, indexed by their offsetted Unicode value. |
__init__(self, threshold=64, **kwargs) special #
Initialization method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
threshold | Optional[int] | Threshold grayscale intensity for pixels to be considered. | 64 |
Source code in picharsso/draw/braille.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
calculate_size(self, image_size) #
Calculates the size of the image for processing the text matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_size | Tuple[int, int] | The height and width of the subject image. | required |
Returns:
| Type | Description |
|---|---|
Tuple[int, int] | The size of the image. |
Source code in picharsso/draw/braille.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
process(self, image) #
Converts an image to a matrix of text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image | PIL.Image.Image | The subject image, with | required |
Returns:
| Type | Description |
|---|---|
numpy.ndarray | The text matrix, with |
Source code in picharsso/draw/braille.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
set(self, threshold=None, **kwargs) #
Sets attributes of the drawer instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
threshold | Optional[int] | Sets | None |
**kwargs | dict | Appropriate keyword arguments. See | {} |
Source code in picharsso/draw/braille.py
103 104 105 106 107 108 109 110 111 112 113 114 | |