bool pixelIsAssignedToNode(unsigned int x, unsigned int y, const NodeType& node) { auto pixelNodeId = nodeIdImage.getPixelValue(x, y); auto pixelNodeLevel = internalImage.getPixelValue(x, y); return pixelNodeId == node.getId() && pixelNodeLevel == node.getLevel(); }
void connectPixelsMaybeReplacingParent(const NodeType& firstNode, const NodeType& secondNode) { auto& isBefore = levelOrderComparator; auto firstNodeParentLevel = firstNode.getParent().getLevel(); auto secondNodeLevel = secondNode.getLevel(); if (isBefore(firstNodeParentLevel, secondNodeLevel)) minMaxTree.setNodeParent(firstNode, secondNode); }
void removeRootNode(const NodeType& node) { minMaxTree.removeNode(node.getLevel(), node.getId()); auto newColor = minMaxTree.getFirstLevel(); auto newId = 0u; updatePixelsIfOnCollapsedLevel(newColor, newId); updatePixelsIfAssignedToNode(node, newColor, newId); }
void removeNormalNode(const NodeType& node) { auto& parent = node.getParent(); auto newColor = parent.getLevel(); auto newId = parent.getId(); updatePixelsIfAssignedToNode(node, newColor, newId); minMaxTree.removeNode(node.getLevel(), node.getId()); }
void removeNode(const NodeType& node) { auto level = node.getLevel(); if (minMaxTree.hasLevel(level)) safelyRemoveNode(node); }