2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[OpenCV]画像全体を赤くする

Posted at

OpenCV for Unityで死神の目を作った際(記事はこちら)に,雰囲気を出すために画像全体を赤くしたいと思いました.

C#で書いていますが,どの言語でも同じ処理でできると思います.

Mat ConvertToRed(Mat rgba)  //RGBでも同じ
{
    var channels = new List<Mat>();
    var zeroMat = new Mat(new Size(rgba.width(), rgba.height()), CV_8UC1, new Scalar(0));
    var redMat = new Mat();

    split(rgba, channels);      //チャンネルごとに分離
    channels[1] = zeroMat;	    //GとBチャンネルの全画素を0で置き換える
    channels[2] = zeroMat;
    merge(channels, redMat);    //マージしてRGBA画像に戻す
    return redMat;
}

zeroMatで置き換えるチャンネルを変えればいろんな色に変換できます.

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?