Hello,
I'm using IPP 6.1.2.041.
I need to convert RGB image to HSV color model. I have a simple 2 pixel image to test, first pixel is RGB 0,0,254 (near pure blue), second pixel is
0,255,1 (near pure green).
First Pixel in HSV should be 240,100,100, but IPP sets first pixel components to 170,255,254.
Here is code for the simple test program I wrote (ReadImageJPEGHighLevel basically just calls ReadImageJPEG in jpeg.cpp that is included with IPP decoder package).
1) First is the JPEG reading method:
JERRCODE ReadImageJPEGHighLevel ( CIppImage& image, std::string fileName ){ JERRCODE jerr; image.Color(JC_UNKNOWN); CStdFileInput in; UIC::BaseStream::TStatus status; status = in.Open(fileName.c_str()); PARAMS_JPEG m_param_jpeg; m_param_jpeg.nthreads = 2; m_param_jpeg.dct_scale = JD_1_1; m_param_jpeg.use_qdct = 1; jerr = ReadImageJPEG(in, m_param_jpeg, image); in.Close(); return jerr; }
2: Here is the sample test program that performs conversion:
string fileName= "C:\bluegreen.jpg"; JERRCODE jerr; CIppImage imageRGB; CIppImage imageHSV; cout << "filename: "<< fileName << endl; jerr=ReadImageJPEGHighLevel ( imageRGB, fileName ); if(jerr!=JPEG_OK){ cerr << "read image failed"<<endl; }else{ cout << "read image success"<<endl; CIppImage imageHSV( imageRGB.Width(), imageRGB.Height(), imageRGB.NChannels(), imageRGB.Precision() ); IppStatus hsvConversionStatus = ippiRGBToHSV_8u_C3R( imageRGB.DataPtr(), imageRGB.Step(), imageHSV.DataPtr(), imageHSV.Step(), imageHSV.Size() ); if( hsvConversionStatus == ippStsNoErr ){ Ipp8u* colorDataRGB = imageRGB.DataPtr(); Ipp8u* colorDataHSV = imageHSV.DataPtr(); cout << "RGB(0,0) = "<< (int)colorDataRGB[0] << ","<< (int)colorDataRGB[1] << ","<< (int)colorDataRGB[2] << endl; cout << "HSV(0,0) = "<< (int)colorDataHSV[0] <<","<<(int)colorDataHSV[1]<<","<<(int)colorDataHSV[2]<<endl; }else{ cout << "RGB->HSV Conversion error"<<endl; } } imageRGB.Free(); imageHSV.Free();
I have included sample JPG in post.
Thank you,
Alessandro Ferrucci