Hi there,
I'm looking for a way to crop a mostly dark/black but noisy background (or make it transparent) from a stack of images.
Here are some examples: http://imgur.com/a/8gE82
I tried trimming with the fuzz-option, but that's not enough. I'm sure there is a solution with the imagemagick-magic, but I'm a bit overwhelmed by the options and algorithms. I would be very grateful for any ideas.
I'm using a Linux system with the folloing imagemagick version: ImageMagick 6.9.6-7 Q16 x86_64
Thanks!
cropping noisy background/border
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: cropping noisy background/border
try
see http://www.imagemagick.org/Usage/crop/#trim_fuzz
Code: Select all
convert image -fuzz XX% -trim +repage result
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: cropping noisy background/border
Also see... trimming noisy image
http://www.imagemagick.org/Usage/crop/#trim_noisy
This blurs the image to filter out the noise, trims it with an appropriate fuzz, then applies that trim results to the unblurred image with some adjustments.
http://www.imagemagick.org/Usage/crop/#trim_noisy
This blurs the image to filter out the noise, trims it with an appropriate fuzz, then applies that trim results to the unblurred image with some adjustments.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: cropping noisy background/border
Thanks for the replies.
@fmw42: I tried that already and the result wasn't satisfcatory, apparently the bits of noise are too large.
@anthony: That worked quite well after playing with the blurring-value, thank you.
For the sake of completeness, the commands I used: and
Follow-up luxury problem: As the manuscripts aren't always perfectly adjusted I have two options: cropping the manuscript too large or too small (see commands above). Is there somehow an option to make the difference between an inner and an outer crop transparent.
Example: http://imgur.com/a/M9H9L (I'd wish to make those black pixels in the bottom right corner disappear...)
@fmw42: I tried that already and the result wasn't satisfcatory, apparently the bits of noise are too large.
@anthony: That worked quite well after playing with the blurring-value, thank you.
For the sake of completeness, the commands I used:
Code: Select all
for i in *.jpg; do convert $i -crop `convert $i -virtual-pixel edge -blur 0x50 -fuzz 30% -trim -format '%[fx:w-20]x%[fx:h-20]+%[fx:page.x+10]+%[fx:page.y+10]' info:` +repage crop_$i;done
Code: Select all
for i in *.jpg; do convert $i -crop `convert $i -virtual-pixel edge -blur 0x50 -fuzz 30% -trim -format '%wx%h%O' info:` +repage crop_$i;done
Example: http://imgur.com/a/M9H9L (I'd wish to make those black pixels in the bottom right corner disappear...)