本文整理汇总了C++中PNM::pixel方法的典型用法代码示例。如果您正苦于以下问题:C++ PNM::pixel方法的具体用法?C++ PNM::pixel怎么用?C++ PNM::pixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PNM
的用法示例。
在下文中一共展示了PNM::pixel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: transform
PNM* HoughRectangles::transform()
{
PNM* img = CornerHarris(image).transform();
for (int i = 0; i < img->width(); i++)
{
for (int j = 0; j < img->height(); j++)
{
QColor color = QColor::fromRgb(img->pixel(i, j));
if (color.black() != 255)
{
img = remove(i, j, i, j, img);
}
}
}
std::vector<std::pair<int, int>> points;
for (int i = 0; i < img->width(); i++)
{
for (int j = 0; j < img->height(); j++)
{
QColor color = QColor::fromRgb(img->pixel(i, j));
if (color.black() != 255)
{
points.push_back(std::make_pair(i, j));
}
}
}
for (int i = 0; i < points.size(); i++)
{
std::vector<std::pair<int, int>> corners = check_quadrat(points.at(i), img);
if (corners.size() == 4)
{
img = drawQuadrat(corners, img);
}
}
return img;
}
示例2: transform
PNM* MapHorizon::transform()
{
int width = image->width(),
height = image->height();
double scale = getParameter("scale").toDouble();
int sun_alpha = getParameter("alpha").toInt();
int dx, dy;
switch (getParameter("direction").toInt())
{
case NORTH: dx = 0; dy = -1; break;
case SOUTH: dx = 0; dy = 1; break;
case EAST: dx = 1; dy = 0; break;
case WEST: dx = -1; dy = 0; break;
default:
qWarning() << "Unknown direction!";
dx = 0;
dy = -1;
}
PNM* newImage = new PNM(width, height, QImage::Format_Indexed8);
PNM* mapHeight = MapHeight(image).transform();
for(int i=0; i<width; i++)
for(int j=0; j<height; j++)
{
double alpha = 0;
int current_h = qRed(mapHeight->pixel(i, j));
for(int k = i+dx, l = j+dy; k < width && l < height && k >= 0 && l >= 0; k = k+dx, l = l+dy)
{
int ray_h = qRed(mapHeight->pixel(k,l));
if(current_h < ray_h)
{
double dist = sqrt(pow(k - i, 2) + pow(l - j, 2)) * scale;
double ray_alpha = atan((ray_h - current_h) / dist);
if(ray_alpha > alpha) alpha = ray_alpha;
}
}
double delta = alpha - sun_alpha * M_PI/180;
if(delta > 0)
{
newImage->setPixel(i, j, cos(delta) * 255);
}
else
{
newImage->setPixel(i, j, 255);
}
}
return newImage;
}