Best image compression for low bit depth, grayscale images?

3

1

I am trying to compress many (up to 2,500) small (300x200 px) grayscale images so the file size is as small as possible. Currently, my bit depth is 4 (16 shades of gray). Image source is surveillance camera at a remote location, and we need to send images over a very slow satellite connection. I am using ImageMagick to convert images to 4 bit depth uncompressed grayscale TIFs. The uncompressed size of each image is around 41 KB. I am able to compress 1,500 of these images to 3MB with 7zip, which is about a 95% reduction. I have also played around with settings on zpaq, but still cannot get any smaller than 3MB. I know this seems small, but again the satellite connection is at kbps speeds and we pay by the minute for airtime.

Because this is a surveillance camera, the images do not change much between pictures, so I have also tried ffmpeg to convert them to a H.264 video, but file size is even larger (I believe this is because H.264 does not support grayscale, so RGB is still present).

Are there any better settings for zpaq that might give better results, or any other ideas?

Thanks in advance

bdoyle159

Posted 2018-01-10T23:21:02.700

Reputation: 31

What command did you try with ffmpeg? – Gyan – 2018-01-11T04:48:10.563

ffmpeg -i img%04d.tif -vf fps=30 -c:v libx264 -pix_fmt yuv420p out.mp4 – bdoyle159 – 2018-01-11T14:35:07.923

Answers

2

It is often better to let the algorithm choose the best way to compress. Indexed-color compression is suitable for sharp-edged images. Photographic images are better compressed by standards such as JPEG and MPEG.

I tested the H.264 compression using FFmpeg and a video of swimming pool that I made. First I converted the video to grayscale, 300x200 pixels and 2 fps. So I used 00:12:30 of the video to get 1,500 frames. I obtained the following:

ffmpeg -i input.mp4 -c:v libx264 -crf 30 crf30.mp4

File size: 5.7 MB
Bit rate: 60.7 Kbps
Example frame:
enter image description here

ffmpeg -i input.mp4 -c:v libx264 -crf 40 crf40.mp4

File size: 1.6 MB
Bit rate: 17.2 Kbps
Example frame:
enter image description here

ffmpeg -i input.mp4 -c:v libx264 -crf 45 crf45.mp4

File size: 768.5 kB
Bit rate: 7998 bps
Example frame:
enter image description here

Marco

Posted 2018-01-10T23:21:02.700

Reputation: 388

Thanks! I went with a similar approach, but first converted the images to 8-bit grayscale with imagemagick, then packaged them in a video with ffmpeg. I don't have the commands I used in front of me, but I used a 2-pass encoding to encode the video to 25kbps. I'm happy with the results of around 200kB per video. – bdoyle159 – 2018-01-13T00:34:54.190