1 | initial version |
int main (int argc, char** argv)
{
Mat img=imread("D:\\32.png",CV_LOAD_IMAGE_COLOR);
Mat A = Mat::zeros(img.size(),img.type());
namedWindow("Display window");
namedWindow("threshold");
imshow("Display window",img);
for (int i = 0; i < img.size().height; ++i)
{
for(int j = 0; j < img.size().width; ++j)
{
A.at<Vec3b>(i,j) = img.at<Vec3b>(i,j);
}
}
imwrite("D:\\etc1.png",A);
imshow("threshold",A);
waitKey(0);
}
2 | No.2 Revision |
Below code work for me on your image
int main (int argc, char** argv)
{
Mat img=imread("D:\\32.png",CV_LOAD_IMAGE_COLOR);
Mat A = Mat::zeros(img.size(),img.type());
namedWindow("Display window");
namedWindow("threshold");
imshow("Display window",img);
for (int i = 0; i < img.size().height; ++i)
{
for(int j = 0; j < img.size().width; ++j)
{
A.at<Vec3b>(i,j) = img.at<Vec3b>(i,j);
}
}
imwrite("D:\\etc1.png",A);
imshow("threshold",A);
waitKey(0);
}
input image
output image
3 | No.3 Revision |
Below code work for me on your imageimage , it looks your performing which are not compulsory to perform in copying image using pixel operation
int main (int argc, char** argv)
{
Mat img=imread("D:\\32.png",CV_LOAD_IMAGE_COLOR);
Mat A = Mat::zeros(img.size(),img.type());
namedWindow("Display window");
namedWindow("threshold");
imshow("Display window",img);
for (int i = 0; i < img.size().height; ++i)
{
for(int j = 0; j < img.size().width; ++j)
{
A.at<Vec3b>(i,j) = img.at<Vec3b>(i,j);
}
}
imwrite("D:\\etc1.png",A);
imshow("threshold",A);
waitKey(0);
}
input image
output image
4 | No.4 Revision |
Below code work for me on your image , it looks your performing functions which are not compulsory to perform in copying image using pixel operation
int main (int argc, char** argv)
{
Mat img=imread("D:\\32.png",CV_LOAD_IMAGE_COLOR);
Mat A = Mat::zeros(img.size(),img.type());
namedWindow("Display window");
namedWindow("threshold");
imshow("Display window",img);
for (int i = 0; i < img.size().height; ++i)
{
for(int j = 0; j < img.size().width; ++j)
{
A.at<Vec3b>(i,j) = img.at<Vec3b>(i,j);
}
}
imwrite("D:\\etc1.png",A);
imshow("threshold",A);
waitKey(0);
}
input image
output image