资源简介
用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
相关资源
- 人脸识别(opencv_facedetect_v4l2)
- 基于opencv的模板匹配代码
- opencv图片扫描以及校正
- opencv手部轮廓识别以及轨迹识别
- opencv2 3D标定.cpp
- 基于opencv漫水填充算法综合
- opencv激光中心线的提取
- OpenCV Computer Vision Application Programming
- 基于图割的图像分割OpenCV+MFC实现
- 识别魔方颜色
- opencv版俄罗斯方块源码
- VS2013 / MFC + OpenCV 2.4.9实现视频的播放
- 粒子滤波器+目标跟踪的C++实现,VS2
- 张平OpenCV算法精讲基于python和C++教材
- 虹膜识别开源代码OSIRIS4.1基于opencv
- Sift特征点提取与匹配opencv库
- YCbCr、混合高斯以及YCbCg肤色检测模型
- 光流法代码
- OpenCV打开摄像机显示在MFC窗口工程源
- 使用c++读取图像到二维矩阵
- 三维点云的圆柱面拟合
- MFC+OPENCV摄像机标定程序
- 基于特征脸的人脸识别MFC+OpenCV
- opencv图像处理MFC
- OPENCV人脸检测加角点检测并输出坐标
- FillHole.rar
- 道路提取算法 c++ opencv
- PCA代码实现详解
- opencv卡尔曼滤波
- SeamCarving opencv c++
评论
共有 条评论