If you're serious about compressing this data, you shouldn't be using
a general image-compression algorithm at all, because you know an
incredible amount about the structure of the image a priori. Assuming
this is a standard EKG image, you're looking at a uniform pink grid on
a white background with a black squiggle overlying it. Everything
except for the black line can be encoded in four values - the (x,y)
scaling and offsets of the grid (and possibly a rotation amount to
account for misalignment). It should be possible to fit the actual
EKG trace with a piecewise linear approximation.
This sort of approach will get you vastly better compression because
it takes into account the known image structure. The downside is that
it's harder to find off-the-shelf components from which you can piece
it together, so this would probably require a good deal more work,
which may be a deal breaker for you.
– Steve
On Jan 15, 2008, at 2:42 PM, Holger Bettag wrote:
On Tue, 15 Jan 2008, Scott Ribe wrote:
PNG might be the right format. JPEG will have ringing artifacts with
simple line art like that.
I'll look at PNG. I also plan to try TIFF + zlib, and even making an
uncompressed TIFF then bzip'ing it. In some experiments, I got
surprisingly
good results with JPEG. I can't of course use a heavy degree of
quantization, but I was surprised at how much compression I could
get before
artifacts started showing up. I think part of it is that with
scanned images
the edges are already slightly "softened" by the aliasing inherent
in the
sampling, as opposed to a computer-generated original where many
edges may
be absolute.
A compression format based on a wavelet transform of the whole image
ought to do significantly better than JPEG, because the images in
question do not have large areas with texture. Wavelets typically
remove much more redundancy from large uniform areas, while JPEG
cannot look past the 8x8 pixel tiles that it transforms
independently. The amount of ringing can be controlled by the type
of wavelet used. But even the "standard" Daubechies filter pair with
9 and 7 taps (also called "4,4" refering to the number of "vanishing
moments" in each filter) handles line art surprisingly well.