AForge学习笔记(8):AForge.Imaging.ColorReduction
来源:互联网 发布:淘宝客成交家信誉吗 编辑:程序博客网 时间:2024/05/21 15:04
BurkesColorDithering:用于实现伴有巴克斯误差扩散的色彩抖动。所谓色彩抖动即是根据调色板中的最匹配色替换原始图像颜色,在此过程中由于匹配色与原始色存在差值,因此产生误差,这些误差会进行扩散,通常通过邻近的七个像素基于协因子进行扩散。色彩抖动程序实现如下:
Bitmap bt = new Bitmap(@"C:\Users\GAOXIANG\Desktop\0.jpg");
// 创建彩色图像量化器
ColorImageQuantizer ciq = new ColorImageQuantizer(new MedianCutQuantizer());
// 创建像素深度8位的色彩板
Color[] colorTable = ciq.CalculatePalette(bt, 8);
// 彩色波动
AForge.Imaging.ColorReduction.BurkesColorDithering dithering = new AForge.Imaging.ColorReduction.BurkesColorDithering();
dithering.ColorTable = colorTable;
// apply the dithering routine
Bitmap newImage = dithering.Apply(bt);
运行结果:
ColorErrorDiffusionToAdjacentNeighbors:该类使用设定的协因素矩阵对邻近像素误差扩散模式进行设定。协因素矩阵:第一行处理右站像素,其他行处理底站像素,除第一行外,其他行数组成员个数必须是奇数个。示例如下:
Bitmap bt = new Bitmap(@"C:\Users\GAOXIANG\Desktop\2.jpg");
// 邻域色彩抖动
AForge.Imaging.ColorReduction.ColorErrorDiffusionToAdjacentNeighbors dithering = new
AForge.Imaging.ColorReduction.ColorErrorDiffusionToAdjacentNeighbors(new int[3][] {new int[2] { 5, 3 },new int[5] { 2, 4, 5, 4, 2 }, new int[3] { 2, 3, 2 } });
Bitmap newImage = dithering.Apply(bt);
运行结果:
FloydSteinbergColorDithering:基于弗洛伊德·斯坦伯格误差扩散的色彩抖动,实现如下:
Bitmap bt = new Bitmap(@"C:\Users\GAOXIANG\Desktop\2.jpg");
ColorImageQuantizer ciq = new ColorImageQuantizer(new MedianCutQuantizer());
Color[] colorTable = ciq.CalculatePalette(bt, 16);
AForge.Imaging.ColorReduction.FloydSteinbergColorDithering dithering = new AForge.Imaging.ColorReduction.FloydSteinbergColorDithering();
dithering.ColorTable = colorTable;
Bitmap newImage = dithering.Apply(bt);
运行结果:
JarvisJudiceNinkeColorDithering:基于Jarvis-Judice-Ninke 矩阵的图像抖动算法,实现方法完全相同:
Bitmap bt = new Bitmap(@"C:\Users\GAOXIANG\Desktop\0.jpg");
ColorImageQuantizer ciq = new ColorImageQuantizer(new MedianCutQuantizer());
Color[] colorTable = ciq.CalculatePalette(bt, 32);
AForge.Imaging.ColorReduction.JarvisJudiceNinkeColorDithering dithering = new AForge.Imaging.ColorReduction.JarvisJudiceNinkeColorDithering();
dithering.ColorTable = colorTable;
Bitmap newImage = dithering.Apply(bt);
运行结果:
在AForge中还提供了:OrderedColorDithering,SierraColorDithering,StuckiColorDithering,使用方法完全相同,在此不再叙述。
- AForge学习笔记(8):AForge.Imaging.ColorReduction
- AForge学习笔记(8):AForge.Imaging.ColorReduction
- AForge学习笔记(5):AForge.Imaging(上)
- AForge学习笔记(5):AForge.Imaging(下)
- AForge学习笔记(9):AForge.Imaging.ComplexFilters
- AForge学习笔记(11):AForge.Imaging.Textures
- AForge学习笔记(9):AForge.Imaging.ComplexFilters
- AForge学习笔记(10):AForge.Imaging.Filters
- AForge学习笔记(11):AForge.Imaging.Textures
- AForge学习笔记(2):AForge.Controls
- AForge学习笔记(4):AForge.Genetic
- AForge学习笔记(1):AForge
- AForge学习笔记(2):AForge.Controls
- AForge学习笔记(4):AForge.Genetic
- AForge学习笔记(3):AForge.Fuzzy
- AForge学习笔记(3):AForge.Fuzzy
- aforge.net
- AForge.Net
- win7下安装NetBeans找不到jdk的处理方法
- 通过Xcode将项目同步到GitHub上
- PAL制视频信号
- 先序、中序构造一棵唯一的二叉树
- 如何在UIAlertView中显示进度条
- AForge学习笔记(8):AForge.Imaging.ColorReduction
- 付费应用美国区2012-09统计
- linux下python常用插件安装
- How to Run MSTest.exe in Destination PC without be installed VS IDE
- 字符串NSString中去掉空格
- Android的线程使用来更新UI----Thread、Handler、Looper、TimerTask等
- 什么是饱和失真?什么是截止失真?
- 正则表达式
- MyBatis分页剖析