45 Commits

Author SHA1 Message Date
Erik Auerswald 63495ef4a8 suppress debug output without -P, --debug-output
Again, a debug message was not properly guarded with a check
for the debug-flag.
2025-10-30 00:04:42 +01:00
Erik Auerswald 94ce321060 lazily adapt threshold to image
Instead of adapting the threshold to the image before executing
commands, adapt the threshold just before it is needed.

This allows to avoid theshold adaptation when -p, --process-only
is used with only the "grayscale" and/or "mirror" commands.

This also prepares the code to allow introduction of a new option
to avoid adapting the threshold to the original image before the
"crop" command is applied.
2025-03-23 18:54:13 +01:00
Erik Auerswald fa30f473e7 simplify adapt_threshold() and iterative_threshold()
Both functions are always called with the same arguments.
Only the get_threshold() function is also called with
different x, y, w, h arguments (when used during dynamic
thresholding).
2025-03-18 21:31:19 +01:00
Erik Auerswald 67abe0fba8 combine get_minval() and get_maxval()
This simplifies the code a bit, and slightly speeds up using
option "-P, --debug-output".
2025-03-18 20:42:38 +01:00
Erik Auerswald 74aeb44f94 rename draw_pixel() to draw_fg_bg_pixel() 2025-02-02 20:42:52 +01:00
Erik Auerswald f012c14d93 refactoring and type consistency fixes
* The draw_pixel() function was called with an "image" parameter
  of type "Imlib_Image" instead of "Imlib_Image *".  This type
  error did not result in a compilation error, and thus stayed
  undetected in the code.

* Introduce a new function draw_color_pixel() similar to draw_pixel(),
  and use it instead of repeatedly open-coding this operation.
2025-02-02 20:32:48 +01:00
Erik Auerswald b44a4ad72a update copyright years 2025-02-01 19:33:29 +01:00
Erik Auerswald 13a5ec3802 imgproc.c: remove some useless code
The removed code was intended to clear the image to allow
only drawing foreground pixels in the following loop.  But
it only drew the outline of a rectangle and thus did not
clear the image as intended.

Since the image is not cleared, the following loop already
draws every pixel, overwriting any previously drawn rectangle
anyway.
2025-02-01 19:26:09 +01:00
Erik Auerswald 2824d0aea7 ensure M_PI is defined
Some image manipulation functions use trigonometric functions.
This includes using the number Pi.  Pi is often available as
M_PI via including <math.h>.  This constant is part of the Unix98
standard, not the C standard itself.  According to the GCC
documentation[1], M_PI is only defined when the feature selection
macro _XOPEN_SOURCE=500 is used.  This seems to be default in
many versions of GNU/Linux, since ssocr could always use M_PI
without explicitly setting _XOPEN_SOURCE=500.

An MPlayer bug report[2] reported a build failure because M_PI
was not defined.  This lead to a patch[3] to work around this
problem.

I want to avoid running into this specific problem in the future,
without introducing significant changes to ssocr.  Thus I check
if M_PI is defined after inlcuding <math.h>, and define it myself
if it is missing.  I use the value found in /usr/include/math.h
from GNU Libc on my current system (Ubuntu GNU/Linux 20.04.6 LTS).

[1] https://www.gnu.org/software/libc/manual/html_node/Mathematical-Constants.html
[2] https://trac.mplayerhq.hu/ticket/2423
[3] https://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2024-December/074244.html

Also add '+' to the version number to indicate changes after the
latest release.
2024-12-14 14:56:13 +01:00
Erik Auerswald 88a627050a print warning when ignoring unknown luminance formula 2024-11-18 17:55:02 +01:00
Erik Auerswald 6569ca9f6b update copyright years 2024-02-23 19:03:58 +01:00
Erik Auerswald ea8f724846 update copyright years 2023-04-23 12:53:48 +02:00
Erik Auerswald b83610d7d2 update copyright year 2022-01-25 18:38:52 +01:00
Erik Auerswald 9b227e7d64 update reasons for string.h includes 2021-10-26 20:28:36 +02:00
Erik Auerswald dc463a5529 options to control decimal separator recognition
Additionally, bump copyright dates and version number.
2021-04-19 19:27:52 +02:00
Erik Auerswald ae3bc107b6 imgproc.c: shorten variable name to shorten line 2019-03-10 18:16:05 +01:00
Erik Auerswald 353ce4a470 imgproc.c: shorten variable name to shorten line 2019-03-10 18:12:00 +01:00
Erik Auerswald a069600590 imgproc.c: delete commented out debugging code 2019-03-10 18:09:12 +01:00
Erik Auerswald 17928b4b76 always use spaces for indentation, not tabs 2019-03-10 18:06:58 +01:00
Erik Auerswald 2031c2c08e refactor scanning for set segments
This introduces a function to scan part of the image for foreground
pixels.

This scanline() function may be of use for distuingishing between
the digit '1' and the symbol ":".

