本文整理汇总了C++中Pixel::color方法的典型用法代码示例。如果您正苦于以下问题:C++ Pixel::color方法的具体用法?C++ Pixel::color怎么用?C++ Pixel::color使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pixel
的用法示例。
在下文中一共展示了Pixel::color方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processGroup
bool processGroup(Bitmap bitmap, ManagerOfGroups& manager,Pixel pixel) {
std::set<Pixel> processedPixels;
std::vector<Pixel> toDoStack;
std::set<uint32_t> neighbors;
uint32_t groupNumber= manager.getGroupNumber(pixel);
toDoStack.push_back(pixel);
while (!toDoStack.empty()) {
Pixel nextPixel= toDoStack.back();
toDoStack.pop_back();
if (processedPixels.count(nextPixel) == 0) {
if (manager.getGroupNumber(nextPixel) == groupNumber) {
processedPixels.insert(nextPixel);
if (nextPixel.y != 0) {
toDoStack.push_back(nextPixel.highNeighbor());
}
if (nextPixel.x != manager.width - 1) {
toDoStack.push_back(nextPixel.rightNeighbor());
}
if (nextPixel.y != manager.height - 1) {
toDoStack.push_back(nextPixel.lowNeighbor());
}
if (nextPixel.x != 0) {
toDoStack.push_back(nextPixel.leftNeighbor());
}
} else {
if (nextPixel.color() == pixel.color()) {
LOG("Same-color neighbors: (%d %d) and (%d %d), color = %d",nextPixel.x,nextPixel.y,pixel.x,pixel.y,pixel.color());
}
neighbors.insert(manager.getGroupNumber(nextPixel));
}
}
}
std::set<uint32_t>::const_iterator item= neighbors.begin();
if (item == neighbors.end()) {
return true;
}
bool isMaximum= pixel.color() > unpackGroupPixel(bitmap,*item).color();
item++;
for (; item != neighbors.end(); ++item) {
Pixel groupPixel = unpackGroupPixel(bitmap, *item);
bool isNextMaximum= pixel.color() > groupPixel.color();
if (isMaximum != isNextMaximum) {
return false;
}
}
for (std::set<Pixel>::const_iterator item= processedPixels.begin(); item != processedPixels.end(); ++item) {
Pixel pixel= *item;
pixel.setColor(isMaximum ? 255 : 0);
}
return true;
}
示例2: processNeighbor
void processNeighbor(ManagerOfGroups& manager, Pixel pixel, Pixel neighbor) {
if (!manager.isInGroup(neighbor) || manager.getGroupNumber(neighbor) != manager.getGroupNumber(pixel)) {
if (pixel.color() == neighbor.color()) {
if (manager.isInGroup(neighbor)) {
manager.mergeGroups(pixel, neighbor);
} else {
uint32_t group = manager.getGroupNumber(pixel);
manager.addToGroup(group,neighbor);
}
}
}
}