Maybe fill the background color to black and crop only the white areas of the photo? Or maybe there is a better solution I am not aware of.
Any help is appreciated.
thanks.

Code: Select all
convert noisy.jpg -crop \
`convert noisy.jpg -virtual-pixel edge -blur 0x15 -fuzz 15% \
-trim -format '%wx%h%O' info:` +repage noisy_trimmed_2.jpg
Code: Select all
cropvals=`convert image.png -statistic median 5x5 -fuzz 15% -format "%@" info:`
convert image.png -crop $cropvals image_crop.png
Code: Select all
cropvals=`convert image.png -threshold 0 -type bilevel \
-define connected-components:area-threshold=25 \
-define connected-components:mean-color=true \
-connected-components 4 \
-fuzz 15% -format "%@" info:`
convert image.png -crop $cropvals image_crop.png
Code: Select all
convert image.png -scale 1x! -scale 50x! -negate -threshold 2% -negate image1_rows.png
Code: Select all
convert input.tif -kuwahara 2 multi-output.png
convert *.png -fuzz 90% -trim +repage multi-output.png
Code: Select all
convert input.tif -kuwahara 2 -fuzz 90% -trim +repage multi-output_%02d.png
Thanks again for all your help, I will mark this thread as solved in the title.fmw42 wrote: ↑2018-12-29T12:55:57-07:00 Kuwahara is a noise smoothing filter. But if using too large a value, it will smooth your image as in the examples at https://imagemagick.org/discourse-serve ... =4&t=26480. For small arguments it will remove your spot noise that is limiting the trim. Since this works for you, it looks like a good way to do all the pages at one time. The high fuzz values is needed since you have nearly binary data, but still have noise, though it is smoothed to brighter values. Anyway, that certainly seems like a good way, since it seems to work. But you can do that all in one line.
Code: Select all
convert input.tif -kuwahara 2 -fuzz 90% -trim +repage multi-output_%02d.png