6/26/2017

cvCvtPixToPlane, cvCvtPlaneToPix -> split, merge / example code and explanation


In previous version of oepncv which used iplImage, these functions are used -> cvCvtPixToPlane and cvCvtPlaneToPix.

This article introduces how this functions are used and what to use in the current version.


1. cvCvtPixToPlane

It is same with split function in current version.
So channels of the input image are seperately stored.

ex) old version
iplImage img; //BGR 3 colors image
iplImage B,G,R;
cvCvtPixToPlane(img, B, G, R, NULL);


ex) current version

Mat img; //BGR 3 colors image
vector< Mat > BGR(3);
split(img, BGR);
BGR[0]; //B Mat
BGR[1]; //G Mat
BGR[2]; //R Mat


2. cvCvtPlaneToPix
It is same with mere function in current version.
So each mat is merged into one Mat.

ex) old version

iplImage B,G,R;
iplImage BGR;
cvCvtPlaneToPix(B, G, R, NULL, BGR);


ex) current version
vector< Mat > BGR(3);
Mat img;
merge(BGR, img);


Thank you.

refer to gpu version split and merge example :
http://study.marearts.com/2014/11/opencv-gpu-3-channel-blur-example.html



No comments:

Post a Comment