mercredi 24 décembre 2014

random generator and openCV in c++

This is my function for generating random white noise in openCV and c++. Can anyone point me to the real problem ?



int i,j;

int h = image.cols;
int w = image.rows;

for(int k=0; k<n ; k++)
{

i = Random(h);
j = Random(w);


if(image.channels() == 1)
{
image.at<uchar>(j,i) = 255;
}
else if (image.channels() == 3)
{
image.at<cv::Vec3b>(j,i)[0] = 255;
image.at<cv::Vec3b>(j,i)[1] = 255;
image.at<cv::Vec3b>(j,i)[2] = 255;

}

}


![enter image description here][1]





Aucun commentaire:

Enregistrer un commentaire