1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| IplImage *src=cvLoadImage("PolyU_014_S_03.bmp");
CvSize size_src=cvSize(src->width,src->height);
IplImage *PlaneB=cvCreateImage(size_src,src->depth,1);
IplImage *PlaneG=cvCreateImage(size_src,src->depth,1);
IplImage *PlaneR=cvCreateImage(size_src,src->depth,1);
cvCvtPixToPlane(src,PlaneB,PlaneG,PlaneR,0);
IplImage *dst=cvCreateImage(size_src,IPL_DEPTH_8U,1);
unsigned char pixel_mask[3];
for(i=0;i<PlaneB->height;i++)
{
for(int j=0;j<PlaneB->width;j++)
{
iplGetPixel(PlaneB,j,i,&pixel_mask[0]);
iplGetPixel(PlaneG,j,i,&pixel_mask[1]);
iplGetPixel(PlaneR,j,i,&pixel_mask[2]);
samples[nvector]=(CvVect32f)malloc(3*sizeof(float));
samples[nvector][0]=(float)pixel_mask[0];
samples[nvector][1]=(float)pixel_mask[1];
samples[nvector][2]=(float)pixel_mask[2];
nvector++;
} |
Partager