Example #1
0
void traversePolyNodes(int array[][COL], PolyNode * start) {

    PolyNode * current = start;
    int i, j = 1;
    char x;

    while(current != NULL) {
        generatePolygon(array, current->XCoord, current->YCoord, current->numVertex);
        current = current->next;
    }
    printGrid(array);

}
QuillImageFilter *RedEyeDetection::generate(const QuillImage &image) const
{
    // No reference image given; no operations possible.
    if (image == QuillImage())
        return 0;

    // Scale the search rectangle from full-image coordinates to current
    // image.

    QRect rect = getStartingRectangle(image.size(), image.fullImageSize());

    // Detect best possible starting point

    QPoint center = locateStartingPoint(image, rect);

    // No possible red-eye pixels found - aborting (this should
    // generally not happen unless you select the blue sky or
    // something)
    if (center == QPoint())
        return 0;

    // Generate legal area around center
    int radius = priv->eyeRadius * qMin(image.size().width(), image.size().height()) /
	qMin(image.fullImageSize().width(), image.fullImageSize().height());
    QRect area = QRect(center.x()-radius, center.y()-radius,
		       radius*2+1, radius*2+1);

    area &= image.rect();

    // Flood fill around selected center
    // If overflows, tighten the criteria and try again.

    QSet<QPoint> redEye;

    for (int phase = 0; phase < 5; phase++)
    {
        setThreshold(phase);
        redEye = expandRedEye(image, center, area);
        if (!redEye.isEmpty())
            break;
    }

    // Still overflows - abandon

    if (redEye.isEmpty())
        return 0;

    QPolygon polygon = generatePolygon(area, redEye);

    // For some reason, polygon was empty (this should never happen)

    if (polygon == QPolygon())
        return 0;

    // If this was a preview, scale the plugin to big-picture coordinates

    if ((image.fullImageSize() != QSize()) && image.fullImageSize() != image.size())
        polygon = scalePolygon(polygon, image.size(), image.fullImageSize());

    // All is well.

    QuillImageFilter *filter =
	QuillImageFilterFactory::createImageFilter(QuillImageFilter::Name_RedEyeReduction);

    if (!filter)
        return 0;

    filter->setOption(QuillImageFilter::SelectionArea, polygon);

    return filter;
}