Пример #1
0
void Tools::edgeLaplacian()
{
    ImageViewer* iv = getViewer();

    if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Mono
                                                          << QImage::Format_Indexed8
                                                          << QImage::Format_RGB32))
        return;

    MaskDialog dialog;
    dialog.setWindowTitle("Laplacian");

    if (dialog.exec() == QDialog::Rejected)
        return;

    EdgeLaplacian* el = new EdgeLaplacian(iv->getImage(), iv);
    el->setParameter("size", dialog.getSize());

    el->start();
}
PNM* HoughLines::transform()
{
    // Cut of value from the image;
    int  threshold      = getParameter("threshold").toInt();
    bool drawWholeLines = getParameter("draw_whole_lines").toBool();

    PNM* newImage = new PNM(image->copy());

    EdgeLaplacian* edgeLaplacian = new EdgeLaplacian(image);
    edgeLaplacian->setParameter("size", 3);
    image = edgeLaplacian->transform();
    delete edgeLaplacian;

    BinarizationGradient* binGradient = new BinarizationGradient(image);
    image = binGradient->transform();
    delete binGradient;

    Hough* hough = new Hough(image);
    hough->setParameter("theta_density" , 3);
    hough->setParameter("skip_edge_detection", true);
    image = hough->transform();
    delete hough;

    int width  = image->width(),
        height = image->height();

    for (int theta = 0; theta < width; theta++) {
        for (int rho = 0; rho < height; rho++) {
            QRgb pixel = image->pixel(theta, rho);
            if(qGray(pixel) > threshold)
                newImage->setPixel(theta, rho, 1);
       }
    }

    return newImage;
}