function thresholding

asked 2017-08-08 11:42:44 -0600

barramibac gravatar image

updated 2017-08-08 11:45:16 -0600

 #include <opencv2/highgui/highgui.hpp>
  #include <opencv2/core/core.hpp>
  #include <opencv2/core/mat.hpp>
  #include <opencv2/imgproc/imgproc.hpp>
  #include<iostream>
  #include<math.h>

using namespace std;
using namespace cv;
float sig(float x)
{
float s;
if(x==0) { s=0;}
else if(x>0) {s=1;}
else(x<0) {s=-1;}
return s;
}
void threshold(Mat src,float T)
{
    Mat dst;


for(int x=0;x<src.rows;x++)
                {
                    for(int y=0;y<src.cols;y++)
                    {
float a=src.at<float>(x,y);
float b=dst.at<float>(x,y);

    if(a>T)
    {
        b=sig(a)*(fabs(a)-T);
    }
    else
    {
      b=0;
    }
    return b;
}

}
}
 int main()
{
system("clear");

 Mat src=imread("/home/jamal/Bureau/lena.jpg",0);
Mat dst;
float T=1;
threshold(src,T);   

    namedWindow("Picture", CV_WINDOW_AUTOSIZE); 
       imshow("Picture", src); 
          namedWindow("picf", CV_WINDOW_AUTOSIZE); 
       imshow("Picf", dst); 
       waitKey(); 

    return 0;
}

I can't compile this code.what is the error I have committed?

edit retag flag offensive close merge delete

Comments

@sturkmen I work with a soft thresholding function

barramibac gravatar imagebarramibac ( 2017-08-08 12:28:20 -0600 )edit