Page 1 of 1

White pixel noise on JPG [6.7.7-10]

Posted: 2019-01-30T23:22:20-07:00
by alibek
Hello.
I have a JPG image, to which every few minutes I output narrow vertical stripes (2-3 pixels) from another JPG image. For some reason, small white squares appear on the resulting image.
When the stripes were wider (about 50 pixels), I did not notice such a problem.
Screenshot: https://prnt.sc/mel1tf
The image is formed in this way (bash script):

Code: Select all

SRC="images.jpg"
DST="result.jpg"
let NOW=`date +"%s"`-`date --date="00:00" +"%s"`
let MW=`identify -format "%w" "$DST"`
let MH=`identify -format "%h" "$DST"`
let MX0=`calc "int(${MW}*${NOW}/86400)"`
let MX1=`calc "int(${MW}*(${NOW}+${INT})/86400)-1"`
if [ $MX1 -ge $MW ]; then let MX1=$MW-1 ; fi
let MW1=$MX1-$MX0+1
let MX2=`calc "int(${MW}*(${NOW}+2*${INT})/86400)-1"`
if [ $MX2 -ge $MW ]; then let MX2=$MW-1 ; fi
let MW2=$MX2-$MX0+1

convert "$DST" -size ${MW2}x${MH} -fill black -draw "rectangle ${MX0},0 ${MX2},${MH}" "$DST"
convert "$SRC" -crop ${MW1}x${MH}+${MX0}+0 "/tmp/crop.jpg"
composite -geometry +${MX0}+0 "$TMP/crop.jpg" "$DST" "$DST"
rm -f "/tmp/crop.jpg"
I draw a black strip on the destination image, and then I draw a strip of the dynamic image on top of it.

Version: ImageMagick 6.7.7-10 2018-05-23 Q16 http://www.imagemagick.org
OS: Linux srv-svc03 3.2.0-6-amd64 #1 SMP Debian 3.2.102-1 x86_64 GNU/Linux

Re: White pixel noise on JPG [6.7.7-10]

Posted: 2019-01-30T23:56:48-07:00
by dlemstra
And what happens with the latest version? You are using an ancient one.

Re: White pixel noise on JPG [6.7.7-10]

Posted: 2019-01-31T00:10:13-07:00
by alibek
On this server, I still can not update the OS and ImageMagick. But if you use PNG (instead of JPG) as the resulting image, the problem is eliminated.
As a workaround, I use PNG format images when processing, and upon completion convert PNG to JPG.

Re: White pixel noise on JPG [6.7.7-10]

Posted: 2019-01-31T03:34:29-07:00
by snibgo
JPG is a lossy format. This means that when you save a JPG file, the compression code changes your pixels. I strongly suggest that you never use it as an intermediate format. Always use a lossless format such as tiff or miff or png.

Re: White pixel noise on JPG [6.7.7-10]

Posted: 2019-02-02T01:47:26-07:00
by Lars-Daniel
snibgo wrote: 2019-01-31T03:34:29-07:00Always use a lossless format such as tiff or miff or png.
Please don't recommend PNG as an intermediate format, it cannot handle CMYK. Even when that's not important here, other users might get into trouble :-)

Re: White pixel noise on JPG [6.7.7-10]

Posted: 2019-02-02T06:40:19-07:00
by snibgo
Yes, that's true, PNG cannot record CMYK. Writing PNG is also rather slow, which is another reason not to use it.