Skip to content

Commit

Permalink
Add test to misctest2.c showing heavy edge cropping with 2 column mat…
Browse files Browse the repository at this point in the history
…erial
  • Loading branch information
DanBloomberg committed Aug 18, 2024
1 parent 2b1f02a commit 6551f38
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
Binary file added prog/2_column_crop_input.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions prog/compresspdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
* required) to have a '.pdf' extension.
*
* As the first step in processing, images are saved in the directory
* /tmp/lept/renderpdf/, as RGB at 300 ppi in ppm format. Each image
* is about 26MB.
* /tmp/lept/renderpdf/, as RGB at either 150 or 300 ppi in ppm format.
* Each image about 6MB at 150 ppi, or 25MB at 300 ppi.
*
* We use pdftoppm to render the images at (typically) 150 pixels/inch
* for a full page, when scalefactor = 1.0. The renderer uses the
Expand Down
2 changes: 1 addition & 1 deletion prog/croppdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
* The pdf output is written to %fileout. It is advisable (but not
* required) to have a '.pdf' extension.
*
* The first processing step is render images from the pdf as $GB
* The first processing step is render images from the pdf as RGB
* at 300 ppi in ppm format, and to seve them in the directory
* /tmp/lept/renderpdf/.
*
Expand Down
18 changes: 18 additions & 0 deletions prog/misctest2.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
* * Page cropping with light filtering
* * Page cropping with removal of fg on left and right sides
* * Demonstrate image cleaning function
* * Demonstrat page cropping for 2-column, where one column is
* Kanji, and removing lots of junk on left and right sides.
*/

#ifdef HAVE_CONFIG_H
Expand All @@ -40,6 +42,7 @@
int main(int argc,
char **argv)
{
char buf[256];
PIX *pix1, *pix2, *pix3;
PIXA *pixa1;

Expand Down Expand Up @@ -67,6 +70,21 @@ PIXA *pixa1;
pixDestroy(&pix1);
pixDestroy(&pix2);

/* Page cropping for 2 columns with junk on left and right sides,
* This is the 2-column introductory material from Bruggen's
* transcription of Bach's Cello Suites 1-3. The right column
* is kanji, which is relatively weak for coalescing into
* connected blocks. So it is necessary to include a
* horizontal close/open of size 3, and in the algorithm, the
* vertical close/open needs to be at least 70 at 4x reduction. */
lept_mkdir("lept/2_column");
lept_cp("2_column_crop_input.pdf", "lept/2_column", "input.pdf", NULL);
snprintf(buf, sizeof(buf),
"croppdf /tmp/lept/2_column 50 50 -1 70 70 1.12 0"
" none /tmp/lept/misc/2_column_crop_result.pdf");
lept_stderr("Writing /tmp/lept/misc/2_column_crop_result.pdf\n");
callSystemDebug(buf);

/* Page cleaning */
pixa1 = pixaCreate(3);
pix1 = pixRead("tel_3.tif");
Expand Down

0 comments on commit 6551f38

Please sign in to comment.