0
# Input/Output
1
2
Image input/output operations for reading and writing images in various formats. Supports single images, image collections, multi-frame images, and metadata handling.
3
4
## Capabilities
5
6
### Basic Image I/O
7
8
```python { .api }
9
def imread(fname, as_gray=False, plugin=None, **plugin_args):
10
"""
11
Load image from file.
12
13
Parameters:
14
fname : str
15
Image filename or URL
16
as_gray : bool, optional
17
Convert to grayscale
18
plugin : str, optional
19
Plugin to use for reading
20
**plugin_args
21
Additional plugin arguments
22
23
Returns:
24
ndarray
25
Image array
26
"""
27
28
def imsave(fname, arr, plugin=None, check_contrast=True, **plugin_args):
29
"""
30
Save image array to file.
31
32
Parameters:
33
fname : str
34
Output filename
35
arr : array_like
36
Image array to save
37
plugin : str, optional
38
Plugin to use for writing
39
check_contrast : bool, optional
40
Check for low contrast
41
**plugin_args
42
Additional plugin arguments
43
"""
44
```
45
46
### Image Collections
47
48
```python { .api }
49
class ImageCollection:
50
"""
51
Load and manage collections of images.
52
53
Parameters:
54
load_pattern : str or list
55
Pattern or list of image files
56
conserve_memory : bool, optional
57
Load images on demand
58
load_func : callable, optional
59
Custom loading function
60
"""
61
62
def __init__(self, load_pattern, conserve_memory=True, load_func=None):
63
pass
64
65
def imread_collection(load_pattern, conserve_memory=True, plugin=None, **plugin_args):
66
"""
67
Load image collection from pattern.
68
69
Parameters:
70
load_pattern : str or list
71
Pattern or list of image files
72
conserve_memory : bool, optional
73
Load images on demand
74
plugin : str, optional
75
Plugin to use
76
**plugin_args
77
Additional plugin arguments
78
79
Returns:
80
ImageCollection
81
Collection of images
82
"""
83
84
class MultiImage:
85
"""
86
Handle multi-page/multi-frame images.
87
88
Parameters:
89
filename : str
90
Image filename
91
conserve_memory : bool, optional
92
Load frames on demand
93
**kwargs
94
Additional arguments
95
"""
96
97
def __init__(self, filename, conserve_memory=True, **kwargs):
98
pass
99
100
def concatenate_images(images):
101
"""
102
Concatenate images into single array.
103
104
Parameters:
105
images : iterable
106
Images to concatenate
107
108
Returns:
109
ndarray
110
Concatenated image array
111
"""
112
```
113
114
## Types
115
116
```python { .api }
117
from typing import Union, List, Optional, Callable
118
from numpy.typing import NDArray
119
import numpy as np
120
121
# I/O types
122
ImagePath = Union[str, bytes]
123
ImageArray = NDArray[np.number]
124
ImageList = List[ImageArray]
125
LoadFunction = Callable[[str], ImageArray]
126
```