Opencv— — Bias and Gain
来源:互联网 发布:java cms框架搭建 编辑:程序博客网 时间:2024/06/08 04:05
// define head function#ifndef PS_ALGORITHM_H_INCLUDED#define PS_ALGORITHM_H_INCLUDED#include <iostream>#include <string>#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<height; y++) { for (int x=0; x<width; x++) { for (int k=0; k<3; k++) { val=(float)Img.at<Vec3b>(y, x)[k]/255; val=Gain(val, gain_val); Img_out.at<Vec3f>(y, x)[k]=Bias(val, bias_val); } } } Show_Image(Img_out, "New_img"); cout<<"All is well."<<endl; waitKey();}float Bias(float a, float b){ float y; a=pow(a, log(b)/log(0.5)); y=a/((1.0f/b-2)*(1.0f-a)+1); return y;}float Gain(float a, float b){ /* float p = log(1.0 - b) / log(0.5); if (a < .001) return 0.0f; else if (a > .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 <iostream>#include <string>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);}
图像效果可以参考:
http://blog.csdn.net/matrix_space/article/details/46790171
0 0
- Opencv— — Bias and Gain
- PS 图像调整— — gain and bias
- Bias and Variance Tradeoff
- Error And Bias
- bias and variance
- Bias and Variance
- bias and variance
- Bias and Variance
- bias and variance
- Regularization and Bias/Variance
- bias and variance
- 分类模型的性能评估——Lift和Gain
- 学习笔记——Bias-variance
- 【机器学习】bias and variance
- bias
- 偏差与方差(Bias and Variance)
- 偏差与方差(Bias and Variance)
- bias and variance 的简单理解
- hdu 2156 分数矩阵
- 黑马程序员---c语言中的分支语句 switch与if
- VS2013 OpenGL 编程中常见的错误
- Python 网页爬虫 & 文本处理 & 科学计算 & 机器学习 & 数据挖掘兵器谱
- charles解决安卓https抓包乱码
- Opencv— — Bias and Gain
- Hadoop集群完全分布式模式环境部署
- 汇编学习(一)
- Xcode技巧 - 1
- 异步过程调用(Asynchronous Procedure Call)
- 解锁滑动渐变动画
- hdu5305dfs对边的搜索,俩个数组记录度数
- 【Android基础】Android SQLite存储自定义对象
- 动漫人物之无头骑士异闻录:塞尔提·史特路尔森 セルティ・ストゥルルソン Celty Sturluson CV:泽城美雪 沢城みゆき