Ask Your Question

Revision history [back]

Calculating MyHistogram

Hi all,

I'm trying to do a version of mine to calcolute an Histogram.

I think that the logic is this, but i don't know why it's going in segmentation fault.

Can anyone help me?

    //My Hist
    int Occorrenze[255];
    for(int i=0;i<255;i++)
            Occorrenze[i]=0;

    for(int i=0;i<src.rows;i++)
    {
            for(int j=0;j<src.cols;j++)
            {
                    Occorrenze[src.at<uchar>(i,j)]++;
            }
    }
    Mat MyHist(255,255,CV_8U);
    for(int colonna=0;colonna<255;colonna++)
    {
            int numero=0;
            int flag=0;
            while(numero != Occorrenze[colonna] && flag==0)
            {
                    MyHist.at<uchar>((255-numero),colonna)=255;
                    numero++;
                    if(numero==255)
                            flag=1;
            }
    }
    namedWindow("Hist",WINDOW_AUTOSIZE);
    imshow("Hist",MyHist);

thank u so much