Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

function thresholding

#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&lt;src.cols;y++)" {="" float="" a="src.at&lt;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?

function thresholding

#include <opencv2 highgui="" highgui.hpp=""> #include <opencv2 core="" core.hpp=""> #include <opencv2 core="" mat.hpp=""> #include <opencv2 imgproc="" imgproc.hpp="">

 #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>

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

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

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");

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?