It may also help in segment detection reliability if the "len" parameter
is used to skip scanning image areas between segment positions.
2019-03-10 17:58:04 +01:00
Erik Auerswald 9569289c63 bump copyright year to 2019 2019-02-02 13:08:13 +01:00
Erik Auerswald 1b90fbba6e prefix all error messages with 'ssocr: ' 2018-07-27 22:30:05 +02:00
Erik Auerswald 583b96263c bump copyright year to 2018 2018-07-24 15:18:05 +02:00
Erik Auerswald f87b4a80bd enable executing dilation & erosion N times...
...with optional parameter N instead of repeating the command
2017-11-19 15:33:29 +01:00
Erik Auerswald 60614d467e maint: change flags from int to unsigned int 2017-10-22 17:03:03 +02:00
Erik Auerswald 482969cd12 bump copyright year to 2017 2017-02-26 21:38:51 +01:00
Erik Auerswald 2fc3a07190 bump copyright year to 2016 to reflect recent changes 2016-08-08 21:11:22 +02:00
Erik Auerswald 55a982e253 use a float for one_ratio comparison, and bump copyright year 2015-02-23 15:52:56 +00:00
Erik Auerswald 842cae99e2 bumped version number and copyright year 2014-10-27 09:45:23 +00:00
Erik Auerswald 9865a9ea41 Added new command 'mirror' and bumped version to 2.16.0.
This command enables recognition of Critiano Fontana's images.
2013-12-29 05:29:51 +00:00
Erik Auerswald 971b37308c Fixed dynamic_threshold (broken since "the beginning")
and bumped version number to 2.13.4.

As a result my regression tests using the _broken_ dynamic_threshold fail:

testing images in first2...FAILED
testing images in neu...FAILED
testing images in pics-2005-11-12...FAILED
testing images in schlechte_bilder...FAILED
testing images in new_token_2008-11-07...FAILED
testing images in calc_dyn_thresh...FAILED

But at least I do understand now why dynamic_threshold did not work as I had
expected...I just did not see the error until today.
2013-05-19 19:58:27 +00:00
Erik Auerswald d540340fbd Fixed verbose message when writing image file to disk:
previous, wrong message:  using debug format for png image
current, correct message: using png format for debug image
2013-01-11 05:37:29 +00:00
Erik Auerswald 03434efeae Check for errors when loading or saving an image with Imlib2.
This relies on the definition of enum _imlib_load_error in Imlib2.h
and might break on different versions of Imlib2, but should be better
than the total lack of error reporting before.

Developed with Imlib2 version 1.4.5 from Debian/Sid:

$ dpkg -l libimlib2-dev
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  libimlib2-dev  1.4.5-1      i386         Imlib2 development files
2013-01-11 05:30:21 +00:00
Erik Auerswald 16bcc37f78 Bumped copyright years to 2004-2013. 2013-01-08 16:56:37 +00:00
Erik Auerswald 1d8e788e93 Removed function rgb_threshold() from imgproc.[ch].
All calls to this function have been replaced by calls to make_mono()
with the appropriate luminance type (minimum, red, green, or blue).
This way --foreground / --background work with the commands
{r,g,b,rgb}_threshold as expected.

Problem was "shear" setting background pixels using the specified
--background color, but rgb_threshold() always using the default colors
(foreground black, background white), ognoring the options.

Added a formerly failing test case to the regression tests:
  Lauro-LEDs-digits-fore_back
2012-07-13 17:03:43 +00:00
Erik Auerswald fbd00e8c96 Removed left-over debugging output. 2012-07-13 16:15:53 +00:00
Erik Auerswald dc70232167 Use extern global variables for ssocr_foreground / ssocr_background. 2012-07-13 16:14:57 +00:00
Erik Auerswald 9041d7d41b Fixed off-by-one error in shear operation.
One pixel per line was left unchanged.
2012-06-10 17:07:17 +00:00
Erik Auerswald a45d5cd5d8 Bump copyright to 2004-2010,2012. 2012-02-16 08:58:31 +00:00
Erik Auerswald 5bd1f54b5d Updated copyright statement. 2010-06-08 11:59:09 +00:00
Erik Auerswald cba330b81f Correct a comment (copy&paste error). 2009-08-11 09:42:08 +00:00
Erik Auerswald be3bb8f66b Add - as shorthand for /proc/self/fd/1 to image save function. 2009-08-11 08:19:08 +00:00
Erik Auerswald d01795f191 Improve verbose messages when writing image files. 2009-08-11 07:48:40 +00:00
Erik Auerswald 5738646605 Use "gray" and "color" consistently (A.E.). 2009-08-05 05:14:45 +00:00
Erik Auerswald a1a060b416 - refactor image processing and online help in seperate files
- no functional changes
- this is another step towards refactoring the recognition algorithm
- this is another step towards factoring out the image access routines to
  ultimately replace Imlib2 by something else (e.g. gd)
2009-01-06 11:22:10 +00:00