Hi , i m using VS2010 i m trting to make a gray image more bright , the code did compile normaly but no change in the seconde picture , and an error message ( undhadled exeception .. .. ) showed up after that the execute is done showed up here is a peace of my code :
int main(int argc, _TCHAR* argv[])
{
IplImage *img = cvLoadImage("mra.jpg");
if (!img) {
printf("Error: Couldn't open the image file.\n");
return 1;
}
//IplImage* new_image = getlargersize(img);
double Min , Max ;
Min = Max = 0 ;
Max_Min (img , &Min , &Max);
cout<<"the max value in the picture is :"<<Min<<" and the minimum value is :"<<Max<<endl ;
IplImage* img2 = eclaircir(Min ,Max ,img);
cvNamedWindow("Image:", CV_WINDOW_AUTOSIZE);
cvNamedWindow("Image2:", CV_WINDOW_AUTOSIZE);
cvShowImage("Image2:", img2);
cvShowImage("Image:", img);
cvWaitKey(0);
cvDestroyWindow("Image2:");
cvDestroyWindow("Image:");
cvReleaseImage(&img2);
cvReleaseImage(&img);
return 0;
}
void Max_Min(IplImage* temp , double *min , double *max ){
CvScalar pix ;
for (int i = 0 ; i < temp->height ; i++){
for (int j = 0 ; j < temp->width ; j++){
pix = cvGet2D(temp , i , j);
if ( pix.val[0] >= *max ){
*max = pix.val[0];
}
if ( pix.val[0] <= *min){
*min = pix.val[0];
}
}
}
}
IplImage* eclaircir (double min , double max , IplImage* image){
double temp = max - min ;
CvScalar pix ;
for (int i = 0 ; i < image->height ; i++){
for (int j = 0 ; j < image->width ; j++){
pix = cvGet2D(image , i , j);
pix.val[0] = ( pix.val[0] - min)*255 ;
pix.val[0] = pix.val[0]/temp ;
cvSet2D(image , i , j , pix );
}
}
return image ;
}
thanks