dimanche 12 avril 2015

can't change all pixel in image Mat opencv

I have a gray image and I want to change all pixel value in that image into white colors.


I try these code:




int main(int argc, char** argv){

cv::Mat img = cv::imread("C:/mata.jpg");

for (int i = 0; i < img.rows; i++)
{
for (int j = 0; j < img.cols; j++)
{
img.at<uchar>(i, j) = 255;
}
}
imshow("result", img); }


size of image: 37 x 29


I've checked the total of pixel in that loop, and the result, I can access all pixel but not all pixel in image changes into white color (just a quarter of image changes into white colors, the others still have the same color as original image).


Anyone can help me?


Aucun commentaire:

Enregistrer un commentaire