双曲最终概率密度函数 Opencv

Hyperbolic final probability density function Opencv

本文关键字:概率密度函数 Opencv      更新时间:2023-10-16

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

也许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;

也许这个

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]];