/* Seven Segment Optical Character Recognition Image Processing Functions */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /* Copyright (C) 2004-2025 Erik Auerswald */ #ifndef SSOCR2_IMGPROC_H #define SSOCR2_IMGPROC_H /* parse luminance keyword */ luminance_t parse_lum(char *keyword); /* set foreground color */ void set_fg_color(int color); /* set background color */ void set_bg_color(int color); /* set imlib color */ void ssocr_set_color(fg_bg_t color); /* draw a fore- or background pixel */ void draw_fg_bg_pixel(Imlib_Image *image, int x, int y, fg_bg_t color); /* draw a foreground pixel */ void draw_fg_pixel(Imlib_Image *image, int x, int y); /* draw a background pixel */ void draw_bg_pixel(Imlib_Image *image, int x, int y); /* draw a pixel of a given color */ void draw_color_pixel(Imlib_Image *image, int x, int y, Imlib_Color color); /* check if a pixel is set regarding current foreground/background colors */ int is_pixel_set(int value, double threshold); /* set pixel if at least mask neighboring pixels (including the pixel to be set) * are set * a pixel is set if its luminance value is less than thresh * mask=1 is the standard dilation filter * mask=9 is the standard erosion filter */ Imlib_Image set_pixels_filter(Imlib_Image *source_image, double thresh, luminance_t lt, int mask); /* perform set pixel filter operation iter times */ Imlib_Image set_pixels_filter_iter(Imlib_Image *source_image, double thresh, luminance_t lt, int mask, int iter); /* shortcut for dilation */ Imlib_Image dilation(Imlib_Image *source_image, double thresh, luminance_t lt, int n); /* shortcut for erosion */ Imlib_Image erosion(Imlib_Image *source_image, double thresh, luminance_t lt, int n); /* shortcut for closing */ Imlib_Image closing(Imlib_Image *source_image, double thresh, luminance_t lt, int n); /* shortcut for opening */ Imlib_Image opening(Imlib_Image *source_image, double thresh, luminance_t lt, int n); /* keep only pixels that have at least mask-1 neighbors set */ Imlib_Image keep_pixels_filter(Imlib_Image *source_image, double thresh, luminance_t lt, int mask); /* remove isolated pixels (shortcut for keep_pixels_filter with mask = 2) */ Imlib_Image remove_isolated(Imlib_Image *source_image, double thresh, luminance_t lt); /* gray stretching, i.e. lum lum=0, lum>t2 => lum=100, * else lum=((lum-t1)*MAXRGB)/(t2-t1) */ Imlib_Image gray_stretch(Imlib_Image *source_image, double t1, double t2, luminance_t lt); /* use dynamic (aka adaptive) local thresholding to create monochrome image */ Imlib_Image dynamic_threshold(Imlib_Image *source_image, double t, luminance_t lt ,int ww, int wh); /* make black and white */ Imlib_Image make_mono(Imlib_Image *source_image, double thresh, luminance_t lt); /* set pixel to black (0,0,0) if R