1 | initial version |
Now that your question is clear, I can give you an answer:
cv::RNG rng(cv::getTickCount()); // for having each time different numbers
int lo = 16;
int hi = 150; // maximum distance between points: sqrt(3800*2800/300)=188
std::vector< uchar > distantPixels;
cv::Point currentPos(0,0);
while (currentPos.y < image.rows)
{
while (currentPos.x < image.cols)
{
currentPos.x += rng.uniform(lo, hi);
distantPixel.push_back(image.ptr< uchar >(currentPos.y)[currentPos.x]);
}
currentPos.x = 0;
currentPos.y += rng.uniform(lo, hi);
}
PS: I did not tested it, sorry if it has some bugs, but you get the idea ;)
2 | No.2 Revision |
Now that your question is clear, I can give you an answer:
cv::RNG rng(cv::getTickCount()); // for having each time different numbers
int lo = 16;
int hi = 150; max(16, sqrt(image.cols * image.rows / 300) - 1); // maximum distance between points: sqrt(3800*2800/300)=188
points
std::vector< uchar > distantPixels;
cv::Point currentPos(0,0);
while (currentPos.y < image.rows)
{
while (currentPos.x < image.cols)
{
currentPos.x += rng.uniform(lo, hi);
distantPixel.push_back(image.ptr< uchar >(currentPos.y)[currentPos.x]);
distantPixel.push_back(image.ptr< uchar >(currentPos.y)[currentPos.x]);
currentPos.x += rng.uniform(lo, hi);
}
currentPos.x = 0;
currentPos.y += rng.uniform(lo, hi);
}
PS: I did not tested it, sorry if it has some bugs, but you get the idea ;)