예제 #1
0
파일: main.cpp 프로젝트: andyTsing/piccante
    /**
     * @brief paintGL
     */
    void paintGL(){
        if(parentWidget() != NULL) {
            if(!parentWidget()->isVisible()) {
                return;
            }
        }

        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

        switch(method) {
        case 0:
            //applying Reinhard et al.'s TMO (local version)
            img_tmo = reinhard_tmo->ProcessLocal(&img, 0.18f, 8.0f, NULL, img_tmo);
            break;

        case 1:
            //applying Reinhard et al.'s TMO (global version)
            img_tmo = reinhard_tmo->ProcessGlobal(&img, 0.18f, img_tmo);
            break;

        case 2:
            //applying Drago et al.'s TMO
            img_tmo = drago_tmo->Process(&img, 100.0f, 0.95f, img_tmo);
            break;
        }

        //converting the image color space from linear RGB to sRGB
        img_tmo_with_sRGB = tmo->Process(SingleGL(img_tmo), img_tmo_with_sRGB);

        //img_tmo_with_sRGB visualization
        quad->Render(program, img_tmo_with_sRGB->getTexture());
    }
    /**
     * @brief execute
     * @param nameIn
     * @param nameOut
     * @param sigma_s
     * @param sigma_r
     * @param testing
     * @return
     */
    static ImageGL *execute(std::string nameIn, std::string nameOut,
                               float sigma_s, float sigma_r, int testing)
    {
        GLuint testTQ = glBeginTimeQuery();
        glEndTimeQuery(testTQ);

        ImageGL imgIn(nameIn);
        imgIn.generateTextureGL(GL_TEXTURE_2D, GL_FLOAT, false);

        FilterGLBilateral2DSP filter(sigma_s, sigma_r);
        ImageGL *imgRet = new ImageGL(1, imgIn.width, imgIn.height, 3, IMG_GPU, GL_TEXTURE_2D);

        GLuint testTQ1;

        if(testing > 1) {
            filter.Process(SingleGL(&imgIn), imgRet);

            testTQ1 = glBeginTimeQuery();

            for(int i = 0; i < testing; i++) {
                filter.Process(SingleGL(&imgIn), imgRet);
            }
        } else {
            testTQ1 = glBeginTimeQuery();
            filter.Process(SingleGL(&imgIn), imgRet);
        }

        GLuint64EXT timeVal = glEndTimeQuery(testTQ1);
        double ms = double(timeVal) / (double(testing) * 1000000.0);
        printf("Separate Bilateral Filter on GPU time: %f ms\n", ms);

        std::string sign = genBilString("S", sigma_s, sigma_r);
        std::string nameTime = FileLister::getFileNumber(sign, "txt");

        FILE *file = fopen(nameTime.c_str(), "w");

        if(file != NULL) {
            fprintf(file, "%f", ms);
            fclose(file);
        }

        ImageGL *imgWrite = new ImageGL(1, imgIn.width, imgIn.height, 4, IMG_CPU, GL_TEXTURE_2D);
        imgWrite->readFromFBO(filter.getFbo());
        imgWrite->Write(nameOut);
        return imgRet;
    }
예제 #3
0
    /**
     * @brief Process
     * @param imgIn
     * @param imgOut
     * @return
     */
    ImageGL Process(ImageGL *imgIn, ImageGL *imgOut)
    {
        if(imgIn == NULL){
            return imgOut;
        }

        if(imgIn->channels != 3) {
            return imgOut;
        }

        if(imgOut == NULL){
            imgOut = new ImageGL(1, imgIn->width, imgIn->height, 1, IMG_GPU, GL_TEXTURE_2D);
        }

        ImageGLVec input = SingleGL(imgIn);

        if(flt == NULL) {
            flt = new FilterGLChannel(0);
        }

        int channels = imgIn->channels;

        if(img_vec.empty()) {
            for(int i = 0; i < channels; i++) {
                img_vec.push_back(flt->Process(input, NULL));
                flt->Update(i + 1);
            }
        } else {
            for(int i = 0; i < channels; i++) {
                flt->Process(input, img_vec[i]);
                flt->Update(i + 1);
            }
        }

        if(ef == NULL) {
            ef = new ExposureFusionGL();
        }

        imgOut = ef->Process(img_vec, 1.0f, 1.0f, 0.0f, imgOut);

        return imgOut;
    }
예제 #4
0
 /**
  * @brief execute
  * @param imgIn
  * @param imgOut
  * @param size
  * @return
  */
 static ImageGL *execute(ImageGL *imgIn, ImageGL *imgOut, int size)
 {
     FilterGLMax filter(size);
     return filter.Process(SingleGL(imgIn), imgOut);
 }