コード例 #1
0
void MainWindow::SecondDerivImage()
{
    double sigma = ui->secondDerivSpinBox->value();

    SecondDerivImage(&outImage, sigma);

    DrawDisplayImage();
}
コード例 #2
0
ファイル: mainwindow.cpp プロジェクト: mandary/ComputerVision
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    connect(ui->openButton, SIGNAL(clicked()), this, SLOT(OpenImage()));
    connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(SaveImage()));
    connect(ui->saveDisplayButton, SIGNAL(clicked()), this, SLOT(SaveDisplayImage()));
    connect(ui->resetButton, SIGNAL(clicked()), this, SLOT(ResetImage()));
    connect(ui->toggleButton, SIGNAL(pressed()), this, SLOT(ToggleImage()));
    connect(ui->toggleButton, SIGNAL(released()), this, SLOT(ToggleImage()));

    connect(ui->bwButton, SIGNAL(clicked()), this, SLOT(BlackWhiteImage()));
    connect(ui->noiseButton, SIGNAL(clicked()), this, SLOT(AddNoise()));
    connect(ui->meanButton, SIGNAL(clicked()), this, SLOT(MeanBlurImage()));
    connect(ui->medianButton, SIGNAL(clicked()), this, SLOT(MedianImage()));
    connect(ui->gaussianBlurButton, SIGNAL(clicked()), this, SLOT(GaussianBlurImage()));
    connect(ui->firstDerivButton, SIGNAL(clicked()), this, SLOT(FirstDerivImage()));
    connect(ui->secondDerivButton, SIGNAL(clicked()), this, SLOT(SecondDerivImage()));
    connect(ui->sharpenButton, SIGNAL(clicked()), this, SLOT(SharpenImage()));
    connect(ui->sobelButton, SIGNAL(clicked()), this, SLOT(SobelImage()));
    connect(ui->bilateralButton, SIGNAL(clicked()), this, SLOT(BilateralImage()));
    connect(ui->halfButton, SIGNAL(clicked()), this, SLOT(HalfImage()));
    connect(ui->rotateButton, SIGNAL(clicked()), this, SLOT(RotateImage()));
    connect(ui->peaksButton, SIGNAL(clicked()), this, SLOT(FindPeaksImage()));
    connect(ui->houghButton, SIGNAL(clicked()), this, SLOT(HoughImage()));
    connect(ui->crazyButton, SIGNAL(clicked()), this, SLOT(CrazyImage()));
    connect(ui->randomButton, SIGNAL(clicked()), this, SLOT(RandomSeedImage()));
    connect(ui->pixelButton, SIGNAL(clicked()), this, SLOT(PixelSeedImage()));
    connect(ui->histogramButton, SIGNAL(clicked()), this, SLOT(HistogramSeedImage()));

    connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(OpenImage()));
    connect(ui->zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(Zoom(int)));
    connect(ui->brightnessSlider, SIGNAL(valueChanged(int)), this, SLOT(Brightness(int)));
    connect(ui->verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(Scroll(int)));
    connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(Scroll(int)));

    ui->meanBox->setValue(2);
    ui->medianBox->setValue(2);
    ui->blurSpinBox->setValue(2.0);
    ui->firstDerivSpinBox->setValue(2.0);
    ui->secondDerivSpinBox->setValue(2.0);
    ui->sharpenSigmaSpinBox->setValue(2.0);
    ui->sharpenMagSpinBox->setValue(1.0);
    ui->bilateralSigmaSSpinBox->setValue(2.0);
    ui->bilateralSigmaISpinBox->setValue(20.0);
    ui->noiseSpinBox->setValue(10.0);
    ui->orientationSpinBox->setValue(10.0);
    ui->peakThresholdSpinBox->setValue(10.0);
    ui->colorNoiseCheckBox->setChecked(true);
    ui->zoomSlider->setValue(0);
    ui->brightnessSlider->setValue(0);
    ui->clusterBox->setValue(4);

    displayImage = QImage(ui->ImgDisplay->width(), ui->ImgDisplay->height(), QImage::Format_RGB32);
}
コード例 #3
0
ファイル: Project1.cpp プロジェクト: mandary/ComputerVision
void MainWindow::SharpenImage(QImage *image, double sigma, double alpha)
{
    // sharpen = original - alpha * second derivative

    int r, c;

    QRgb pixel;

    QImage buffer;
    buffer = image->copy();

    int w = image->width();
    int h = image->height();

    SecondDerivImage(&buffer, sigma);

    for(r = 1; r < h - 1; r++) {
        for(c = 1; c < w - 1; c++) {

            double rgb[3] = {0, 0, 0};

            pixel = image->pixel(c, r);
            rgb[0] += (double) qRed(pixel);
            rgb[1] += (double) qGreen(pixel);
            rgb[2] += (double) qBlue(pixel);

            pixel = buffer.pixel(c, r);
            rgb[0] -= alpha * ((double) qRed(pixel) - 128.0);
            rgb[1] -= alpha * ((double) qGreen(pixel) - 128.0);
            rgb[2] -= alpha * ((double) qBlue(pixel) - 128.0);

            // Adjust the rgb value
            rgb[0] = min(255.0, max(0.0, rgb[0]));
            rgb[1] = min(255.0, max(0.0, rgb[1]));
            rgb[2] = min(255.0, max(0.0, rgb[2]));

            // Store convolved pixel in the image to be returned.
            image->setPixel(c, r, qRgb((int) floor(rgb[0] + 0.5), (int) floor(rgb[1] + 0.5), (int) floor(rgb[2] + 0.5)));
        }
    }

}