Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV how to Retain Icon Property

I have an icon image like this,

Source:-

image description

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

image description

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

click to hide/show revision 2
retagged

updated 2013-10-01 03:23:16 -0600

berak gravatar image

OpenCV how to Retain Icon Property

I have an icon image like this,

Source:-

image description

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

image description

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

OpenCV how to Retain Icon Property

I have an icon image like this,

Source:-

image description

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

image description

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

OpenCV how to Retain Icon Property

I have an icon image like this,

Source:-

image description

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

image description

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

OpenCV how to Retain Icon Property

I have an icon image like this,

Source:-

image description

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

image description

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

OpenCV how to Retain Icon Property

I have an icon image like this,

Source:-

image description

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

image description

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