Reader
The reader
module provides ways to read image data
Image Reader module
ReaderImage
ReaderImage class to facilitate the reading of images from different formats such as JPG, PNG, and PDF. It provides methods to load images from file paths.
Source code in otary/image/components/io/reader.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
from_file(filepath, as_grayscale=False, resolution=None)
staticmethod
Create a Image array from a file image path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath
|
str
|
path to the image file |
required |
as_grayscale
|
bool
|
turn the image in grayscale. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
NDArray |
NDArray
|
Image as array |
Source code in otary/image/components/io/reader.py
from_fillvalue(value=255, shape=(128, 128, 3))
staticmethod
Create an array image from a single value
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
int
|
value in [0, 255]. Defaults to 255. |
255
|
shape
|
tuple
|
image shape. If it has three elements then the last one must be a 3 for a coloscale image. Defaults to (128, 128, 3). |
(128, 128, 3)
|
Returns:
Name | Type | Description |
---|---|---|
NDArray |
NDArray
|
array with a single value |
Source code in otary/image/components/io/reader.py
from_jpg(filepath, as_grayscale=False, resolution=None)
staticmethod
Create a Image object from a JPG or JPEG file path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath
|
str
|
path to the JPG image file |
required |
as_grayscale
|
bool
|
turn the image in grayscale. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
NDArray |
NDArray
|
numpy array |
Source code in otary/image/components/io/reader.py
from_pdf(filepath, as_grayscale=False, page_nb=0, resolution=None, clip_pct=None)
staticmethod
Create an Image array from a pdf file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath
|
str
|
path to the pdf file. |
required |
as_grayscale
|
bool
|
whether to turn the image in grayscale. Defaults to False. |
False
|
page_nb
|
int
|
as we load only one image we have to select the page that will be turned into an image. Defaults to 0. |
0
|
resolution
|
Optional[int]
|
resolution of the loaded image. Defaults to 3508. |
None
|
clip_pct
|
Rect
|
optional zone to extract in the image. This is particularly useful to load into memory only a small part of the image without loading everything into memory. This reduces considerably the image loading time especially combined with a high resolution. |
None
|
Returns:
Name | Type | Description |
---|---|---|
NDArray |
NDArray
|
Image as array |
Source code in otary/image/components/io/reader.py
from_png(filepath, as_grayscale=False, resolution=None)
staticmethod
Create a Image array from a PNG file image path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath
|
str
|
path to the image file |
required |
as_grayscale
|
bool
|
turn the image in grayscale. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
NDArray |
NDArray
|
Image as array |