After wasting a lot of time over trying to manipulate the individual pixels of an image, Rushi pointed out that the image was not a float image but rather had unsigned char elements. The following is the code (without the header files included) and which had the effect on "sg (25).jpg" as shown above:
IplImage *img=0; //the pointer is assigned value zero;
//thus it points to nothing untill something is loaded
int main(void){
img=cvLoadImage("sg (25).jpg");
if(img==0){
fprintf(stderr,"Cannot load file.");
getchar();
return(1);
}
printf("%u",img->depth);
getchar();
int i,j,height,width, step, channels;
height=img->height;
width=img->width;
channels=img->nChannels;
step=img->widthStep;
unsigned char *data=(unsigned char *)img->imageData;
for(i=30;i<90;i++){ j="30;j<120;j++){" class="descname">cvSaveImage(const char* filename, const CvArr* image) is also demonstrated in the above example.
This entry was posted
on Sunday, October 11, 2009
at 2:08 PM
and is filed under
My Programming Practice
. You can follow any responses to this entry through the
comments feed
.