zoukankan      html  css  js  c++  java
  • VC6.0图像处理3灰度变换

    源码下载:http://download.csdn.net/detail/renshengrumenglibing/3875522

    //书接前文,我们继续看一些灰度操作,由于比较简单,我们多放几个函数

    //添加菜单以及处理函数 

    void CBMPViewerDoc::OnMenuitem32777() //灰度拉伸
    {
    // TODO: Add your command handler code here

    int linewidth;
    linewidth=(pbi->bmiHeader.biWidth*pbi->bmiHeader.biBitCount+31)/32*4;


    int r1  = 60;
    int r2 = 200;
    double  k = 1.5;
    // TODO: Add your command handler code here




    // TODO: Add your command handler code here
    for(int i = 0 ; i< bi.biHeight ; i++){
    for(int j = 0 ; j< bi.biWidth ; j++){
    unsigned char *lpScr;
    lpScr = (unsigned char *)lpBuf+linewidth*(bi.biHeight - i -1) + j;


    // *(lpScr) = BYTE((*lpScr - min)*256/(max- min));
    // *(lpScr) = BYTE(0);


    if(*lpScr < r1){
    *lpScr = BYTE(*lpScr/ k);
    }
    else if(*lpScr < r2){
    *lpScr = BYTE((*lpScr - r1)*k + r1/k);
    }
    else {
    *lpScr = BYTE((*lpScr - r2)/k + 255 -(255 -r2)/k);
    }
    }

    }
           UpdateAllViews(NULL,0,NULL);

    }


    void CBMPViewerDoc::OnMenuitem32780() //亮度增减  亮度增加20
    {
    // TODO: Add your command handler code here
    int linewidth;
    linewidth=(pbi->bmiHeader.biWidth*pbi->bmiHeader.biBitCount+31)/32*4;


    // TODO: Add your command handler code here
    for(int i = 0 ; i< bi.biHeight ; i++){
    for(int j = 0 ; j< bi.biWidth ; j++){
    unsigned char *lpScr;
    lpScr = (unsigned char *)lpBuf+linewidth*(bi.biHeight - i -1) + j;
    if(*lpScr < 235){
    *(lpScr) = BYTE(*lpScr +20);
    }
    else *lpScr = BYTE(255);
    }

    }

    // Invalidata(TRUE);
    UpdateAllViews(NULL,0,NULL);

    }


    void CBMPViewerDoc::OnMenuitem32781() //取对数
    {
    // TODO: Add your command handler code here
    int linewidth;
    linewidth=(pbi->bmiHeader.biWidth*pbi->bmiHeader.biBitCount+31)/32*4;


    // TODO: Add your command handler code here
    for(int i = 0 ; i< bi.biHeight ; i++){
    for(int j = 0 ; j< bi.biWidth ; j++){
    unsigned char *lpScr;
    lpScr = (unsigned char *)lpBuf+linewidth*(bi.biHeight - i -1) + j;
    double c ;
    c = 255/log(255);
    *lpScr  = BYTE(c*log(*lpScr +1));
    }

    }

    // Invalidata(TRUE);
    UpdateAllViews(NULL,0,NULL);

    }


    void CBMPViewerDoc::OnMenuitem32782() //取指数
    {
    // TODO: Add your command handler code here
    int linewidth;
    linewidth=(pbi->bmiHeader.biWidth*pbi->bmiHeader.biBitCount+31)/32*4;


    // TODO: Add your command handler code here
    for(int i = 0 ; i< bi.biHeight ; i++){
    for(int j = 0 ; j< bi.biWidth ; j++){
    unsigned char *lpScr;
    lpScr = (unsigned char *)lpBuf+linewidth*(bi.biHeight - i -1) + j;
    double c ;
    c = 255/pow(255 ,2);
    *lpScr  = BYTE(c*pow(*lpScr , 2));
    }

    }

    // Invalidata(TRUE);
    UpdateAllViews(NULL,0,NULL);

    }


    void CBMPViewerDoc::OnMenuitem32785() //降低亮度
    {
    // TODO: Add your command handler code here
    int linewidth;
    linewidth=(pbi->bmiHeader.biWidth*pbi->bmiHeader.biBitCount+31)/32*4;


    // TODO: Add your command handler code here
    for(int i = 0 ; i< bi.biHeight ; i++){
    for(int j = 0 ; j< bi.biWidth ; j++){
    unsigned char *lpScr;
    lpScr = (unsigned char *)lpBuf+linewidth*(bi.biHeight - i -1) + j;

    if(*lpScr > 20){
    *(lpScr) = BYTE(*lpScr -20);
    }
    else *lpScr = BYTE(0);
    }

    }

    // Invalidata(TRUE);
    UpdateAllViews(NULL,0,NULL);
    }

  • 相关阅读:
    文化因素对商标翻译的影响
    Building An Effective Marketing Plan
    HipHop PHP简介(转)
    关于comet
    TI BSL in python
    剖析 HTTP 协议
    NSIS 打包脚本基础
    图解使用VS的安装项目打包程序
    [Java IO]06_JSON操作
    [Java IO]04_系统标准IO
  • 原文地址:https://www.cnblogs.com/libing64/p/2878774.html
Copyright © 2011-2022 走看看