My company still used old IPL (IPL_DEPTH_1U functions) , and let me change IPL 1bit function to IPP for build x64 software.
After used ippiBinToGray_1u8u_C1R------>ipp functions------>ippiGrayToBin_8u1u_C1R, I find the result are different with IPL.
So, I do a test and find some difference. I find old IPL 1 bit functions,gray to bin, convert 8 byte to 1 byte with the older"high bit to low bit",
as opposed to IPP's ippiGrayToBin_8u1u.
The test code is:
/////////////////////////////////////////////////////////code begin////////////////////////////////////////////////////////////////////
Ipp8u bitonalImage[8] = { 0 }; // for a 32x2 image
bitonalImage[0] = 1; // 00000001 high bit->low bit;
bitonalImage[1] = 2; // 00000010
bitonalImage[2] = 4; // 00000100
bitonalImage[3] = 8; // 00001000
bitonalImage[4] = 16; // 00010000
bitonalImage[5] = 32; // 00100000
bitonalImage[6] = 64; // 01000000
bitonalImage[7] = 128; // 10000000
Ipp8u grayImageIPP[64] = { 0 };
ippiBinToGray_1u8u_C1R(bitonalImage, 4, 0, grayImageIPP, 32, { 32, 2 }, 0, 255);
Ipp8u bitonalImageIPP[8] = { 0 };
ippiGrayToBin_8u1u_C1R(grayImageIPP, 32, bitonalImageIPP, 4, 0, { 32, 2 }, 1);
IplImage *srcImage = iplCreateImageHeader(
1, // number of channels
0, // no alpha channel
IPL_DEPTH_8U, // data of byte type
"Gray", // color model
"Gray", // color order
IPL_DATA_ORDER_PIXEL, // channel arrangement
IPL_ORIGIN_TL, // top left orientation
IPL_ALIGN_DWORD, // 4 bytes align
32, // image width
2, // image height
NULL, // no ROI
NULL, // no mask ROI
NULL, // no image ID
NULL); // not tiled
if (NULL == srcImage)
return 0;
srcImage->imageData = (char *)grayImageIPP;
Ipp8u bitonalImageIPL[8] = { 0 };
IplImage *dstImage = iplCreateImageHeader(
1, // number of channels
0, // no alpha channel
IPL_DEPTH_1U, // data of byte type
"Gray", // color model
"Gray", // color order
IPL_DATA_ORDER_PIXEL, // channel arrangement
IPL_ORIGIN_TL, // top left orientation
IPL_ALIGN_DWORD, // 4 bytes align
32, // image width
2, // image height
NULL, // no ROI
NULL, // no mask ROI
NULL, // no image ID
NULL); // not tiled
if (NULL == dstImage)
return 0;
dstImage->imageData = (char *)bitonalImageIPL;
iplThreshold(srcImage, dstImage, 1);
iplDeallocate(srcImage, IPL_IMAGE_HEADER);
iplDeallocate(dstImage, IPL_IMAGE_HEADER);
/////////////////////////////////////////////////////code end////////////////////////////////////////////////////////////////
The result of bitonalImageIPP is:
bitonalImage[0] = 1; // 00000001 high bit->low bit;
bitonalImage[1] = 2; // 00000010
bitonalImage[2] = 4; // 00000100
bitonalImage[3] = 8; // 00001000
bitonalImage[4] = 16; // 00010000
bitonalImage[5] = 32; // 00100000
bitonalImage[6] = 64; // 01000000
bitonalImage[7] = 128; // 10000000
As the same with the bitonalImage.
The result of bitonalImageIPL is:
bitonalImageIPL[0] = 128; // 10000000 high bit------>low bit
bitonalImageIPL[1] = 64; // 01000000
bitonalImageIPL[2] = 32; // 00100000
bitonalImageIPL[3] = 16; // 00010000
bitonalImageIPL[4] = 8; // 00001000
bitonalImageIPL[5] = 4; // 00000100
bitonalImageIPL[6] = 2; // 00000010
bitonalImageIPL[7] = 1; // 00000001
Are all IPL 1 bit functions having these difference?