Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Dahan__Dor
Beginner
191 Views

RGBToGray with cv::Mat

Hi Guys,

i'm trying to use ipp to convert rgb image to grayscale one.

 

following code:

        gray_frame = Mat(color_frame.size().width, color_frame.size().height, CV_8UC1);

        IppiSize roi;
        roi.width = color_frame.size().width;
        roi.height = color_frame.size().height;
        Ipp8u* ippRGBPtr = (Ipp8u*)&color_frame.data[0]; // Get pointer to the data
        int ipprgbStep = color_frame.step; // get step value in bytes
        Ipp8u* ippGrayPtr = (Ipp8u*)&gray_frame.data[0]; // Get pointer to the data
        int ippGrayStep = gray_frame.step; // get step value in bytes
        ippiRGBToGray_8u_C3C1R(ippRGBPtr, ipprgbStep, ippGrayPtr, ippGrayStep, roi); // do the color conversion

 

the problem i'm facing is that the image i now fully procced,

when i cv::imshow(gray_frame) i see half of the image. 

what can be the problem?

 

thank you!

0 Kudos
1 Reply
Andrey_B_Intel
Employee
191 Views

Hi Dahan Dor.

I've reproduced your issue.

Swap please width and height in this line

gray_frame = Mat(color_frame.size().width, color_frame.size().height, CV_8UC1) 

with

gray_frame = Mat(color_frame.size().height, color_frame.size().width, CV_8UC1)

Thanks.

 

Reply