Closed GoogleCodeExporter closed 9 years ago
Ah... actually after further investigation with rotating larger angles (like 5
degrees), I discovered that the problem is NOT with pixRotate() but with my
binImageDiff() routine. That was creating the diff image by starting out with
the
original image. This means the width & height are wrong unless you center that
image
within the rotated image's width and height. Sorry for false alarm.
However, the artifacts are still there when you directly rotate 1bpp images.
Original comment by tomp2...@gmail.com
on 6 Dec 2009 at 10:35
You probably thought I forgot about this...
You are right: when you rotate a 1 bpp image you get horizontal and vertical
shear
lines. The horizontal ones are most visible when they go through a line of
text,
making the text even look tilted in some situations. And the eye is very
sensitive
to a line of shears, even a single pixel.
There are various ways that have been suggested to prevent this. One way is to
choose the horizontal shear lines to be in the white background between text
lines
(for horizontal text). Another is to put some randomness into the shearing, so
that
you don't get full lines of shear.
Your suggestion is actually better. Here is a simple set of operations that
does a
pretty good job on your declaration of independence. I've added in some unsharp
masking to counter the blurring in the convolution.
angletorad = 3.14159 / 180.;
pix1 = pixRead("doi.tif");
pix2 = pixConvertTo8(pix1, 0);
pix3 = pixBlockconv(pix2, 1, 1);
pixFindSkewSweepAndSearch(pix1, &angle, &conf, 2, 2, 3.0, 0.5, 0.01);
radangle = angletorad * angle;
pix4 = pixRotateAM(pix3, radangle, L_BRING_IN_WHITE);
pix5 = pixUnsharpMasking(pix4, 1, 1.0);
pix6 = pixThresholdToBinary(pix5, 128);
pix7 = pixRotateBySampling(pix1, 0, 0, radangle, L_BRING_IN_WHITE);
pixDisplay(pix6, 100, 100);
pixDisplay(pix7, 600, 100);
pixWrite("junkpix6", pix6, IFF_PNG);
pixWrite("junkpix7", pix7, IFF_PNG);
With some playing around to choose parameters, this would certainly be nice
enough to
put into the library.
Original comment by dan.bloo...@gmail.com
on 4 Jan 2010 at 5:08
This feature has been added to 1.65.
The function is pixRotateBinaryNice().
Original comment by dan.bloo...@gmail.com
on 8 Apr 2010 at 6:00
Original issue reported on code.google.com by
tomp2...@gmail.com
on 1 Dec 2009 at 10:04Attachments: