예제 #1
0
static Photo debayerMask(const Photo &photo, u_int32_t filters)
{
    Photo newPhoto(photo);
    Magick::Image srcImage(newPhoto.image());
    Magick::Image& dst = newPhoto.image();
    ResetImage(dst);

    int w = srcImage.columns();
    int h = srcImage.rows();
    std::shared_ptr<Ordinary::Pixels> src_cache(new Ordinary::Pixels(srcImage));
    std::shared_ptr<Ordinary::Pixels> dst_cache(new Ordinary::Pixels(dst));
    dfl_block bool error=false;
    dfl_parallel_for(y, 0, h, 4, (srcImage, dst), {
       Magick::PixelPacket *pixel = dst_cache->get(0, y, w, 1);
        const Magick::PixelPacket *src = src_cache->getConst(0, y, w, 1);
        if ( error || !pixel || !src ) {
            if (!error)
                dflError(DF_NULL_PIXELS);
            error=true;
            continue;
        }
        for (int x = 0 ; x < w ; ++x ) {
            int c = FC(filters, y, x);
            switch (c) {
            case 0:
                pixel[x].red = src[x].red; pixel[x].green = 0 ; pixel[x].blue = 0; break;
            case 1:
            case 3:
                pixel[x].red = 0 ; pixel[x].green = src[x].green ; pixel[x].blue = 0; break;
            case 2:
                pixel[x].red = 0; pixel[x].green = 0; pixel[x].blue = src[x].blue; break;
            }
        }
        dst_cache->sync();
    });
예제 #2
0
void CImageView::InitVars(void)
{
	m_hwnd = NULL;
	m_pfnOldImageViewWndProc = NULL;
	m_lOldStyle = 0;
	m_nWheelLines = g_dwDefaultNumWheels;
	ResetImage();
}
예제 #3
0
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);
}
void FaceDetection::FindFace(IplImage *img)
{
    // find all contours
    FindContours(img);
    //
    ResetImage();

    if (m_bBoosting)
        PostBoostingFindCandidats(img);
    else
        FindCandidats();    
    
}// void FaceDetection::FindFace(IplImage *img)
예제 #5
0
    void play() {
        int p = 0,
                c = m_inputs[0].count();
        foreach(Photo photo, m_inputs[0]) {
            if (aborted())
                continue;
            Photo pRed(photo);
            Photo pGreen(photo);
            Photo pBlue(photo);
            Photo pLuminance(photo);
            Magick::Image& srcImage = photo.image();
            Magick::Image& iRed = pRed.image();
            Magick::Image& iGreen = pGreen.image();
            Magick::Image& iBlue = pBlue.image();
            Magick::Image& iLuminance = pLuminance.image();

            try {
                ResetImage(iRed);
                ResetImage(iGreen);
                ResetImage(iBlue);
                ResetImage(iLuminance);
                std::shared_ptr<Ordinary::Pixels> src_cache(new Ordinary::Pixels(srcImage));
                std::shared_ptr<Ordinary::Pixels> iRed_cache(new Ordinary::Pixels(iRed));
                std::shared_ptr<Ordinary::Pixels> iGreen_cache(new Ordinary::Pixels(iGreen));
                std::shared_ptr<Ordinary::Pixels> iBlue_cache(new Ordinary::Pixels(iBlue));
                std::shared_ptr<Ordinary::Pixels> iLuminance_cache(new Ordinary::Pixels(iLuminance));
                int w = srcImage.columns();
                int h = srcImage.rows();
                dfl_block int line = 0;
                dfl_parallel_for(y, 0, h, 4, (srcImage, iRed, iGreen, iBlue, iLuminance),{
                    const Magick::PixelPacket *src = src_cache->getConst(0, y, w, 1);
                    Magick::PixelPacket *pxl_Red = iRed_cache->get(0, y, w, 1);
                    Magick::PixelPacket *pxl_Green = iGreen_cache->get(0, y, w, 1);
                    Magick::PixelPacket *pxl_Blue = iBlue_cache->get(0, y, w, 1);
                    Magick::PixelPacket *pxl_Luminance = iLuminance_cache->get(0, y, w, 1);
                    if ( m_error || !src || !pxl_Red || !pxl_Green || !pxl_Blue || !pxl_Luminance ) {
                        if ( !m_error )
                            dflError(DF_NULL_PIXELS);
                        continue;
                    }
                    for ( int x = 0 ; x < w ; ++x ) {
                        pxl_Red[x].red = pxl_Red[x].green = pxl_Red[x].blue = src[x].red;
                        pxl_Green[x].red = pxl_Green[x].green = pxl_Green[x].blue = src[x].green;
                        pxl_Blue[x].red = pxl_Blue[x].green = pxl_Blue[x].blue = src[x].blue;
                        pxl_Luminance[x].red =
                        pxl_Luminance[x].green =
                        pxl_Luminance[x].blue = DF_ROUND(LUMINANCE_PIXEL(src[x]));
                    }
                    iRed_cache->sync();
                    iGreen_cache->sync();
                    iBlue_cache->sync();
                    iLuminance_cache->sync();
                    dfl_critical_section({
                        emitProgress(p, c, line++, h);
                    });
                });
                outputPush(0, pLuminance);
                outputPush(1, pRed);
                outputPush(2, pGreen);
                outputPush(3, pBlue);
                emitProgress(p, c, 1, 1);
                ++p;
            }
            catch(std::exception &e) {