Page 1 of 1
cropping noisy background/border
Posted: 2016-12-21T14:08:38-07:00
by zuck
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!
Re: cropping noisy background/border
Posted: 2016-12-21T17:47:24-07:00
by fmw42
try
Code: Select all
convert image -fuzz XX% -trim +repage result
see
http://www.imagemagick.org/Usage/crop/#trim_fuzz
Re: cropping noisy background/border
Posted: 2016-12-21T19:18:13-07:00
by anthony
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.
Re: cropping noisy background/border
Posted: 2016-12-22T06:14:52-07:00
by zuck
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:
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
and
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
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...)