程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> 關於C++ >> Opencv— — Bias and Gain

Opencv— — Bias and Gain

編輯:關於C++
// define head function
#ifndef PS_ALGORITHM_H_INCLUDED
#define PS_ALGORITHM_H_INCLUDED

#include 
#include 
#include "cv.h"
#include "highgui.h"
#include "cxmat.hpp"
#include "cxcore.hpp"
#include "math.h"

using namespace std;
using namespace cv;

void Show_Image(Mat&, const string &);

#endif // PS_ALGORITHM_H_INCLUDED

/*
Adjust bias and gain.
*/

#include "PS_Algorithm.h"

float Bias(float a, float b);
float Gain(float a, float b);

int main()
{
    string  Image_name("4.jpg");
    Mat Img=imread(Image_name.c_str());
    Mat Img_out(Img.size(), CV_32FC3);

    float gain_val = 0.75;   // 0-1
    float bias_val = 0.25;   // 0-1

    int width=Img.cols;
    int height=Img.rows;

    float val;

    for (int y=0; y(y, x)[k]/255;

                val=Gain(val, gain_val);

                Img_out.at(y, x)[k]=Bias(val, bias_val);

            }

        }

    }


    Show_Image(Img_out, "New_img");

    cout<<"All is well."< .999)
            return 1.0f;
        if (a < 0.5)
            return pow(2 * a, p) / 2;
        else
            return 1.0f - pow(2 * (1. - a), p) / 2;
    */

        float c = (1.0f/b-2.0f) * (1.0f-2.0f*a);
        if (a < 0.5)
            return a/(c+1.0f);
        else
            return (c-a)/(c-1.0f);


}

// define the show image
#include "PS_Algorithm.h"
#include 
#include 

using namespace std;
using namespace cv;

void Show_Image(Mat& Image, const string& str)
{
    namedWindow(str.c_str(),CV_WINDOW_AUTOSIZE);
    imshow(str.c_str(), Image);

}
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved