-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpepeline.pyi
executable file
·214 lines (171 loc) · 5.81 KB
/
pepeline.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
from __future__ import annotations
import random
from enum import Enum
from typing import Optional
import numpy as np
class ImgColor(Enum):
GRAY = 0,
RGB = 1,
DYNAMIC = 2
class ImgFormat(Enum):
U8 = 0,
F32 = 1
class TypeNoise(Enum):
PERLIN = 0,
SIMPLEX = 1,
OPENSIMPLEX = 2,
SUPERSIMPLEX = 3,
PERLINSURFLET = 4
class CvtType(Enum):
RGB2Gray = 0, #NTSC
RGB2GrayAverage = 1,
RGB2GrayBt709 = 2,
RGB2GrayBt2020 = 3,
RGB2CMYK = 4,
CMYK2RGB = 5,
RGB2YCbCr = 6, #bt 601
YCbCr2RGB = 7, #bt 601
RGB2YCvCrBt2020 = 8,
YCvCr2RGBBt2020 = 9,
RGB2YCvCrBt709 = 10,
YCvCr2RGBBt709 = 11,
RGB2BGR = 12,
BGR2RGB = 13,
GRAY2RGB = 14,
RGB2Luma = 15 #CIELAB. L only
class TypeDot(Enum):
CIRCLE = 0,
CROSS = 1,
ELLIPSE = 2,
LINE = 2,
INVLINE = 3
def read(
path: str,
mode: Optional[ImgColor] = ImgColor.DYNAMIC,
format: Optional[ImgFormat] = ImgFormat.U8
) -> np.ndarray:
""" The function to read the image. input parameters:
\n path -> str file path
\n mode -> psd dynamic format, and in other cases rgb, None = ImgColor.DYNAMIC
\n format -> f32 0-1 img, u8 0-255, None = ImgFormat.U8"""
def read_size(path: str) -> tuple[int, int]:
"""
Reads the dimensions (width and height) of the image at the given path.
Arguments:
path -- A string that holds the path to the image file.
Returns:
A tuple containing the width and height of the image.
Examples:
dimensions = read_size("path/to/image.png")
print(f"Width: {dimensions[0]}, Height: {dimensions[1]}")
Errors:
This function will raise an error if the file does not exist, the file is not an image,
or if there is an issue reading the image dimensions.
"""
def screentone(
array: np.ndarray,
dot_size: int,
angle: Optional[int] = 0,
dot_type: Optional[TypeDot] = 7
) -> np.ndarray:
"""
Halftone overlay function.
Parameters:
- array (np.ndarray): Input array representing an image with dtype np.float32 (values ranging from 0 to 1).
- dot_size (int): Size of the screentone dots in pixels (uint).
- angle (None | int): Optional parameter representing the rotation angle of the halftone pattern in degrees (i16).
- dot_type (None | TypeDot): Optional parameter specifying the type of dot pattern to use.
Returns:
- np.ndarray: The array with the halftone overlay applied.
This function applies a halftone pattern overlay to the input image array.
- The input array should be 2D with dtype np.float32 and values ranging from 0 to 1.
- 'dot_size' determines the size of the halftone dots in pixels.
- 'angle' specifies the rotation angle of the halftone pattern in degrees. If not provided, the pattern is not rotated.
- 'dot_type' specifies the type of dot pattern to use. If not provided, a default dot pattern is used.
The function returns the array with the halftone overlay applied.
"""
# def halftone(
# array: np.ndarray,
# dot_size: int,
# angle: Optional[int] = None,
# dot_type: Optional[TypeDot] = None
# ) -> np.ndarray: ...
# def cmyk_shift(
# array: np.ndarray,
# c_bias: [int],
# m_bias: [int],
# y_bias: [int],
# k_bias: [int]
# ) -> np.ndarray: ...
def best_tile(array: np.ndarray, tile_size: int) -> (int, int):
"""
Finds the top-left corner of the tile with the highest mean Laplacian intensity.
# Arguments
* `input` - 2D image array (PyReadonlyArray2<f32>).
* `tile_size` - Size of the tile in pixels.
# Returns
* `(usize, usize)` - Coordinates of the top-left corner of the best tile.
"""
def cvt_color(array: np.ndarray, cvt_type: CvtType) -> np.ndarray:
"""
Convert the color space of an array of type np.ndarray.
Parameters:
- array (np.ndarray): The input array, typically representing an image, with dtype np.float32. (YCbCr only 0-1)
- cvt_type (CvtType): The type of color space conversion to perform.
Returns:
- np.ndarray: The array with the converted color space.
This function accepts an array representing an image with dtype np.float32 and converts its color space
based on the specified conversion type (cvt_type). The supported conversion types are enumerated in CvtType.
The function returns the array with the converted color space.
"""
def crop_cord(array: np.ndarray) -> (
int, int, int, int):
"""returns image coordinates not equal to 0, made for cropping using the Laplace operator"""
def fast_color_level(
array: np.ndarray,
in_low: Optional[int] = 0,
in_high: Optional[int] = 255,
out_low: Optional[int] = 0,
out_high: Optional[int] = 255,
gamma: Optional[float] = 1.0,
) -> np.ndarray:
""" array:np.float32
\n in_low...out_high:uint8
\n gamma:float32"""
def noise_generate(
size: tuple[int, int] | tuple[int, int, int],
type_noise: TypeNoise,
octaves: int,
frequency: float,
lacunarity: float,
seed: Optional[int] = random.randint(0,20000),
) -> np.ndarray:
""" size: tuple 2d or 3d
\n type_noise: TypeNoise
\n octaves: uint
\n frequency: float32
\n lacunarity: float32
\n seed: uint"""
class ResizeFilters(enum):
Nearest = 0,
Box = 1,
Bilinear = 2,
Hamming = 3,
CatmullRom= 4,
Mitchell = 5,
Gaussian = 6,
Lanczos3 = 7
def save(
array: np.ndarray,
path: str
) -> np.ndarray:
"""function to save an image, currently supports:
\n f32 0-1 array
\n u8 0-255 array"""
def resize_img(
input: np.ndarray,
size: tuple[int,int],
filter: Optional[ResizeFilters] = ResizeFilters.Nearest,
conv: bool = False,
sampling:int = None
) -> np.ndarray:...