OpenCVの画像のシェーディング

OpenCVの画像のシェーディング

書式#include <iostreamの> 
の#include <opencv2 / opencv.hpp>

使用して 名前空間はstdを、
使用して 名前空間の品種;

// 画像のシェーディング
CV ::マットshadingTreatment(CV ::マット imgParam)。

int型のmain()
{
    ダブルアルファ; // コントラスト
    int型のベータ;      // 輝度
     // マットイメージ関数imread =( "F:OpencvProject \\ \\ \\のx64-CamerasAndSurveillance201910デバッグ\\ \\ \\ 20191025143712025.jpg face_data"); 
    マットイメージ関数imread =(" D:\\ \\ロイヤリティーフリー0.jpgトランプ\\ " );

    もし(image.empty())
    {
        リターン 0 ;
    }

    CV ::マットnew_image = shadingTreatment(画像)。

    /// 対象画像予め割り当てられた空間
     /// 表示画像 
    関数imshow(原画像、画像)。
    関数imshow(" 新画像" 、new_image)。


    /// キーボードイベントを待つ 
    waitKey(0 );



    リターン 0 ;
}


// 画像のシェーディング
CV ::マットshadingTreatment(CV ::マット imgParam)
{
    マットnew_image = マット::ゼロ(imgParam.size()、imgParam.type())。


    /// 入力の初期値
    // COUT << "コントラスト1-3入力してください:";
     // CIN >>アルファ;
     // COUT << "を入力してください輝度1-100:";
     // CIN >>ベータ版。

    二重アルファ= 1.2 int型のベータ= 50 ;
    /// 执行变换new_image(I、J)=アルファ*画像(I、J)+ベータ
    のためのINT Y = 0 ; Y <imgParam.rows; Y ++ 
    {
        INT X = 0 ; X <imgParam.colsあり; x ++ 
        {
            INT C = 0 ; C < 3 ; C ++ 
            {
                new_image.at <Vec3b>(Y、X)[C] = saturate_cast <UCHAR>(アルファ*(imgParam.at <Vec3b>(Y、X)[C])+ ベータ)。
            }
        }
    }

    リターンnew_image。
}

おすすめ

転載: www.cnblogs.com/herd/p/11754654.html