C# (灰度)加权平均法将图片转换为灰度图
2016-10-09 10:55
281 查看
private Bitmap ToG(string file) { using (Bitmap o = new Bitmap(file)) { Bitmap g = new Bitmap(o.Width, o.Height); for (int i = 0; i < o.Width; i++) { for (int j = 0; j < o.Height; j++) { Color c = o.GetPixel(i, j); //灰度加权平均法公式 int rgb = (int)(c.R * 0.299 + c.G * 0.587 + c.B * 0.114); g.SetPixel(i, j, Color.FromArgb(rgb, rgb, rgb)); } } return g; } }
相关文章推荐
- c# winform 把彩色图片转换为灰色的图片,变灰,灰度图片,速度很快,safe,unsafe
- (工具ffmpeg)视频转换为flv格式,视频截取图片(c#)
- .net控制图片的显示尺寸/C#控制图片的显示尺寸/.net取得图片尺寸/.net更改图片尺寸/Unit转换
- C# 图片格式(JPG,BMP,PNG,GIF)等转换为ICO图标
- C# 图片格式(JPG,BMP,PNG,GIF)等转换为ICO图标
- C#中的数据类型转换和图片拼接
- Base64编码的字符串与图片的转换 C#
- C#实现图片文件到数据流再到图片文件的转换 --转
- 彩色图片转换为灰度图(方法)
- C#编写的类库,实现将pdf转换成图片(jpg)
- C#转换为灰度图的算法
- C# 图片转换成二进制,二进制转换成图片
- C#实现图片文件到数据流再到图片文件的转换
- 利用C#转换图片格式,可转换为ico
- 利用C#转换图片格式,可转换为ico
- [C#]将文字转换成图片
- C#将网页内容转换成图片保存到本地( webbrowser 可应用于B/S结构中)
- C#将图片转换成pdf
- C# 图片与byte[]之间以及byte[]与string之间的转换