Intel® Integrated Performance Primitives
Community support and discussions relating to developing high-performance vision, signal, security, and storage applications.
6634 Discussions

JPEG write fails after rotating image 90 degrees

alessandroferrucci
115 Views
Hello,
I'm reading a grayscale JPEG. Rotating it 90 degrees, and writing the rotated image out to a new image.

Below is code:

[bash]
ExcStatus         res;
CIppImage         image;
CStdFileInput     fi;
CStdFileOutput    fo;

if(!BaseStream::IsOk(fi.Open(source.c_str()))){
   cout << "STREAM ERROR ON INPUT IMAGE" << endl;
   return -1;
}

res = DecodeImage(fi, image, &decTime);

CIppImage rimage( image.Height(), image.Width(), image.NChannels(), image.Precision() );

IppiSize src_size     = { image.Width(), image.Height() };
	IppiRect src_rect = { 0, 0, image.Width(), image.Height() };
	IppiRect dst_rect = { 0, 0, rimage.Width(), rimage.Height() };
	double xShift = ((double)image.Width() ) / 2.0;
	double yShift = ((double)image.Height()) / 2.0;

IppStatus rotStatus;

rotStatus = ippiRotateCenter_8u_C1R ( 
			image.DataPtr(),
			src_size,
			image.Step(),
			src_rect,
			rimage.DataPtr(),
			rimage.Step(),
			dst_rect,
			90.0,
			xShift,
			yShift,
			IPPI_INTER_NN
			);

res = EncodeImage(rimage, fo, &encTime);

if(!IsOk(res)){
   cerr << "ENCODE IMAGE ERROR " << endl;
   return 1;
}else{
   cout << "ENCODE IMAGE SUCCESS ( " << encTime << " MSEC )" << endl;
}

[/bash]
It always returns with "ENCODE IMAGE ERROR"

using UIC encoding.

The encoding function works fine if I don't rotate the image.

Any ideas why this would be happening? (ignore the markup in the source code viewer.. not sure why the forum web page added that)

Thanks!
0 Kudos
1 Reply
Vladimir_Dudnik
Employee
115 Views
Hello,

Have no idea what might be wrong, but you should be able to trace execution in debugger (UIC sample is available in sources)?

Note, to roate image to 90 degree you may want to use IPP Mirror or Transpose functions which should be much faster then general case ratation.

Regards,
Vladimir

Reply