Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Can't compute power of float point

Hi, i have a Mat<float> image. After making the fourier spectrum of the image i have to apply a Butterworth filter of equation: H(u,v)=1/(1+[D(u,v)/250]⁴) where

D(u,v)=[(u-(image.col/2)²)+(v-(image.row/2)²))]^0.5

as you can see there are many power function in the image. My image is a Mat_<float>, so i suppose that the result of each computation should be a float, so i can change each pixel of the image with the result of the equation. Unfortuntely my code seems not to work , i have problems with the function pow..seems to work only for certain type.. here is my code

Mat_<float> filter;
    moon_spectrum.copyTo(filter);//giving the same dimentions

    for (int i=0;i<filter.cols;i++)
    {
        for (int j=0;j<filter.rows;j++)
        {
            float d_x=pow((i-filter.cols),2);
            float d_y=pow((j-filter.rows),2);
            float d=pow((d_x+d_y),2);
            float d_fin=pow((d/250),4);
            filter.at<float>(i,j)=1/(1+d_fin);



        }
click to hide/show revision 2
retagged

Can't compute power of float point

Hi, i have a Mat<float> image. After making the fourier spectrum of the image i have to apply a Butterworth filter of equation: H(u,v)=1/(1+[D(u,v)/250]⁴) where

D(u,v)=[(u-(image.col/2)²)+(v-(image.row/2)²))]^0.5

as you can see there are many power function in the image. My image is a Mat_<float>, so i suppose that the result of each computation should be a float, so i can change each pixel of the image with the result of the equation. Unfortuntely my code seems not to work , i have problems with the function pow..seems to work only for certain type.. here is my code

Mat_<float> filter;
    moon_spectrum.copyTo(filter);//giving the same dimentions

    for (int i=0;i<filter.cols;i++)
    {
        for (int j=0;j<filter.rows;j++)
        {
            float d_x=pow((i-filter.cols),2);
            float d_y=pow((j-filter.rows),2);
            float d=pow((d_x+d_y),2);
            float d_fin=pow((d/250),4);
            filter.at<float>(i,j)=1/(1+d_fin);



        }