Help with Trim
Help with Trim
Hello, I'm having an issue with trim. I have a set of scanned documents I'm trying to automatically process, but trim doesn't seem to be removing whitespaces from them. I've tried with the borders and with fuzz, but no luck. Any help would be much appreciated.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Help with Trim
I'm not sure what you are trying to do.
"-trim" crops by trimming away pixels around the edges that are the same (or similar) colour. Your sample has white edges with a few isolated black pixels. You might de-noise to remove these. Or you might flood-fill with black, then trim away all the black.
"-trim" crops by trimming away pixels around the edges that are the same (or similar) colour. Your sample has white edges with a few isolated black pixels. You might de-noise to remove these. Or you might flood-fill with black, then trim away all the black.
snibgo's IM pages: im.snibgo.com
Re: Help with Trim
Thank you, I'll take a look at doing that. Isn't that what fuzz is for though?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Help with Trim
Black is as far from white as it can be, so you would need "-fuzz 100%", which would remove your image entirely.
snibgo's IM pages: im.snibgo.com
Re: Help with Trim
So, would it be something like this: convert c:\20.png -fuzz 99% -fill white -draw "color 0,0 flood
fill" -trim +repage c:\20.out.png?
fill" -trim +repage c:\20.out.png?
Re: Help with Trim
I found this to work well:
convert -density 1200 -deskew 40 20.pdf[0] -deskew 40 -resize 25% +repage t.png;
convert t.png -crop \
`convert t.png -virtual-pixel edge -blur 0x15 -fuzz 20% \
-trim -format '%wx%h%O' info:` +repage 20.png
Is there a way to properly work the deskew into here? Most of my images (without the deskew) are fine, but I can't seem to get some of them that are skewed to deskew correctly.
convert -density 1200 -deskew 40 20.pdf[0] -deskew 40 -resize 25% +repage t.png;
convert t.png -crop \
`convert t.png -virtual-pixel edge -blur 0x15 -fuzz 20% \
-trim -format '%wx%h%O' info:` +repage 20.png
Is there a way to properly work the deskew into here? Most of my images (without the deskew) are fine, but I can't seem to get some of them that are skewed to deskew correctly.
Re: Help with Trim
I forgot the % for the deskew, that fixed it.