Colorspaces and porting from IM 6.6.x
Posted: 2015-08-27T10:39:30-07:00
I have an old script that is used to do clean up some images before OCR. The script has grown organically but it is "well oiled" and it has done its job perfectly in the past years. Now we moved to a new Ubuntu version that ships version 6.7.7-10 and the script is producing horrible results. We traced it down to a change in the way default colorspaces are handled, as suggested by http://www.imagemagick.org/script/color-management.php and viewtopic.php?t=20501.
I tried sprinkling some -set colorspace RGB -colorspace RGB around but it did not work.
The core of my script is
This script works perfectly with IM 6.6.9 but produces completely wrong results with IM 6.7.7-10.
How can I change this script to work in the same way it both version or, at least, only in version 6.7.7 but in the correct way?
I tried sprinkling some -set colorspace RGB -colorspace RGB around but it did not work.
The core of my script is
Code: Select all
cat "$workdir/src.png" |
# remove shades of gray1
convert png:fd:0 -fuzz 10% -fill black -opaque 'rgb(159,153,153)' png:fd:1 |
tee /tmp/step1.png |
# remove shades of gray2
convert png:fd:0 -fuzz 10% -fill black -opaque 'rgb(109,97,109)' png:fd:1 |
tee /tmp/step2.png |
# remove shades of gray3
convert png:fd:0 -fuzz 10% -fill black -opaque 'rgb(178,185,193)' png:fd:1 |
tee /tmp/step3.png |
# convert to grayscale with an emphasis on reds
convert png:fd:0 \
\( -clone 0 -channel GR -separate +channel -evaluate-sequence mean \) \
\( -clone 0 -channel RB -separate +channel -evaluate-sequence mean \) \
-delete 0 -evaluate-sequence mean \
png:fd:1 |
tee /tmp/step4.png |
# black text on white background
convert png:fd:0 -threshold 50% -negate png:fd:1 |
cat > "$workdir/bw.png"
How can I change this script to work in the same way it both version or, at least, only in version 6.7.7 but in the correct way?