//the grayscale function:
void pre_process_y (CImageY_Int* CImgY, double* lut_transform, int param, CImageY_Int* CImgY_InOut)
{
int w=CImgY->get_img_width();
int h=CImgY->get_img_height();
int i =0;
int j =0;
unsigned char gray;
// create a cimage buffer
unsigned char *cimageDataPointer;
cimageDataPointer = CImgY->get_img_data();
// create a cimage buffer
unsigned char *cimageDataPointer_inout;
cimageDataPointer_inout = CImgY_InOut->get_img_data();
//copying from CImages
for(unsigned int p=0;p<CImgY->get_img_height();p++)
{
// memory copy
memcpy(cimageDataPointer_inout, cimageDataPointer, CImgY->get_img_width()*1);
// cimageDataPointer jump to next line
cimageDataPointer = cimageDataPointer + CImgY->get_img_width()*1;
// cvImageDataPointer jump to next line
cimageDataPointer_inout = cimageDataPointer_inout+(CImgY_InOut->get_img_width()*1);
}
for(j=0;j<h-1;j++)
{
for(i=0;i<w-1;i++)
{
//int index = (i*h)*1+j*1;
gray= CImgY_InOut->get_pixel(i,j);
CImgY_InOut->set_pixel(i,j, lut_transform[gray]);
}
}
}
//the rgb function:
pre_process_rgb (CImageRGB_Int* CImgRGB, double* lut_transform, int param, CImageRGB_Int* CImgRGB_InOut)
{
int nb_channel =3;
int w=CImgRGB->get_img_width();
int h=CImgRGB->get_img_height();
int i =0;
int j =0;
int k =0;
unsigned long color;
// create a cimage buffer
unsigned char *cimageDataPointer;
cimageDataPointer = CImgRGB->get_img_data();
// create a cimage buffer
unsigned char *cimageDataPointer_inout;
cimageDataPointer_inout = CImgRGB_InOut->get_img_data();
//copying from CImage to CV image
for(unsigned int p=0;p<CImgRGB->get_img_height();p++)
{
// memory copy
memcpy(cimageDataPointer_inout, cimageDataPointer, CImgRGB->get_img_width()*nb_channel);
// cimageDataPointer jump to next line
cimageDataPointer = cimageDataPointer + CImgRGB->get_img_width()*nb_channel;
// cvImageDataPointer jump to next line
cimageDataPointer_inout = cimageDataPointer_inout+(CImgRGB_InOut->get_img_width()*nb_channel);//+nb_channel?
}
for(j=0;j<h-1;j++)
{
for(i=0;i<(w-1);i++)
{
//int index = (i*h)*nb_channel+j*nb_channel;
color= CImgRGB_InOut->get_pixel(i,j);
//pCImgRGB->set_pixel(0, 0, 0x080706);
CImgRGB_InOut->set_pixel(i,j, lut_transform[color]); //ERROR ACCESS VIOLATION
}
}
}
|