0

大家好,我有一个运行时错误,我不知道数字输入是否错误?我想我会寻求帮助

也许有些东西超出了范围t[x]=gmin*pow(gmax/gmin, factor);??

void image::hhyper(const char* path)
{
    IplImage* img = cvLoadImage(path);
    IplImage* out = cvCreateImage( cvGetSize(img), IPL_DEPTH_8U, 3 );

    h = img->height;
    w = img->width;
    step = img->widthStep;
    channels = img->nChannels;
    data = (uchar *)img->imageData;
    newdata = (uchar *)out->imageData;

    int gmin=20;
    int gmax=200;

    double sum=0;
    double t[256];
    double factor;

    for(int a=0; a<h; a++){
        for(int b=0; b<w; b++){
            for(int k=0; k<3; k++){
                newdata[i*step+j*channels+k]=data[i*step+j*channels+k];
            }
        }
    }

    for(int x=0; x<256; x++){
       sum+=table[x];
       factor=sum/(h*w);
       t[x]=gmin*pow(gmax/gmin, factor);
    }

    for(int a=0; a<h; a++){
        for(int b=0; b<w; b++){
            for(int k=0; k<3; k++){
                newdata[i*step+j*channels+k]=t[(int)data[i*step+j*channels+k]];
       }
        }
    }

    cvNamedWindow("out");
    cvNamedWindow("in");
    cvShowImage("in",img);
    cvShowImage("out",out);
    system("pause");
}

这是我的标题

  class image
 {
public:
image();
const char* path;
void hhyper(const char*);
void histo(const char*);
IplImage* DrawHistogram(CvHistogram *hist, float scaleX, float scaleY);
int h,w,step,channels,i,j,;
int table[256];
uchar *data, *newdata;
4

1 回答 1

0

也许这

newdata[i*step+j*channels+k] = t[(int)data[i*step+j*channels+k]];

应该

newdata[i*step+j*channels+k] = t[(uchar)data[i*step+j*channels+k]];
于 2012-11-19T05:07:16.050 回答