画像内の各点に同じ処理を行うフィルタ。
画像の2値化処理に内分点を施しただけのフィルタ。
各点の色が色空間内の3点赤、青、緑を含む平面より下にあるなら、その点の色を黒に近づけ、平面より上にあるなら白に近づける処理を行っているだけのフィルタ。



//フィルタ製作者 堀江伸一 
  class pictFilter
   {
       Random rnd = new Random();
       Bitmap pictOut = null;
       int h;//絵の高さ
       int w;//絵の横幅
       public pictFilter()
       {
           h = 0;
           w = 0;
       }

       public Bitmap  flatFilter(Bitmap pictIn){
           //テンプレ
           Color C1;
           this.h = pictIn.Height;
           this.w = pictIn.Width;
           int rgbR,rgbG,rgbB;

           pictOut = new Bitmap(this.w, this.h);
           for(int i=0;i<this.w;i++){
               for (int j = 0; j < this.h; j++)
               {
                   C1 = pictIn.GetPixel(i, j);
                   if (C1.R + C1.G + C1.B >255)//ここは255ではなく画像全体での色の平均値とかでもいいと思う
                   {
                       rgbR = (int )(C1.R * 0.5 + 255 * 0.5);
                       rgbG = (int )(C1.G * 0.5 + 255 * 0.5);
                       rgbB = (int )(C1.B * 0.5 + 255 * 0.5);
                   }
                   else
                   {
                       rgbR = (int )(C1.R * 0.5);
                       rgbG = (int )(C1.G * 0.5);
                       rgbB = (int )(C1.B * 0.5);
                   }
                   pictOut.SetPixel(i, j, Color.FromArgb(rgbR, rgbG, rgbB));  
               }
           }
           return pictOut;
       }


       private int cutNum(int min, int max, int t)
       {
           if (t < min)
           {
               t = min;
           }
           if (t > max)
           {
               t = max;
           }
           return t;
       }

   }

}

タグ:

+ タグ編集
  • タグ:

このサイトはreCAPTCHAによって保護されており、Googleの プライバシーポリシー利用規約 が適用されます。

最終更新:2010年05月28日 16:08