登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

秒大刀 博客

好好学习 天天向上

 
 
 

日志

 
 
 
 

ColorMatrix  

2010-03-27 12:06:58|  分类: Game |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

What Is a Color Matrix?
    Just as the co-ordinates x, y, and z define a single point in 3D space, the three color components R (red), G (green), and B (blue) define a single point in color space. In 3D geometrics (and in 2D geometrics as well), matrices can be used to transform the position of a point, and, more importantly, the position of a group of points. Change the matrix, apply the matrix to a group of points, and all the points are moved together. If you apply the matrix to all the points in a specific scene, the whole scene is transformed.

ColorMatrix - 秒大刀 - 秒大刀的城堡

(图片来源:www.couleur.org)

    A color matrix works the same way in color space. With a color matrix, you can change one specific color, say dark blue into light red, but you can also change all colors together, in a co-ordinated way. Just like a scene in 3D space, you can scale, translate, rotate, and shear the color space, or apply any combination of these basic transformations to it.

  For technical reasons, points in 3D space are transformed with 4x4 matrices. A color in RGB color space can also be transformed with a 4x4 matrix. But as GDI+ works with a fourth 'color', A (alpha, or opacity) throughout, ColorMatrix is defined as a 5x5 matrix of REALs: typedef struct { REAL m[5][5]; } ColorMatrix;

    GDI+ 提供用于存储和操作图像的 Image Bitmap 类。Image 和 Bitmap 对象将每个像素的颜色都存储为 32 位的数:红色、绿色、蓝色和 alpha 各占 8 位。这四个分量的值都是 0 到 255,其中 0 表示没有亮度,255 表示最大亮度。alpha 分量指定颜色的透明度:0 表示完全透明,255 表示完全不透明。
    颜色矢量采用 4 元组形式(红色、绿色、蓝色、alpha)。例如,颜色矢量 (0, 255, 0, 255) 表示一种没有红色和蓝色但绿色达到最大亮度的不透明颜色。
    表示颜色的另一种惯例是用数字 1 表示亮度达到最大。使用这种惯例,上一段中描述的颜色将用 (0, 1, 0, 1) 表示。GDI+ 在进行颜色变换时使用以 1 表示最大亮度的惯例。
    可通过用 4×4 矩阵乘以这些颜色矢量将线性变换(旋转和缩放等)应用到颜色矢量中。但是,您不能使用 4×4 矩阵进行平移(非线性)。如果在每个颜色矢量中再添加一个虚拟的第 5 坐标(例如,数字 1),则可使用 5×5 矩阵应用任何组合形式的线性变换和平移。由线性变换组成的后跟平移的变换称为仿射变换。
    一言而蔽之,ColorMatrix是通过5 * 5矩阵对图像颜色(包括Alpha)进行的几何变换,理解和掌握ColorMatrix变换,能使你的图像产生千变万化的效果。

ColorMatrix - 秒大刀 - 秒大刀的城堡 ColorMatrix - 秒大刀 - 秒大刀的城堡 ColorMatrix - 秒大刀 - 秒大刀的城堡

    .NET中有个tem.Drawing.Imaging.ColorMatrix类,专门处理ColorMatrix相关的工作。MSDN对其解释为“定义包含 RGBA 空间坐标的 5 x 5 矩阵。ImageAttributes 类的若干方法通过使用颜色矩阵调整图像颜色”,“矩阵系数组成一个 5 x 5 的线性转换,用于转换 ARGB 单色值。例如,ARGB 向量表示为 Alpha、Red(红色)、Green(绿色)、Blue(蓝色)和 W,此处 W 始终为 1”。

    具体的应用可以参考MSDN中对图像重新着色的相关文章:

如何:使用颜色矩阵对单色进行变换

讨论使用颜色矩阵变换颜色。

如何:转换图像颜色

演示如何使用颜色矩阵转换颜色。

使用转换来调整颜色

解释如何使用颜色矩阵调整颜色。

如何:旋转颜色

描述如何使用颜色矩阵旋转颜色。

如何:修剪颜色

定义剪切并解释如何使用颜色矩阵剪切颜色。

如何:使用颜色重新映射表

定义重新映射并演示如何使用颜色重新映射表。

参考:

对图像重新着色

颜色调整矩阵ColorMatrix详解

GDI+ ColorMatrix的完全揭秘

ColorMatrix的含义

Playing with ColorMatrix

ColorMatrix Basics - Simple Image Color Adjustment

Color Transformations and the Color Matrix

Using ColorMatrix for Creating Negative Image

Color Spaces

  评论这张
 
阅读(4754)| 评论(1)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018