本文整理汇总了C++中GImage::gradientMagnitudeImage方法的典型用法代码示例。如果您正苦于以下问题:C++ GImage::gradientMagnitudeImage方法的具体用法?C++ GImage::gradientMagnitudeImage怎么用?C++ GImage::gradientMagnitudeImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GImage
的用法示例。
在下文中一共展示了GImage::gradientMagnitudeImage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: regionMask
void G2DRegionGraph::makeWatershedRegions(const GImage* pImage)
{
GImage gradMag;
gradMag.gradientMagnitudeImage(pImage);
GImage* pMask = regionMask();
int x, y, u, v, du, dv;
size_t region, other;
for(y = 0; y < (int)pImage->height(); y++)
{
for(x = 0; x < (int)pImage->width(); x++)
{
u = x;
v = y;
do
{
region = pMask->pixel(u, v);
if(region != 0xffffffff)
break;
PickTobogganDirection(&gradMag, u, v, &du, &dv);
u += du;
v += dv;
} while(du != 0 || dv != 0);
if(region == 0xffffffff)
{
region = addRegion();
setMaskPixel(u, v, pImage->pixel(u, v), region);
}
u = x;
v = y;
do
{
if(pMask->pixel(u, v) != 0xffffffff)
break;
setMaskPixel(u, v, pImage->pixel(u, v), region);
PickTobogganDirection(&gradMag, u, v, &du, &dv);
u += du;
v += dv;
} while(du != 0 || dv != 0);
if(x > 0)
{
other = pMask->pixel(x - 1, y);
if(other != region)
makeNeighbors(region, other);
}
if(y > 0)
{
other = pMask->pixel(x, y - 1);
if(other != region)
makeNeighbors(region, other);
}
}
}
}