• 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);
    }

  • 相关阅读:
    文件I/O(不带缓冲)之write函数
    文件I/O(不带缓冲)之read函数
    webpack4.x版本splitChunksPlugin的配置项详解与实际应用场景
    关于使用express作为spa应用服务的问题
    url 的正则表达式:path-to-regexp
    node.js、js读取excel、操作excel、创建excel之js-xlsx.js
    Web前端之iframe详解
    html中的meta标签是什么?有哪些属性?
    大型互联网架构概述,看完文章又涨知识了
    redis 的过期策略都有哪些?内存淘汰机制都有哪些?
  • 原文地址:https://www.cnblogs.com/libing64/p/2878774.html
Copyright © 2020-2023  润新知