function soft thresholding
-
this code correct or no? thank you in advance.
#include
#include
#include
#include
#include
#includeusing namespace std;
using namespace cv;
float soft_tresholding(Mat src, float threshold)
{int height=src.rows;
int width=src.cols;
for(int y=0; y < height; y++)
{
for(int x=0; x < width; x++)
{
if (src(y*width+x) > threshold)
src(y*width+x) = src(y*width+x) - threshold;
else if (src(y*width+x) < -threshold)
src(y*width+x) = src(y*width+x) + threshold;
else
src(y*width+x) = 0;
}
}
}
int main()
{
system("clear");Mat src=imread("/home/jamal/Bureau/lena.jpg",0);
Mat dst;
float threshold;
dst=soft_thresholding(src,threshold);namedWindow("Picture", CV\_WINDOW\_AUTOSIZE); imshow("Picture", src); namedWindow("picf", CV\_WINDOW\_AUTOSIZE); imshow("Picf", dst); waitKey(); return 0;
}
-
this code correct or no? thank you in advance.
#include
#include
#include
#include
#include
#includeusing namespace std;
using namespace cv;
float soft_tresholding(Mat src, float threshold)
{int height=src.rows;
int width=src.cols;
for(int y=0; y < height; y++)
{
for(int x=0; x < width; x++)
{
if (src(y*width+x) > threshold)
src(y*width+x) = src(y*width+x) - threshold;
else if (src(y*width+x) < -threshold)
src(y*width+x) = src(y*width+x) + threshold;
else
src(y*width+x) = 0;
}
}
}
int main()
{
system("clear");Mat src=imread("/home/jamal/Bureau/lena.jpg",0);
Mat dst;
float threshold;
dst=soft_thresholding(src,threshold);namedWindow("Picture", CV\_WINDOW\_AUTOSIZE); imshow("Picture", src); namedWindow("picf", CV\_WINDOW\_AUTOSIZE); imshow("Picf", dst); waitKey(); return 0;
}
saidinsan000000000 wrote:
this code correct or no?
But didn't you test it? :confused: Does it compile? Does it work as expected?
-
this code correct or no? thank you in advance.
#include
#include
#include
#include
#include
#includeusing namespace std;
using namespace cv;
float soft_tresholding(Mat src, float threshold)
{int height=src.rows;
int width=src.cols;
for(int y=0; y < height; y++)
{
for(int x=0; x < width; x++)
{
if (src(y*width+x) > threshold)
src(y*width+x) = src(y*width+x) - threshold;
else if (src(y*width+x) < -threshold)
src(y*width+x) = src(y*width+x) + threshold;
else
src(y*width+x) = 0;
}
}
}
int main()
{
system("clear");Mat src=imread("/home/jamal/Bureau/lena.jpg",0);
Mat dst;
float threshold;
dst=soft_thresholding(src,threshold);namedWindow("Picture", CV\_WINDOW\_AUTOSIZE); imshow("Picture", src); namedWindow("picf", CV\_WINDOW\_AUTOSIZE); imshow("Picf", dst); waitKey(); return 0;
}
saidinsan000000000 wrote:
this code correct or no?
It all depends on what you mean by "correct." Are you asking if it is syntactically correct, logically correct, or some other measurement?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles