///
//Parameters:
// pImg: input image // flags: IMAGECAMEO_0 : sign sculputre in image processing // IMAGECAMEO_1 : sign engrave in image processing /// IplImage *ImageEffect::ImageCameo(IplImage pImg, int flags) { if(!pImg){ printf("Errror: Load File in ImageCameo(.).\n"); exit(EXIT_FAILURE); } nWidth = pImg->width; nHeight = pImg->height; pImgdata =(uchar) pImg->imageData; pImgChannels = pImg->nChannels;step = pImg->widthStep;
int temp0,temp1,temp2;for(int i =0; i<nWidth-1; i++){
for( int j =0; j<nHeight-1;j++){ if(pImgChannels ==1){ // gray image if(flags ==IMAGECAMEO_0){ //sculputre processing temp0 = pImgdata[(j+1)step+(i+1)pImgChannels]- pImgdata[jstep+ipImgChannels]+128; } if(flags ==IMAGECAMEO_1){ //engrave processing temp0 = pImgdata[jstep+ipImgChannels]- pImgdata[(j+1)step+(i+1)pImgChannels] +128; } if(temp0>255) pImgdata[jstep+ipImgChannels] = 255; if(temp0<0) pImgdata[jstep+ipImgChannels] = 0; else pImgdata[jstep+ipImgChannels] = temp0; } if(pImgChannels ==3){ // color image if(flags == IMAGECAMEO_0){ //sculputre processing temp0 = pImgdata[(j+1)step+(i+1)pImgChannels]- pImgdata[jstep+ipImgChannels] +128; temp1 = pImgdata[(j+1)step+(i+1)pImgChannels+1]- pImgdata[jstep+ipImgChannels+1] +128; temp2 = pImgdata[(j+1)step+(i+1)pImgChannels+2]- pImgdata[jstep+ipImgChannels+2] +128; } if(flags == IMAGECAMEO_1){ //engrave processing temp0 = pImgdata[jstep+ipImgChannels]- pImgdata[(j+1)step+(i+1)pImgChannels]+128; temp1 = pImgdata[jstep+ipImgChannels+1]- pImgdata[(j+1)step+(i+1)pImgChannels+1]+128; temp2 = pImgdata[jstep+ipImgChannels+2]- pImgdata[(j+1)*step+(i+1)*pImgChannels+2]+128; }if(temp0>255) pImgdata[j*step+i*pImgChannels] = 255; if(temp0<0) pImgdata[j*step+i*pImgChannels] = 0; else pImgdata[j*step+i*pImgChannels] = temp0; if(temp1>255) pImgdata[j*step+i*pImgChannels+1] = 255; if(temp1<0) pImgdata[j*step+i*pImgChannels+1] = 0; else pImgdata[j*step+i*pImgChannels+1] = temp1; if(temp2>255) pImgdata[j*step+i*pImgChannels+2] = 255; if(temp2<0) pImgdata[j*step+i*pImgChannels+2] = 0; else pImgdata[j*step+i*pImgChannels+2] = temp2; } }
}
return pImg; }