OpenCV——饱和度调整
来源:互联网 发布:淘宝二手雅马哈能买吗 编辑:程序博客网 时间:2024/06/10 07:32
参考:
闲人阿发伯的博客
// 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"using namespace std;using namespace cv;void Show_Image(Mat&, const string &);#endif // PS_ALGORITHM_H_INCLUDED/*This program adjustthe saturation.*/#include "PS_Algorithm.h"#include <time.h>using namespace std;using namespace cv;int main(void){ string Img_name("4.jpg"); Mat Img; Img=imread(Img_name); Show_Image(Img, Img_name); Mat Img_out(Img.size(), CV_32FC3); Img.convertTo(Img_out, CV_32FC3); Mat Img_in(Img.size(), CV_32FC3); Img.convertTo(Img_in, CV_32FC3); // define the iterator of the input image MatIterator_<Vec3f> inp_begin, inp_end; inp_begin=Img_in.begin<Vec3f>(); inp_end =Img_in.end<Vec3f>(); // define the iterator of the output image MatIterator_<Vec3f> out_begin, out_end; out_begin=Img_out.begin<Vec3f>(); out_end =Img_out.end<Vec3f>(); // increment (-100.0, 100.0) float Increment=-50.0/100.0; float delta=0; float minVal, maxVal; float t1, t2, t3; float L,S; float alpha; for(; inp_begin!=inp_end; inp_begin++, out_begin++) { t1=(*inp_begin)[0]; t2=(*inp_begin)[1]; t3=(*inp_begin)[2]; minVal=std::min(std::min(t1,t2),t3); maxVal=std::max(std::max(t1,t2),t3); delta=(maxVal-minVal)/255.0; L=0.5*(maxVal+minVal)/255.0; S=std::max(0.5*delta/L, 0.5*delta/(1-L)); if (Increment>0) { alpha=max(S, 1-Increment); alpha=1.0/alpha-1; (*out_begin)[0]=(*inp_begin)[0]+((*inp_begin)[0]-L*255.0)*alpha; (*out_begin)[1]=(*inp_begin)[1]+((*inp_begin)[1]-L*255.0)*alpha; (*out_begin)[2]=(*inp_begin)[2]+((*inp_begin)[2]-L*255.0)*alpha; } else { alpha=Increment; (*out_begin)[0]=L*255.0+((*inp_begin)[0]-L*255.0)*(1+alpha); (*out_begin)[1]=L*255.0+((*inp_begin)[1]-L*255.0)*(1+alpha); (*out_begin)[2]=L*255.0+((*inp_begin)[2]-L*255.0)*(1+alpha); } } Img_out=Img_out/255.0; Show_Image(Img_out, "out"); imwrite("out.jpg", Img_out*255); waitKey(); cout<<"All is well."<<endl;}// 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);}
原图
效果图
0 2
- OpenCV——饱和度调整
- Photoshop图像处理算法—饱和度调整
- PS 图像调整算法——饱和度调整
- 饱和度调整
- 用OpenCV实现Photoshop算法(七): 调整色相饱和度
- 图像饱和度调整 参考
- opencv——尺度调整
- OpenCV——黑白调整
- 图片饱和度,色相,亮度调整
- Python: PS 图像调整--饱和度调整
- 网站健康成长的关键—网站饱和度
- PPStream调整亮度,色度,饱和度,对比度
- Delphi图像处理 -- 色相/饱和度调整
- 图像处理之调整亮度与饱和度
- 图像处理------调整亮度与饱和度
- 彩色图像颜色和饱和度调整办法
- Qt图片调整之饱和度调节
- 图像处理之调整亮度与饱和度
- 数据结构实验之链表二:逆序建立链表
- checking build system type... configure: error: cannot guess build type; you must specify one
- 运行报错:java.lang.UnsatisfiedLinkError: Cannot load library: soinfo_relocate(linker.cpp:975): can
- 前端代码规范 及 最佳实践
- 近期规划及停滞需要重启的项目
- OpenCV——饱和度调整
- LeetCode 113 Combination Sum II
- genesis_rom
- Python标准库:内置函数any(iterable)
- 80端口占用问题
- 正向代理与反向代理的区别【Nginx读书笔记】
- JDK6的新特性之六:插入式注解处理API(Pluggable Annotation Processing API)
- poj 1088 滑雪(记忆化搜索)
- 活动安排问题