资源简介
用OpenCV C++实现Photoshop色阶调整算法, 包含Levels类和demo例程
代码片段和文件信息
/*
* test_Levels
*
* Created on: 2016年9月11日
* Author: Administrator
*/
#include
#include
#include “opencv2/core.hpp“
#include “opencv2/imgproc.hpp“
#include “opencv2/highgui.hpp“
#include “Levels.hpp“
using namespace std;
using namespace cv;
static string window_name = “Photo“;
static Mat src;
static Mat levels_mat;
static string levels_window = “Adjust Levels“;
static int channel = 0;
Levels levels;
int Shadow;
int Midtones = 100;
int Highlight;
int OutputShadow;
int OutputHighlight;
static void invalidate()
{
Mat dst;
levels.adjust(src dst);
imshow(window_name dst);
imshow(levels_window levels_mat);
}
static void channelRead(int which_channel)
{
channel = which_channel;
Level * CurrentChannel = NULL;
switch (channel) {
case 0: CurrentChannel = &levels.RGBChannel; break;
case 1: CurrentChannel = &levels.RedChannel; break;
case 2: CurrentChannel = &levels.GreenChannel; break;
case 3: CurrentChannel = &levels.BlueChannel; break;
}
if ( CurrentChannel == NULL ) return;
Shadow = CurrentChannel->Shadow;
Midtones = int (CurrentChannel->Midtones * 100);
Highlight = CurrentChannel->Highlight;
OutputShadow = CurrentChannel->OutputShadow;
OutputHighlight = CurrentChannel->OutputHighlight;
}
static void channelWrite()
{
Level * CurrentChannel = NULL;
switch (channel) {
case 0: CurrentChannel = &levels.RGBChannel; break;
case 1: CurrentChannel = &levels.RedChannel; break;
case 2: CurrentChannel = &levels.GreenChannel; break;
case 3: CurrentChannel = &levels.BlueChannel; break;
}
if ( CurrentChannel == NULL )
return ;
CurrentChannel->Shadow = Shadow;
CurrentChannel->Midtones = Midtones / 100.0;
CurrentChannel->Highlight = Highlight;
CurrentChannel->OutputShadow = OutputShadow;
CurrentChannel->OutputHighlight = OutputHighlight;
invalidate();
}
static void callbackAdjust(int void *)
{
channelWrite();
invalidate();
}
static void callbackAdjustChannel(int void *)
{
channelRead(channel);
setTrackbarPos(“Shadow“ levels_window Shadow);
setTrackbarPos(“Midtones“ levels_window Midtones);
setTrackbarPos(“Highlight“ levels_window Highlight);
setTrackbarPos(“OutShadow“ levels_window OutputShadow);
setTrackbarPos(“OutHighlight“ levels_window OutputHighlight);
invalidate();
}
int main()
{
//read image file
src = imread(“building.jpg“);
if ( !src.data ) {
cout << “error read image“ << endl;
return -1;
}
//create window
namedWindow(window_name);
imshow(window_name src);
//create window for levels
namedWindow(levels_window);
levels_mat = Mat::ones(100400 CV_8UC3);
levels_mat.setTo( Scalar(255255255) );
imshow(levels_window levels_mat);
channelRead(0);
createTrackbar(“Channel“ levels_window &channel 3 callbackAdjustChannel);
createTrackbar(“Shadow“ levels_window &Shadow 255 callbackAdjust);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 124965 2016-07-09 17:08 building.jpg
文件 1065 2016-09-11 17:20 Levels.hpp
文件 3093 2016-07-01 08:40 Levels.cpp
文件 3373 2016-09-11 17:35 demo.cpp
----------- --------- ---------- ----- ----
132496 4
相关资源
- 贝叶斯抠图C++源代码
- emgucv&opencv图像处理函数说明
- opencv实现分水岭算法
- 人工势场法C++版及利用opencv(or matl
- OpenCV+C++图像处理项目14个
- 用VS2015+opencv3.4.2+C++编写Yolov3目标检测
- 计算图像的平均灰度值
- OpenCV2.4.8
- 基于opencv的人脸识别程序-代码详解
- OpenCV通过直方图均衡化增强图像对比
- OpenCV种子填充实现彩色图像分割的代
- 基于 OPENCV 对三角形 的 角度检测
- 相机标定与图像畸变校正程序
- moravec算子c++代码
- openCV中stitching_detailed.cpp
- 11个常用OpenCV+C++图像处理
- opencv计算5*5邻域方差图
- opencv 视觉 追踪跟踪 经典kcf算法
- vc++6.0配置OpenCV
- 基于OpenCV的图像检索系统(源码)
- test_opencv.cpp
- opencv提取图片中人轮廓
- Python3+Opencv343环境搭建 dll load failed问
- 04_图像编辑器实现.zip
- 基于opencv人眼定位算法C++工程
- 图像连续拼接算法源码
- opencv 2.4.8 官方最新版安装与配置
- C++实现opencv+yolo+tensorflow+deepsort.txt
- Opencv封装成dll供.net调用方法
- 相机标定棋盘
评论
共有 条评论