SANEI 1.3.1.72-4c77c
sanei_ir.h
Go to the documentation of this file.
1
21#ifndef SANEI_IR_H
22#define SANEI_IR_H
23
24#include <stdint.h>
25
26#define SAMPLE_SIZE 40000
28#define HISTOGRAM_SHIFT 8
29#define HISTOGRAM_SIZE (1 << HISTOGRAM_SHIFT)
30
31#define SAFE_LOG(x) ( ((x) > 0.0) ? log ((x)) : (0.0) )
33#define MAD_WIN2_SIZE(x) ( (((x) * 4) / 3) | 1 )
35typedef uint16_t SANE_Uint;
36
40typedef union
41{
42 uint8_t *b8;
43 uint16_t *b16;
44}
46
47
52extern void sanei_ir_init (void);
53
68extern SANE_Status
69sanei_ir_create_norm_histogram (const SANE_Parameters * params,
70 const SANE_Uint *img_data,
71 double ** histogram);
72
95extern SANE_Status
96sanei_ir_threshold_yen (const SANE_Parameters * params,
97 double * norm_histo, int *thresh);
98
115extern SANE_Status
116sanei_ir_threshold_otsu (const SANE_Parameters * params,
117 double * norm_histo, int *thresh);
118
138extern SANE_Status
139sanei_ir_threshold_maxentropy (const SANE_Parameters * params,
140 double * norm_histo, int *thresh);
141
158SANE_Status
159sanei_ir_RGB_luminance (SANE_Parameters * params, const SANE_Uint **in_img,
160 SANE_Uint **out_img);
161
180extern SANE_Status
181sanei_ir_to_8bit (SANE_Parameters * params, const SANE_Uint *in_img,
182 SANE_Parameters * out_params, SANE_Uint **out_img);
183
196SANE_Status sanei_ir_ln_table (int len, double **lut_ln);
197
222extern SANE_Status
223sanei_ir_spectral_clean (const SANE_Parameters * params, double *lut_ln,
224 const SANE_Uint *red_data,
225 SANE_Uint *ir_data);
226
245extern SANE_Status
246sanei_ir_filter_mean (const SANE_Parameters * params,
247 const SANE_Uint *in_img, SANE_Uint *out_img,
248 int win_rows, int win_cols);
249
250
282extern SANE_Status
283sanei_ir_filter_madmean (const SANE_Parameters * params,
284 const SANE_Uint *in_img,
285 SANE_Uint ** out_img, int win_size,
286 int a_val, int b_val);
287
288
297void
298sanei_ir_add_threshold (const SANE_Parameters * params,
299 const SANE_Uint *in_img,
300 SANE_Uint * mask_img, int threshold);
301
302
322void
323sanei_ir_manhattan_dist (const SANE_Parameters * params,
324 const SANE_Uint * mask_img, unsigned int *dist_map,
325 unsigned int *idx_map, unsigned int erode);
326
327
339void
340sanei_ir_dilate (const SANE_Parameters * params, SANE_Uint * mask_img,
341 unsigned int *dist_map, unsigned int *idx_map, int by);
342
357void
358sanei_ir_find_crop (const SANE_Parameters * params,
359 unsigned int * dist_map, int inner, int * edges);
360
384SANE_Status
385sanei_ir_dilate_mean (const SANE_Parameters * params,
386 SANE_Uint **in_img,
387 SANE_Uint *mask_img,
388 int dist_max, int expand, int win_size,
389 SANE_Bool smooth, int inner,
390 int *crop);
391
392
393#endif /* not SANEI_IR_H */
SANE_Status sanei_ir_create_norm_histogram(const SANE_Parameters *params, const SANE_Uint *img_data, double **histogram)
Create the normalized histogram of a grayscale image.
void sanei_ir_add_threshold(const SANE_Parameters *params, const SANE_Uint *in_img, SANE_Uint *mask_img, int threshold)
Add dark pixels to mask from static threshold.
SANE_Status sanei_ir_threshold_maxentropy(const SANE_Parameters *params, double *norm_histo, int *thresh)
Implements a Maximum Entropy thresholding method.
void sanei_ir_dilate(const SANE_Parameters *params, SANE_Uint *mask_img, unsigned int *dist_map, unsigned int *idx_map, int by)
Dilate or erode a mask image.
SANE_Status sanei_ir_filter_mean(const SANE_Parameters *params, const SANE_Uint *in_img, SANE_Uint *out_img, int win_rows, int win_cols)
Optimized mean filter.
void sanei_ir_manhattan_dist(const SANE_Parameters *params, const SANE_Uint *mask_img, unsigned int *dist_map, unsigned int *idx_map, unsigned int erode)
Calculates minimal Manhattan distances for an image mask.
SANE_Status sanei_ir_threshold_otsu(const SANE_Parameters *params, double *norm_histo, int *thresh)
Implements Otsu's thresholding method.
SANE_Status sanei_ir_RGB_luminance(SANE_Parameters *params, const SANE_Uint **in_img, SANE_Uint **out_img)
Generate gray scale luminance image from separate R, G, B images.
SANE_Status sanei_ir_to_8bit(SANE_Parameters *params, const SANE_Uint *in_img, SANE_Parameters *out_params, SANE_Uint **out_img)
Convert image from >8 bit depth to an 8 bit image.
void sanei_ir_find_crop(const SANE_Parameters *params, unsigned int *dist_map, int inner, int *edges)
Suggest cropping for dark margins of positive film.
SANE_Status sanei_ir_spectral_clean(const SANE_Parameters *params, double *lut_ln, const SANE_Uint *red_data, SANE_Uint *ir_data)
Reduces red spectral overlap from an infrared image plane.
SANE_Status sanei_ir_dilate_mean(const SANE_Parameters *params, SANE_Uint **in_img, SANE_Uint *mask_img, int dist_max, int expand, int win_size, SANE_Bool smooth, int inner, int *crop)
Dilate clean image parts into dirty ones and smooth int inner,.
void sanei_ir_init(void)
Initialize sanei_ir.
SANE_Status sanei_ir_threshold_yen(const SANE_Parameters *params, double *norm_histo, int *thresh)
Implements Yen's thresholding method.
SANE_Status sanei_ir_ln_table(int len, double **lut_ln)
Allocate and initialize logarithmic lookup table.
SANE_Status sanei_ir_filter_madmean(const SANE_Parameters *params, const SANE_Uint *in_img, SANE_Uint **out_img, int win_size, int a_val, int b_val)
Find noise by adaptive thresholding.
Pointer to access values of different bit depths.
Definition: sanei_ir.h:41
uint16_t * b16
‍8, <= 16 bits
Definition: sanei_ir.h:43
uint8_t * b8
<= 8 bits
Definition: sanei_ir.h:42