Skip to content

Commit

Permalink
0.20230704: despeckle: wgrid
Browse files Browse the repository at this point in the history
  • Loading branch information
zvezdochiot committed Jul 3, 2023
1 parent 84f96e1 commit ebb5f87
Show file tree
Hide file tree
Showing 31 changed files with 80 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CC = gcc
CPP = g++
CFLAGS = -DUNIX -I$(SRCS) -Wall -s
VER = 0
VERB = 20230505
VERB = 20230704
ifeq ($(OS),Windows_NT)
LIBS = FreeImage.lib
PLIBF = $(PNAME).$(VER).dll
Expand Down
3 changes: 3 additions & 0 deletions bash/pdf/mfbpdf-jbig2jpge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,6 @@ printf ">>\n" >> $fout
printf "startxref\n" >> $fout
printf "%d\n" "$xrefC" >> $fout
printf "%%%%EOF\n" >> $fout

xrefZ=$(cat $fout | wc -c)
printf "%s: %s\n" $fout $xrefZ
5 changes: 5 additions & 0 deletions doc/imthreshold/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.20230704

Despeackle: WGrid
Bash: MFB PDF generator

0.20230505

Threshold: EdgePlus - accurate memory used
Expand Down
2 changes: 1 addition & 1 deletion doc/imthreshold/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.20230505
0.20230704
2 changes: 1 addition & 1 deletion man/man1/imthreshold-a4.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-a4
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-anytodjvu.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-anytodjvu
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-anytominidjvu.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-anytodjvu
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-bash-scripts.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-bash-scripts
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-deskew.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-deskew
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-fautoinv.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-fautoinv
Expand Down
3 changes: 2 additions & 1 deletion man/man1/imthreshold-fdespeckle.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-fdespeckle
Expand Down Expand Up @@ -34,6 +34,7 @@ name method:
'neuro'
'smearing'
'simple' (default)
'wgrid'
.TP
-h
help
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-filter.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-filter
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-finfo.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-finfo
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-fpmean.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-fpmean
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-math.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-math
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-rotate.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-rotate
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-sbwmag2.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-sbwmag2
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-separate.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-separate
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-shris.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-shris
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-size.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-size
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-tdjvul.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-tdjvul
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-tgatos.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-tgatos
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-tglobal.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-tglobal
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-tlayer.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-tlayer
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-tlocal.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-tlocal
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-ttext.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-ttext
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold-twhiterohrer.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold-twhiterohrer
Expand Down
2 changes: 1 addition & 1 deletion man/man1/imthreshold.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ImThreshold" 1 0.20230428 "28 Apr 2023" "User Manual"
.TH "ImThreshold" 1 0.20230704 "04 Jul 2023" "User Manual"

.SH NAME
imthreshold
Expand Down
7 changes: 7 additions & 0 deletions src/fdespeckle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void ImthresholdFilterDespeckleUsage()
printf(" 'neuro'\n");
printf(" 'smearing'\n");
printf(" 'simple' (default)\n");
printf(" 'wgrid'\n");
printf(" -h this help\n");
}

Expand Down Expand Up @@ -137,6 +138,12 @@ int main(int argc, char *argv[])
printf("Method= %s\n", namefilter);
IMTFilterInvertBW(p_im, height, width);
}
else if (strcmp(namefilter, "wgrid") == 0)
{
printf("Method= %s\n", namefilter);
unsigned threshold = 0;
IMTFilterDWGrid(p_im, height, width, Ksize);
}
else if (strcmp(namefilter, "mag2") == 0)
{
printf("Method= %s\n", namefilter);
Expand Down
1 change: 1 addition & 0 deletions src/imthreshold.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ void IMTFilterDNeuro2 (BYTE**, unsigned, unsigned, unsigned, float, unsigned);
float IMTFilterDphist (BYTE**, unsigned, unsigned, unsigned);
void IMTFilterDMinMax (BYTE**, unsigned, unsigned, unsigned);
void IMTFilterDSmearing (BYTE**, unsigned, unsigned, unsigned);
void IMTFilterDWGrid (BYTE**, unsigned int, unsigned int, unsigned int);
float IMTFilterDeNoiseDiff1p (IMTpixel**, unsigned, unsigned, float);
float IMTFilterDeNoiseDiff (IMTpixel**, unsigned, unsigned, unsigned, float);
void IMTBlurMask (IMTpixel**, BYTE**, unsigned, unsigned, int);
Expand Down
37 changes: 37 additions & 0 deletions src/lib/despeckle.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,3 +598,40 @@ void IMTFilterDSmearing (BYTE** p_im, unsigned height, unsigned width, unsigned
}

////////////////////////////////////////////////////////////////////////////////

void IMTFilterDWGrid (BYTE** p_im, unsigned int height, unsigned int width, unsigned int Ksize)
{
unsigned int y, x, yg, xg, hg, wg;
BYTE** d_im;;

hg = (height + Ksize - 1) / Ksize;
wg = (width + Ksize - 1) / Ksize;
d_im = BWalloc(hg, wg);
for (yg = 0; yg < hg; yg++)
{
for (xg = 0; xg < wg; xg++)
{
d_im[yg][xg] = 255;
}
}
for (y = 0; y < height; y++)
{
yg = y / Ksize;
for (x = 0; x < width; x++)
{
xg = x / Ksize;
d_im[yg][xg] &= (255 - p_im[y][x]);
}
}
for (y = 0; y < height; y++)
{
yg = y / Ksize;
for (x = 0; x < width; x++)
{
xg = x / Ksize;
p_im[y][x] = (255 - d_im[yg][xg]);
}
}

BWfree(d_im, hg);
}

0 comments on commit ebb5f87

Please sign in to comment.