图像增强算法总结

需要图像增强的原因:

  1 图像噪点过大,影响感观、影响计算机对图像特征的提取

  2 图像因为光线环境等造成整体对比度不足或局部过暗、过曝。细节损失

  3 图像白平衡系数未校准造成图像偏色

  4 图像因采集时镜头失焦等问题造成的模糊

  5 图像由于运动速度过快 (采集一帧时间内发生了剧烈运动),形成运动模糊

  6 图像因为 sensor 感光等问题造成 色彩饱和度不足

  7 图像分辨率太低,放大后的细节缺失

 

下面逐一介绍

   一  噪声抑制

    形成噪声的原因很多,比如相机拍摄时曝光不够(夜间拍摄),或信号传输收到了干扰(如老的无线电视台信号),最终形成画面很多失真的黑白或彩色杂点。 按噪声的分布分高斯噪声, 椒盐(随机的白噪声)等。 按噪声对画质的影响分为加性噪声,或乘性噪声等。 现实远远比我举例的复杂 。。

 

光线不足相机采集的噪声

 

老的无线电视机信号噪声

 

老胶卷电影中的噪点

 

为更好的处理噪声,我们先来人为的增加图像噪声

 

1.1 增加椒盐噪声

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define PI (3.141592653)

int HG_AddSaltNoise(unsigned  char *plane, int w, int h, int pitch , double pcnt)
{
    double      x;  
    uint8_t     *p_pix;
    int         skip;
    int         col , row;

    srandom(time(NULL));

    p_pix = plane;
    skip  = pitch - w;

    for(row = 0 ; row < h ; ++row , p_pix += skip){
        for(col = 0 ; col < w ; ++col , ++p_pix){
            x  = random() * 1.0f / RAND_MAX;
            if (x < pcnt / 2)
                *p_pix = 0;
            else if (x > (1 - pcnt / 2))
                *p_pix = 255;
        }   
    }   
    return 0;
}

1.2 增加高斯噪声

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define PI (3.141592653)
int HG_AddGuassianNoise(unsigned char *plane, int w, int h, int pitch , uint8_t u , double delta)
{
    /*
         Box-Muller transform to generate guassian distribution

         guassian(0 , 1):

         x1 = random(0 ~ 1)
         x2 = random(0 ~ 1)
                ______            __
         z1 = \/-2lnx1  * cos(2 * ||  * x2)
                ______            __
         z2 = \/-2lnx1  * sin(2 * ||  * x2)

         guassian(u ,delta) :
                ______            __
         z1 = \/-2lnx1  * cos(2 * ||  * x2) * delta + u
                ______            __
         z2 = \/-2lnx1  * sin(2 * ||  * x2) * delta + v
    */

    double      x1 , x2;
    uint8_t     *p_pix;
    int         skip;
    int         col , row;
    int16_t     val;

    srandom(time(NULL));

    p_pix = plane;
    skip  = pitch - w;

    for(row = 0 ; row < h ; ++row , p_pix += skip){
        for(col = 0 ; col < w ; ++col , ++p_pix){
            if (col % 2 == 0) {
                x1  = random() * 1.0f / RAND_MAX;
                x2  = random() * 1.0f / RAND_MAX;
                val = sqrt(-2 * log(x1)) * cos( 2 * PI * x2) * delta + u;
            }else {
                x1  = random() * 1.0f / RAND_MAX;
                x2  = random() * 1.0f / RAND_MAX;
                val = sqrt(-2 * 
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

walletiger

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值