国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

C#彩色圖片灰度化算法

2019-11-17 03:15:11
字體:
來源:轉載
供稿:網友

C#彩色圖片灰度化算法

網上幾種算法中速度相對較快的

public static Bitmap MakeGrayscale(Bitmap original){    //create a blank bitmap the same size as original    Bitmap newBitmap = new Bitmap(original.Width, original.Height);    //get a graphics object from the new image    Graphics g = Graphics.FromImage(newBitmap);    //create the grayscale ColorMatrix    System.Drawing.Imaging.ColorMatrix colorMatrix = new System.Drawing.Imaging.ColorMatrix(       new float[][]       {         new float[] {.3f, .3f, .3f, 0, 0},         new float[] {.59f, .59f, .59f, 0, 0},         new float[] {.11f, .11f, .11f, 0, 0},         new float[] {0, 0, 0, 1, 0},         new float[] {0, 0, 0, 0, 1}      });    //create some image attributes    System.Drawing.Imaging.ImageAttributes attributes = new System.Drawing.Imaging.ImageAttributes();    //set the color matrix attribute    attributes.SetColorMatrix(colorMatrix);    //draw the original image on the new image    //using the grayscale color matrix    g.DrawImage(original, new Rectangle(0, 0, original.Width, original.Height), 0, 0, original.Width, original.Height, GraphicsUnit.Pixel, attributes);    //dispose the Graphics object    g.Dispose();    return newBitmap;}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 丰顺县| 德清县| 泗洪县| 乐安县| 浦城县| 潢川县| 皮山县| 高要市| 伊金霍洛旗| 于田县| 石屏县| 汝阳县| 凤山县| 冕宁县| 沾益县| 台湾省| 石渠县| 郯城县| 卢龙县| 朝阳区| 曲水县| 措美县| 余江县| 兴和县| 靖安县| 遂川县| 长兴县| 南平市| 沂源县| 绥中县| 广灵县| 黔西| 曲阜市| 阳信县| 吉水县| 宣汉县| 任丘市| 新丰县| 拉孜县| 伊金霍洛旗| 营口市|