I have an icon image like this,
Source:-
And I need to convert this image to red I am using the following code.
Mat src=imread("green_button.png");
for(int i=0;i<src.rows;i++){
for(int j=0;j<src.cols;j++){
Vec3b pixel = src.at<Vec3b>(i, j);
int tmp=pixel[1];
pixel[1]=pixel[2];
pixel[2]=tmp;
src.at<Vec3b>(i,j) = pixel;
}
}
imwrite("red_button.png",src);
But the result look like distorted at side.
Result:-
I am getting the distorted icon image even if I directly save the image after imread()
. How can I retain the result as source while using OpenCV ?. Actually I want use these icon for my android application.
Thanks....