histogram_equalization/hist_equal_decl.rs
1use colorutils_rs::{
2 bgra_to_hsl, bgra_to_hsv, hsl_to_bgra, hsl_to_rgb, hsl_to_rgba, hsv_to_bgra, hsv_to_rgb,
3 hsv_to_rgba, rgb_to_hsl, rgb_to_hsv, rgba_to_hsl, rgba_to_hsv,
4};
5
6use crate::hist_equal_impl::equalize_histogram_impl;
7use crate::lab::{bgra_to_lab, lab_to_bgra, lab_to_rgb, lab_to_rgba, rgb_to_lab, rgba_to_lab};
8use crate::luv::{bgra_to_luv, luv_to_bgra, luv_to_rgb, luv_to_rgba, rgb_to_luv, rgba_to_luv};
9
10/// Converts image to HSV, performs histogram equalization and reverts back into RGB
11///
12/// # Arguments
13///
14///
15/// # Panics
16///
17/// This function panics if the lengths of the planes or the input data are not valid based
18/// on the specified width, height, and strides
19pub fn hist_equal_hsv_rgb(
20 src: &[u8],
21 src_stride: u32,
22 dst: &mut [u8],
23 dst_stride: u32,
24 width: u32,
25 height: u32,
26 bins_count: usize,
27) {
28 equalize_histogram_impl::<3, 2>(
29 src, src_stride, dst, dst_stride, width, height, bins_count, rgb_to_hsv, hsv_to_rgb,
30 );
31}
32
33/// Converts image to HSV, performs histogram equalization and reverts back into RGBA
34///
35/// # Arguments
36///
37///
38/// # Panics
39///
40/// This function panics if the lengths of the planes or the input data are not valid based
41/// on the specified width, height, and strides
42pub fn hist_equal_hsv_rgba(
43 src: &[u8],
44 src_stride: u32,
45 dst: &mut [u8],
46 dst_stride: u32,
47 width: u32,
48 height: u32,
49 bins_count: usize,
50) {
51 equalize_histogram_impl::<4, 2>(
52 src,
53 src_stride,
54 dst,
55 dst_stride,
56 width,
57 height,
58 bins_count,
59 rgba_to_hsv,
60 hsv_to_rgba,
61 );
62}
63
64/// Converts image to HSV, performs histogram equalization and reverts back into BGRA
65///
66/// # Arguments
67///
68///
69/// # Panics
70///
71/// This function panics if the lengths of the planes or the input data are not valid based
72/// on the specified width, height, and strides
73pub fn hist_equal_hsv_bgra(
74 src: &[u8],
75 src_stride: u32,
76 dst: &mut [u8],
77 dst_stride: u32,
78 width: u32,
79 height: u32,
80 bins_count: usize,
81) {
82 equalize_histogram_impl::<4, 2>(
83 src,
84 src_stride,
85 dst,
86 dst_stride,
87 width,
88 height,
89 bins_count,
90 bgra_to_hsv,
91 hsv_to_bgra,
92 );
93}
94
95/// Converts image to HSL, performs histogram equalization and reverts back into RGB
96///
97/// # Arguments
98///
99///
100/// # Panics
101///
102/// This function panics if the lengths of the planes or the input data are not valid based
103/// on the specified width, height, and strides
104pub fn hist_equal_hsl_rgb(
105 src: &[u8],
106 src_stride: u32,
107 dst: &mut [u8],
108 dst_stride: u32,
109 width: u32,
110 height: u32,
111 bins_count: usize,
112) {
113 equalize_histogram_impl::<3, 2>(
114 src, src_stride, dst, dst_stride, width, height, bins_count, rgb_to_hsl, hsl_to_rgb,
115 );
116}
117
118/// Converts image to HSL, performs histogram equalization and reverts back into RGBA
119///
120/// # Arguments
121///
122///
123/// # Panics
124///
125/// This function panics if the lengths of the planes or the input data are not valid based
126/// on the specified width, height, and strides
127pub fn hist_equal_hsl_rgba(
128 src: &[u8],
129 src_stride: u32,
130 dst: &mut [u8],
131 dst_stride: u32,
132 width: u32,
133 height: u32,
134 bins_count: usize,
135) {
136 equalize_histogram_impl::<4, 2>(
137 src,
138 src_stride,
139 dst,
140 dst_stride,
141 width,
142 height,
143 bins_count,
144 rgba_to_hsl,
145 hsl_to_rgba,
146 );
147}
148
149/// Converts image to HSL, performs histogram equalization and reverts back into BGRA
150///
151/// # Arguments
152///
153///
154/// # Panics
155///
156/// This function panics if the lengths of the planes or the input data are not valid based
157/// on the specified width, height, and strides
158pub fn hist_equal_hsl_bgra(
159 src: &[u8],
160 src_stride: u32,
161 dst: &mut [u8],
162 dst_stride: u32,
163 width: u32,
164 height: u32,
165 bins_count: usize,
166) {
167 equalize_histogram_impl::<4, 2>(
168 src,
169 src_stride,
170 dst,
171 dst_stride,
172 width,
173 height,
174 bins_count,
175 bgra_to_hsl,
176 hsl_to_bgra,
177 );
178}
179
180/// Converts image to LAB, performs histogram equalization and reverts back into RGB
181///
182/// # Arguments
183///
184///
185/// # Panics
186///
187/// This function panics if the lengths of the planes or the input data are not valid based
188/// on the specified width, height, and strides
189pub fn hist_equal_lab_rgb(
190 src: &[u8],
191 src_stride: u32,
192 dst: &mut [u8],
193 dst_stride: u32,
194 width: u32,
195 height: u32,
196 bins_count: usize,
197) {
198 equalize_histogram_impl::<3, 0>(
199 src, src_stride, dst, dst_stride, width, height, bins_count, rgb_to_lab, lab_to_rgb,
200 );
201}
202
203/// Converts image to LAB, performs histogram equalization and reverts back into RGBA
204///
205/// # Arguments
206///
207///
208/// # Panics
209///
210/// This function panics if the lengths of the planes or the input data are not valid based
211/// on the specified width, height, and strides
212pub fn hist_equal_lab_rgba(
213 src: &[u8],
214 src_stride: u32,
215 dst: &mut [u8],
216 dst_stride: u32,
217 width: u32,
218 height: u32,
219 bins_count: usize,
220) {
221 equalize_histogram_impl::<4, 0>(
222 src,
223 src_stride,
224 dst,
225 dst_stride,
226 width,
227 height,
228 bins_count,
229 rgba_to_lab,
230 lab_to_rgba,
231 );
232}
233
234/// Converts image to LAB, performs histogram equalization and reverts back into BGRA
235///
236/// # Arguments
237///
238///
239/// # Panics
240///
241/// This function panics if the lengths of the planes or the input data are not valid based
242/// on the specified width, height, and strides
243pub fn hist_equal_lab_bgra(
244 src: &[u8],
245 src_stride: u32,
246 dst: &mut [u8],
247 dst_stride: u32,
248 width: u32,
249 height: u32,
250 bins_count: usize,
251) {
252 equalize_histogram_impl::<4, 0>(
253 src,
254 src_stride,
255 dst,
256 dst_stride,
257 width,
258 height,
259 bins_count,
260 bgra_to_lab,
261 lab_to_bgra,
262 );
263}
264
265/// Converts image to LUV, performs histogram equalization and reverts back into RGB
266///
267/// # Arguments
268///
269///
270/// # Panics
271///
272/// This function panics if the lengths of the planes or the input data are not valid based
273/// on the specified width, height, and strides
274pub fn hist_equal_luv_rgb(
275 src: &[u8],
276 src_stride: u32,
277 dst: &mut [u8],
278 dst_stride: u32,
279 width: u32,
280 height: u32,
281 bins_count: usize,
282) {
283 equalize_histogram_impl::<3, 0>(
284 src, src_stride, dst, dst_stride, width, height, bins_count, rgb_to_luv, luv_to_rgb,
285 );
286}
287
288/// Converts image to LUV, performs histogram equalization and reverts back into RGBA
289///
290/// # Arguments
291///
292///
293/// # Panics
294///
295/// This function panics if the lengths of the planes or the input data are not valid based
296/// on the specified width, height, and strides
297pub fn hist_equal_luv_rgba(
298 src: &[u8],
299 src_stride: u32,
300 dst: &mut [u8],
301 dst_stride: u32,
302 width: u32,
303 height: u32,
304 bins_count: usize,
305) {
306 equalize_histogram_impl::<4, 0>(
307 src,
308 src_stride,
309 dst,
310 dst_stride,
311 width,
312 height,
313 bins_count,
314 rgba_to_luv,
315 luv_to_rgba,
316 );
317}
318
319/// Converts image to LUV, performs histogram equalization and reverts back into BGRA
320///
321/// # Arguments
322///
323///
324/// # Panics
325///
326/// This function panics if the lengths of the planes or the input data are not valid based
327/// on the specified width, height, and strides
328pub fn hist_equal_luv_bgra(
329 src: &[u8],
330 src_stride: u32,
331 dst: &mut [u8],
332 dst_stride: u32,
333 width: u32,
334 height: u32,
335 bins_count: usize,
336) {
337 equalize_histogram_impl::<4, 0>(
338 src,
339 src_stride,
340 dst,
341 dst_stride,
342 width,
343 height,
344 bins_count,
345 bgra_to_luv,
346 luv_to_bgra,
347 );
348}