• //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的更多相关文章

  1. Win8Metro(C#)数字图像处理--2.5图像亮度调整

    原文:Win8Metro(C#)数字图像处理--2.5图像亮度调整  2.5图像亮度调整函数 [函数名称] 图像亮度调整函数BrightnessAdjustProcess(WriteableBit ...

  2. GPUImage中亮度调整的实现——GPUImageBrightnessFilter

    亮度brightness其实是对RGB的调整,RGB值越大,效果越亮:反之则越暗. GPUImage中提供了对图像亮度调整的Filter,其核心代码如下(fragment): varying high ...

  3. OpenCV中图像算术操作与逻辑操作

    OpenCV中图像算术操作与逻辑操作 在图像处理中有两类最重要的基础操作各自是图像点操作与块操作.简单点说图像点操作就是图像每一个像素点的相关逻辑与几何运算.块操作最常见就是基于卷积算子的各种操作.实 ...

  4. TensorFlow学习笔记(五)图像数据处理

    目录: 一.TFRecord输入数据格式 1.1 TFrecord格式介绍 1.2 TFRecord样例程序 二.图像数据处理 2.1TensorFlow图像处理函数 2.2图像预处理完整样例 三.多 ...

  5. 图像切割—基于图的图像切割(Graph-Based Image Segmentation)

     图像切割-基于图的图像切割(Graph-Based Image Segmentation) Reference: Efficient Graph-Based Image Segmentation ...

  6. AngularJS in Action读书笔记1——扫平一揽子专业术语

    前(fei)言(hua): 数月前,以一个盲人摸象的姿态看了一些关于AngularJS的视频书籍,留下了我个人的一点或许是指点迷津或许是误人子弟的读后感.自以为已经达到熟悉ng的程度,但是因为刚入公司 ...

  7. RFID 仿真/模拟/监控/拦截/检测/嗅探器

    Sound card based RFID sniffer/emulator (Too tired after recon.cx to do draw the schematics better th ...

  8. 用C#编写游戏脚本

    大学宿舍玩游戏的时候,为了简化重复的键鼠动作,有学习过按键精灵和TC脚本开发工具,并做了一些小脚本,基本达到了当时的需求.不知不觉,已经毕业了3年了,无聊之余又玩起了游戏,对于一些无趣的重复行为,于是 ...

  9. PA教材提纲 TAW12-2

    Unit1 Adjustment of SAP Standard Software(SAP标准软件修改) 1.1 Adjusting SAP Standard Software(如何修改SAP标准软件 ...

随机推荐

  1. let能否完全替代IIFE

    let是什么 http://es6.ruanyifeng.com/#docs/let 最近,我写了一篇关于syntax of Java’s IIFE pattern的文章,来解释为什么我们用现在的方式 ...

  2. QT 获取文件的路径、打开文件的弹出对话框

    1.打开获取文件夹路径的对话框 QString filePath = QFileDialog::getExistingDirectory(this, "请选择文件保存路径...", ...

  3. AQS(队列同步器)

    目录导引: 一.简介 二.源码解析(JDK8) 三.运用示例 一.简介 1.volatile volatile修饰的共享变量可以保证可见性和有序性(禁止指令重排序). 2.CAS: CAS的原理很简单 ...

  4. mybatis-plus分页查询

    在springboot中整合mybatis-plus 按照官方文档进行的配置:快速开始|mybatis-plus 引入依赖: <!-- 引入mybatisPlus --> <depe ...

  5. 关于tomcat配置了虚拟路径,但是在Idea中无法生效的问题

    1. 确认 tomcat 的server.xml 文件中配置的虚拟路径是否正确 其中,path表示访问的虚拟路径,docBase表示真实路径 2. Idea 服务器配置中是否勾选 “Deploy ap ...

  6. 解决jquery调用NET webservice跨域的问题

    声明,解决方案由网上收集而来,个人整理.有别人的,也有我的. 一.webserive端 1.web.config 需要在web.config的configuration节点中加入如下的黑体部分内容. ...

  7. js 实现vue—引入子组件props传参

    参考:https://www.cnblogs.com/xiaohuochai/p/7388866.html 效果 html <!DOCTYPE html> <html> < ...

  8. grep 查看前后几行和参数匹配

    如果在只是想匹配模式的上下几行,grep可以实现.   grep -5 'parttern' inputfile //打印匹配行的前后5行 grep -C 5 'parttern' inputfile ...

  9. Linux 下 Nand Flash 驱动主要数据结构说明

    s3c2410 专有数据结构 s3c2410_nand_set struct s3c2410_nand_set { int                    nr_chips;     /* 芯片 ...

  10. Parted:2T以上磁盘分区工具(LINUX挂载2T以上磁盘)

    支持大于2T的磁盘,2T以下的最好还是用Fdisk来分区. [root@centos57 aixi]# parted /dev/hda print Model: VMware Virtual IDE ...