Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
6759 Discussions

Best way to Encode a 16 bit image to Grayscale jpeg image with JPEG_LOSSLESS option

Dhruba_Mahanta
Beginner
403 Views

Hi,

I am new to IPP UIC codecs. My requirement is to encode a 16 bit pixel image to grayscale jpeg format. I need to maintain high quality with lossless compression.

Here is whatI am doing:

***********************************************************

CIppImage imageIn;
PARAMS_JPEG param ;
param.nthreads = 1;
param.quality = 100;
param.color = IC_GRAY;
param.mode = JPEG_LOSSLESS;
param.sampling = IS_444;
param.restart_interval = 0;
param.huffman_opt = 0;
param.point_transform = 0;
param.predictor = 1;
param.dct_scale = JD_1_1;
param.comment_size = 0;

CMy16BitImage sourceImg;
//Get the source image
int nHeight(sourceImg.Height()), nWidth(sourceImg.Width());
unsigned short* pSourceImgBuff = sourceImg.GetImageBuffer();
unsigned char* pImageBuffer = new unsigned char[nHeight*nWidth];

//Construct the destination image buffer
unsigned char* pTempBuff = pSourceImgBuff;
for(int i = 0; i < nHeight; ++i)
{
for(int j = 0; j < nWidth; ++j)
{
*pTempBuff = *pSourceImgBuff ;
++pTempBuff ;
++pSourceImgBuff ;
}
}

imageIn.Attach(nHeight, nWidth, 1, 8, (void*)pSourceImgBuff, 0);
CStdFileOutput foJPEG;
if(!BaseStream::IsOk(foJPEG.Open("C:\\\\testOut.jpeg")))
return 1;

imageIn.Sampling(IS_444);
imageIn.Color(IC_GRAY);
SaveImageJPEG(imageIn, param, foJPEG);

*************************************************************

Result: JPEG Image has generated but unable to view in any image viewer including mspaint.
Format is not recognised and errors out.

But if I change the mode as below, I can see some image.
param.mode = JPEG_BASELINE

What am I looking for:
1. Some help to correct the above code so that the image can be viewed.
2. The best param settings for GRAYSCALE LOSSLESS encoding
3.CanIdirectly attach the 16 bit image buffer to CIppImage without converting to a unsigned char*. I know that for this to happen the precesion param should be 16.

Thanks in advance.
Regards
Dhruba

0 Kudos
1 Reply
Chao_Y_Intel
Moderator
403 Views
Hi Dhruba,

It looks the same problem with this post: http://software.intel.com/en-us/forums/showthread.php?t=84143
we can discuss at that post.

Thanks,
Chao
0 Kudos
Reply