1 | initial version |
The simple way is:
for (int row=0;row<image.height;row++)
{
unsigned char data = image.ptr(row);
for (int col=0;col<image.width;col++)
{
// then use *data for the pixel value
if(image.at<uchar>(i,j) != 0)//do what you want;
}
}
that pixel access isn't the fastest,,, if you need more speed:
for (int row=0;row<image.height;row++)
{
unsigned char data = image.ptr(row);
for (int col=0;col<image.width;col++)
{
// then use *data for the pixel value
if(*data==1)//do what you want;
data++;
}
}
2 | No.2 Revision |
The simple way is:
for (int row=0;row<image.height;row++)
{
unsigned char data = image.ptr(row);
for (int col=0;col<image.width;col++)
{
// then use *data for the pixel value
{
if(image.at<uchar>(i,j) != 0)//do what you want;
}
}
that pixel access isn't the fastest,,, if you need more speed:
for (int row=0;row<image.height;row++)
{
unsigned char data = image.ptr(row);
for (int col=0;col<image.width;col++)
{
// then use *data for the pixel value
if(*data==1)//do what you want;
data++;
}
}
3 | No.3 Revision |
The simple way is:
for (int row=0;row<image.height;row++)
{
unsigned char data = image.ptr(row);
for (int col=0;col<image.width;col++)
{
if(image.at<uchar>(i,j) != 0)//do what you want;
}
}
that pixel access isn't the fastest,,, if you need more speed:
for (int row=0;row<image.height;row++)
{
unsigned char data = image.ptr(row);
for (int col=0;col<image.width;col++)
{
// then use *data for the pixel value
if(*data==1)//do what you want;
data++;
}
}