Win8 Metro(C#)數字影像處理--2.62影像對數增強

weixin_34115824發表於2018-03-13
原文:Win8 Metro(C#)數字影像處理--2.62影像對數增強



[函式名稱]

  對數增強      WriteableBitmap LogenhanceProcess(WriteableBitmap src)

        /// <summary>
        /// Logarithm enhancement process.
        /// </summary>
        /// <param name="src">The source image.</param>
        /// <returns></returns>
         public static WriteableBitmap LogenhanceProcess(WriteableBitmap src)////對數增強
         {
             if (src != null)
             {
                 int w = src.PixelWidth;
                 int h = src.PixelHeight;
                 WriteableBitmap srcImage = new WriteableBitmap(w, h);
                 byte[] temp = src.PixelBuffer.ToArray();
                 byte[] tempMask = (byte[])temp.Clone();
                 for (int i = 0; i < tempMask.Length; i++)
                 {
                     temp[i] = (byte)(255.0 / Math.Log(256) * Math.Log(tempMask[i] + 1));
                 }
                 Stream sTemp = srcImage.PixelBuffer.AsStream();
                 sTemp.Seek(0, SeekOrigin.Begin);
                 sTemp.Write(temp, 0, w * 4 * h);
                 return srcImage;
             }
             else
             {
                 return null;
             }
         }

最後,分享一個專業的影像處理網站(微畫素),裡面有很多原始碼下載:


相關文章