jwilk / didjvu

DjVu encoder with foreground/background separation
https://jwilk.net/software/didjvu
GNU General Public License v2.0
10 stars 8 forks source link

Issue on lower edge of page: The foreground mask does miss the lower edge #16

Closed rmast closed 3 years ago

rmast commented 3 years ago

When I encode the included Scantailored image with content on the lower edge with this statement in the standard didjvu (master from jwilk) with Python2.7 and http://nl.archive.ubuntu.com/ubuntu/pool/universe/g/gamera/python-gamera_3.4.2+git20160808.1725654-2_amd64.deb in Mint 20.2 I get a foreground mask that doesn't contain the lower half on the lower edge of the picture.

./didjvu encode ~/scantailorin/out/outputbase2-000-raar-effect-onderste-regel-didjvu\ zonder\ tekst.tif -o jaarverslagraar.djvu outputbase2-000-raar-effect-onderste-regel-didjvu zonder tekst.zip

Result jaarverslagraar.zip (Watch with djview the lower edge and select foreground to see half of the mask is missing)

This is how the mask looks: image

I can see no visual reason in the original image to cause this.

rmast commented 3 years ago

The error isn't even consistent between runs:

robert@robert-virtual-machine:~/didjvu$ ./didjvu encode ~/scantailorin/out/outputbase2-000-raar-effect-onderste-regel-didjvu\ zonder\ tekst.tif -o jaarverslagraar5.djvu
/home/robert/scantailorin/out/outputbase2-000-raar-effect-onderste-regel-didjvu zonder tekst.tif:
- reading image
- converting to DjVu
- 0.010 bits/pixel; 112.794:1, 99.11% saved, 4122172 bytes in, 36546 bytes out
robert@robert-virtual-machine:~/didjvu$ ./didjvu encode ~/scantailorin/out/outputbase2-000-raar-effect-onderste-regel-didjvu\ zonder\ tekst.tif -o jaarverslagraar6.djvu
/home/robert/scantailorin/out/outputbase2-000-raar-effect-onderste-regel-didjvu zonder tekst.tif:
- reading image
- converting to DjVu
- 0.010 bits/pixel; 112.560:1, 99.11% saved, 4122172 bytes in, 36622 bytes out

However it seems to stem from Gamera include/plugins/threshold.hpp, djvu_threshold. If I can pinpoint the issue there I can move this issue to the Gamera library.

rmast commented 3 years ago

With the fix suggested in Gamera the resulting djvu page would cost 2 kilobyte less.

rmast commented 3 years ago

Solved in the newest commit of gamera