Reputation: 11917
I'm looking for the C++ equivalent of cvConvertImage
in OpenCV.
cvConvertImage(const CvArr* src, CvArr* dst, int flags=0)
Specifically, I have a cv::Mat
image with the red and blue channels flipped, and I wish to swap them back. In cvConvertImage you can do this by setting flags to be CV_CVTIMG_SWAP_RB
.
Upvotes: 1
Views: 6027
Reputation: 56
Late answer, but you can use cv::cvtColor(...)
with option CV_BGR2RGB
if you want to swap R
and B
.
If you want more complex operations mixchannels
is the way to go
Upvotes: 4
Reputation: 93410
I don't know any method in the C++ interface to do this, but if you don't want to do a manual swap like @Martin suggested, you can still convert cv::Mat
to IplImage
and use cvConvertImage
to do the job for you:
// Load image into: cv::Mat mat_img;
...
// Convert cv::Mat to IplImage
IplImage ipl_img = mat_img;
cvConvertImage(&ipl_img , &ipl_img , CV_CVTIMG_SWAP_RB);
Upvotes: 0
Reputation: 96109
TO access individual pixels see Fastest way to extract individual pixel data?
Then it's just a matter of swapping the red / blue values
Upvotes: 0