For Programmers: Free Programming Magazines  


Home > Archive > Compression > February 2005 > a question about JasPer compression (JPEG2000)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author a question about JasPer compression (JPEG2000)
Gui Xie

2005-02-13, 3:55 pm

Hi:
I use the jasper encoder to compress a 8-bit grayscale image in matlab
as follows:

I=imread('lena.bmp');
imwrite(I,'temp1.ppm');
%encode
!jasper -f temp1.ppm -F lena.jp2 -T jp2 -O rate=0.01
%decode
!jasper -f lena.jp2 -F temp2.ppm -T pnm
J=imread('temp2.ppm');


Now the uncompressed image J becomes 32-bit RGB image instead of a 8-bit
grayscale image. It seems the PPM file can only represent 32-bit RGB images.
How can I store the 8-bit grayscale image into a PPM file without expanding
its bit-depth? Thanks.


Thomas Richter

2005-02-14, 8:55 am

Hi,

> I=imread('lena.bmp');
> imwrite(I,'temp1.ppm');
> %encode
> !jasper -f temp1.ppm -F lena.jp2 -T jp2 -O rate=0.01
> %decode
> !jasper -f lena.jp2 -F temp2.ppm -T pnm
> J=imread('temp2.ppm');


> Now the uncompressed image J becomes 32-bit RGB image instead of a 8-bit
> grayscale image. It seems the PPM file can only represent 32-bit RGB images.
> How can I store the 8-bit grayscale image into a PPM file without expanding
> its bit-depth?


PPM files are 24 bit color images, and BMP files typically are color images
as well. Thus, to be sure to do the right thing:

a) Make sure your BMP input image *is* grey scale. That means, the bmp
header has to classify this image as *palette image* with 256 levels of
grey. Otherwise, it is just an RGB image using only grey colors. Use an
image manipulation program to store the data as greyscale otherwise, e.g.
gimp or xv. Recommended grey-scale format would be pgm (a pnm variant).
Few programs are able to write b&w bmp images because they actually use
a different (not-so-common) encoding, and I'm not sure either whether
jasper would then be able to read these images.

b) I don't know whether this is jasper specific, but the suffix "ppm"
indicates color images. What you want to look at are "pgm" images.

So long,
Thomas
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com