[code]图像亮度调整enhancement
//draft 2013.9 //F=X2/u;
////远处细节被淹没。 亮的地方增亮明显,暗的地方更暗。 不可取。
// CvScalar rgb;
// rgb=cvAvg(src);
//for(y=0;y<src->height;y++)
// {
// unsigned char *srcrow= (unsignedchar*)(src->imageData+y*src->widthStep);
// for(x=0;x<src->width;x++)
// {
//srcrow[3*x]=srcrow[3*x]*srcrow[3*x]/rgb.val[0]>255 ?255:srcrow[3*x]*srcrow[3*x]/rgb.val[0];
//srcrow[3*x+1]=srcrow[3*x+1]*srcrow[3*x+1]/rgb.val[1]>255? 255:srcrow[3*x+1]*srcrow[3*x+1]/rgb.val[1] ;
//srcrow[3*x+2]=srcrow[3*x+2]*srcrow[3*x+2]/rgb.val[2]>255? 255:srcrow[3*x+2]*srcrow[3*x+2]/rgb.val[2];
// }
// } #ifdef Enhencement_Linear // 255| ________
// | /
// | /
// | /
// | /
// | /
// |/_____.______.
// 0 A 255
int b=20;//上移b
for(y=0;y<src->height;y++)
{
unsigned char *srcrow= (unsignedchar*)(src->imageData+y*src->widthStep);
for (x=0;x<src->width;x++)
{ if (srcrow[3*x]>a)srcrow[3*x]=255;
else
srcrow[3*x]=(255-b)*srcrow[3*x]/(a)+b>255 ?255:(255-b)*srcrow[3*x]/(a)+b; if (srcrow[3*x+1]>a) srcrow[3*x+1]=255;
else
srcrow[3*x+1]=(255-b)*srcrow[3*x+1]/(a)+b>255 ?255:(255-b)*srcrow[3*x+1]/(a)+b; if (srcrow[3*x+2]>a)srcrow[3*x+2]=255;
else
srcrow[3*x+2]=(255-b)*srcrow[3*x+2]/(a)+b>255 ?255:(255-b)*srcrow[3*x+2]/(a)+b;
}
}
#endif ////改进log函数
//#ifdef Enhencement_LOG
// //CvScalar rgb;
// //rgb=cvAvg(src);
// double aa,bb,cc,aaaaa;aaaaa=255.0;
// k=(a-50)/255.0;
//for(y=0;y<src->height;y++)
// {
// unsigned char *srcrow= (unsignedchar*)(src->imageData+y*src->widthStep);
// for(x=0;x<src->width;x++)
// {
//aa=srcrow[3*x]+0.0;bb=(double)srcrow[3*x+1]+0.0;cc=(double)srcrow[3*x+2]+0.0;
// aa=log(aaaaa)-log(aa);
// bb=log(aaaaa)-log(bb);
// cc=log(aaaaa)-log(cc);
// //if (srcrow[3*x]>a);
// //else
//srcrow[3*x]=srcrow[3*x]+k*srcrow[3*x]*aa<srcrow[3*x]? srcrow[3*x]:srcrow[3*x]+k*srcrow[3*x]*aa;
// //srcrow[3*x]=srcrow[3*x]+k*srcrow[3*x]*aa;
// //if (srcrow[3*x+1]>a);
// //else
//srcrow[3*x+1]=srcrow[3*x+1]+k*srcrow[3*x+1]*bb<srcrow[3*x+1]? srcrow[3*x+1]:srcrow[3*x+1]+k*srcrow[3*x+1]*bb;
// //srcrow[3*x+1]=srcrow[3*x+1]+k*srcrow[3*x+1]*bb;
// //if (srcrow[3*x+2]>a);
// //else
// srcrow[3*x+2]=srcrow[3*x+2]+k*srcrow[3*x+2]*cc<srcrow[3*x+2] ?srcrow[3*x+2]:srcrow[3*x+2]+k*srcrow[3*x+2]*cc;
// //srcrow[3*x+2]=srcrow[3*x +2]+k*srcrow[3*x+2]*cc;
// }
// }
//#endif //
// //cvCvtColor(src,src,CV_BGR2YCrCb);
////转换颜色空间
#ifdef SHARPEN_Y //锐化
unsigned char x1,x2,x3,x4,x5,x6,x7,x8,x9;
int n1,n2,n3,n4,n5,n6,n7,n8;
IplImage* srctem=cvCreateImage(cvGetSize(src),8,3);
cvCopy(src,srctem);
//cvSmooth(srctem,srctem);
for(int y=1;yheight-1;y++)
{
unsigned char *row1= (unsignedchar*)(srctem->imageData+(y-1)*srctem->widthStep);
unsigned char *row2= (unsignedchar*)(srctem->imageData+y*srctem->widthStep);
unsigned char *row3= (unsignedchar*)(srctem->imageData+(y+1)*srctem->widthStep); unsigned char *row= (unsignedchar*)(src->imageData+y*src->widthStep); for (int x=1;xwidth-1;x++) {
x1=row1[3*(x-1)]; x2=row1[3*x]; x3=row1[3*(x+1)];
x4=row2[3*(x-1)]; x5=row2[3*x]; x6=row2[3*(x+1)];
x7=row3[3*(x-1)]; x8=row3[3*x]; x9=row3[3*(x+1)];
//Laplace
//n1=x5<<3;n2=x1+x2+x3+x4+x6+x7+x8+x9;//n1+=x5; //[8 -1..........-1]
n1=x5<<2;//n1+=x5; //[4 -1 -1-1 -1]
n2=x2+x4+x6+x8;
n1=(n1-n2)/3+x5; //锐¨?化¡¥
if(n1<0) n1=0; else if(n1>255)n1=255;//else n1=255;
row[3*x]=n1;
//row[3*x+1]=128;
//row[3*x+2]=128; }
}
#endif
// //cvCvtColor(src,src,CV_YCrCb2BGR);
[code]图像亮度调整enhancement的更多相关文章
- Win8Metro(C#)数字图像处理--2.5图像亮度调整
原文:Win8Metro(C#)数字图像处理--2.5图像亮度调整 2.5图像亮度调整函数 [函数名称] 图像亮度调整函数BrightnessAdjustProcess(WriteableBit ...
- GPUImage中亮度调整的实现——GPUImageBrightnessFilter
亮度brightness其实是对RGB的调整,RGB值越大,效果越亮:反之则越暗. GPUImage中提供了对图像亮度调整的Filter,其核心代码如下(fragment): varying high ...
- OpenCV中图像算术操作与逻辑操作
OpenCV中图像算术操作与逻辑操作 在图像处理中有两类最重要的基础操作各自是图像点操作与块操作.简单点说图像点操作就是图像每一个像素点的相关逻辑与几何运算.块操作最常见就是基于卷积算子的各种操作.实 ...
- TensorFlow学习笔记(五)图像数据处理
目录: 一.TFRecord输入数据格式 1.1 TFrecord格式介绍 1.2 TFRecord样例程序 二.图像数据处理 2.1TensorFlow图像处理函数 2.2图像预处理完整样例 三.多 ...
- 图像切割—基于图的图像切割(Graph-Based Image Segmentation)
图像切割-基于图的图像切割(Graph-Based Image Segmentation) Reference: Efficient Graph-Based Image Segmentation ...
- AngularJS in Action读书笔记1——扫平一揽子专业术语
前(fei)言(hua): 数月前,以一个盲人摸象的姿态看了一些关于AngularJS的视频书籍,留下了我个人的一点或许是指点迷津或许是误人子弟的读后感.自以为已经达到熟悉ng的程度,但是因为刚入公司 ...
- RFID 仿真/模拟/监控/拦截/检测/嗅探器
Sound card based RFID sniffer/emulator (Too tired after recon.cx to do draw the schematics better th ...
- 用C#编写游戏脚本
大学宿舍玩游戏的时候,为了简化重复的键鼠动作,有学习过按键精灵和TC脚本开发工具,并做了一些小脚本,基本达到了当时的需求.不知不觉,已经毕业了3年了,无聊之余又玩起了游戏,对于一些无趣的重复行为,于是 ...
- PA教材提纲 TAW12-2
Unit1 Adjustment of SAP Standard Software(SAP标准软件修改) 1.1 Adjusting SAP Standard Software(如何修改SAP标准软件 ...
随机推荐
- mfcs100d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MSVCRTD.lib(dllmain.obj)
转自VC错误:http://www.vcerror.com/?p=55 问题描述: mfcs100d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 al ...
- System.Web.Mvc.Controller.cs
ylbtech-System.Web.Mvc.Controller.cs 1.程序集 System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicK ...
- 连接 MySQL 报错:Lost connection to MySQL server at 'reading authorization packet', system error: 34
报错信息: Lost connection to MySQL server at 解决方案: use mysql; ; flush privileges; 参考: https://blog.csdn. ...
- apache反向代理和监听多个端口设置
修改apache配置文件httpd.conf 一.监听多个端口 在Listen 80后添加监听端口,如 Listen 80 Listen 8080 Listen 8008 二.反向代理设置 1.取消一 ...
- JavaScript特效源码(8、其他特效)
1.中文日期 中文日期[无须修改][共1步]] ====1.将以下代码加入HEML的<body></body>之间 <script LANGUAGE="Java ...
- 如何在 Apache Flink 中使用 Python API?
本文根据 Apache Flink 系列直播课程整理而成,由 Apache Flink PMC,阿里巴巴高级技术专家 孙金城 分享.重点为大家介绍 Flink Python API 的现状及未来规划, ...
- nc 文件的nan识别
表现形式:print()结果为 -- 打印type为numpy.ma.core.MaskedConstant 使用 if type(x) == np.ma.core.MaskedConsta ...
- VS2010-MFC(VS2010应用程序工程中文件的组成结构)
转自:http://www.jizhuomi.com/software/143.html 用应用程序向导生成框架程序后,我们可以在之前设置的Location下看到以解决方案名命名的文件夹,此文件夹中包 ...
- 《DSP using MATLAB》Problem 8.30
10月1日,新中国70周岁生日,上午观看了盛大的庆祝仪式,整齐的方阵,先进的武器,尊敬的先辈英雄,欢乐的人们,愿我们的 国家越来越好,人民生活越来越好. 接着做题. 代码: %% ---------- ...
- hibernate hql语句 注意事项
现在有实体类 Student 和User . public class Student{ private String id; private Sting classRoom; private Use ...