The RGB color model is an additive system in which each color is defined by the amount of red, green, and blue light emitted. In the RGB scheme, colors are represented numerically with a set of three numbers, each of which ranges from 0 to 255. White has the highest RGB value of (255, 255, 255) while black has the lowest value of (0, 0, 0). This is consistent with the additive nature of the RGB system, since white light is the presence of all colors of light, and black is the absense of all light.

There are other three-parameter representations of colors. One such system is the HSI color model, which encodes colors according to their Hue, Saturation, andIntensity. The HSI model is used by some graphics programs and color monitors as an alternative to, or alongside the RGB representation.

In the HSI system, the hue of a color is its angle measure on a color wheel. Pure red hues are 0°, pure green hues are 120°, and pure blues are 240°. (Neutral colors--white, gray, and black--are set to 0° for convenience.) Intensity is the overall lightness or brightness of the color, defined numerically as the average of the equivalent RGB values.

The HSI definition of saturation is a measure of a color's purity/grayness. Purer colors have a saturation value closer to 1, while grayer colors have a saturation value closer to 0. (In other color models, the meanings and mathematical definitions of "saturation" are slightly different. See HSL and HSV color models for comparison.)

Equations to Convert RGB Values to HSI Values

Suppose R, G, and B are the red, green, and blue values of a color. The HSI intensity is given by the equation

I = (R + G + B)/3.

Now let m be the minimum value among R, G, and B. The HSI saturation value of a color is given by the equation

S = 1 - m/I    if I > 0, or
S = 0            if I = 0.

To convert a color's overall hue, H, to an angle measure, use the following equations:

H = cos-1[ (R - ½G - ½B)/√R² + G² + B² - RG - RB - GB ]            if G ≥ B, or 
H = 360 - cos-1[ (R - ½G - ½B)/√R² + G² + B² - RG - RB - GB ]    if B > G,

where the inverse cosine output is in degrees.

Equations to Convert HSI Values to RGB Values

To convert hue, saturation, and intensity to a set of red, green, and blue values, you must first note the value of H. If H = 0, then R, G, and B are given by

R = I + 2IS
G = I - IS
B = I - IS.

If 0 < H < 120, then

R = I + IS*cos(H)/cos(60-H)
G = I + IS*[1 - cos(H)/cos(60-H)]
B = I - IS.

If H = 120, then the red, green, and blue values are

R = I - IS
G = I + 2IS
B = I - IS.

If 120 < H < 240, then

R = I - IS
G = I + IS*cos(H-120)/cos(180-H)
B = I + IS*[1 - cos(H-120)/cos(180-H)].

If H = 240 then

R = I - IS
G = I - IS
B = I + 2IS.

And if 240 < H < 360, we have

R = I + IS*[1 - cos(H-240)/cos(300-H)]
G = I - IS
B = I + IS*cos(H-240)/cos(300-H).

RGB to HSI, HSI to RGB Conversion Calculator的更多相关文章

  1. RGB 颜色空间转 HSI 颜色空间的matlab程序实现

    RGB 颜色空间转 HSI 颜色空间的matlab程序实现 2014.10.20之前的内容有误,这里依据wikipedia更新了算法内容. 算法以wiki为准 https://en.wikipedia ...

  2. RGB 与 (RGB转 YCbCr再转为 RGB)的图像

           RGB 与 (RGB转 YCbCr再转为 RGB)的图像   不可逆,能够从 矩阵的逆运算看出来. 附上 matlab 代码:         clc,clear; Source=imr ...

  3. 将rgb表示方式转换为hex表示方式-------------将hex表示方式转换为rgb表示方式(这里返回rgb数组组合)

      /**  * kevin 2021.1.4  * 将rgb表示方式转换为hex表示方式  * @param {string} rgbColor 传过来的hex格式的颜色  * @returns { ...

  4. rgb转灰度 RGB To Gray php Adobe RGB (1998) [gamma=2.20]

    <?php /** * Date: 2016/10/24 * Time: 0:52 */ // Gray = (R^2.2 * 0.2973 + G^2.2 * 0.6274 + B^2.2 * ...

  5. 如何将24位RGB颜色转换16位RGB颜色

    有许多朋友第一次使用16位彩色显示屏会遇到如何将24位RGB颜色转换为对应的16位RGB颜色的问题, 通过查阅相关资料,就写一下其中的转换原理吧,希望对大家会有所帮助. 我们知道24位RGB是分别由8 ...

  6. Codeforces Round #575 (Div. 3) D1+D2. RGB Substring (easy version) D2. RGB Substring (hard version) (思维,枚举,前缀和)

    D1. RGB Substring (easy version) time limit per test2 seconds memory limit per test256 megabytes inp ...

  7. 色彩空间转换 rgb转ycbcr422/ycbcr422转rgb

    在图像处理过程中通常需要会对图像类型进行互相转换,在此给出两种转换的工程代码. 1.在将ycbCr422转rgb时,通常先将ycbcr422转换成ycbcr444再讲ycbcr444转成rgb 1.1 ...

  8. QT 实现彩色图亮度均衡,RGB和HSI空间互相转换

    从昨天折腾到今天.再折腾下去我都要上主楼了  大致和灰度图均衡是一样的,主要是不能像平滑什么的直接对R,G,B三个分量进行.这样出来的图像时没法看的.因此我们要对亮度进行均衡.而HSI彩色空间中的分量 ...

  9. 【转载】颜色空间-RGB、HSI、HSV、YUV、YCbCr的简介

    转载自缘佳荟的博客. 颜色通常用三个相对独立的属性来描述,三个独立变量综合作用,自然就构成一个空间坐标,这就是颜色空间.而颜色可以由不同的角度,用三个一组的不同属性加以描述,就产生了不同的颜色空间.但 ...

随机推荐

  1. jQuery报 SyntaxError: expected expression, got '<'错误

    这有什么可奇怪的,这个问题是表达式未能按照预期结束,说白了就是你少写分号了. 你肯定是语法错了,仔细查看一下提示错误的那一行和它的附近,是不是因为疏忽大意出错了. 再给你的建议,不要觉得某个分号可以省 ...

  2. 51nod 1040最大公约数和(欧拉函数)

    1040 最大公约数之和 题目来源: rihkddd 基准时间限制:1 秒 空间限制:131072 KB 分值: 80 难度:5级算法题  收藏  关注 给出一个n,求1-n这n个数,同n的最大公约数 ...

  3. 基于Oracle的Mybatis 批量插入

    项目中会遇到这样的情况,一次性要插入多条数据到数据库中,有两种插入方法: 方法一: Mybatis本身只支持逐条插入,比较笨的方法,就是遍历一个List,循环中逐条插入,比如下面这段代码 for(Da ...

  4. Elasticsearch静态集群配置

    这两天需要将ELK中的单节点运行的ES扩展为双节点,查询了下集群配置,百度搜索结果还是一如既往的坑,基本都是各种转帖,以下记录配置静态集群的步骤: * * * <pre><code& ...

  5. 对TCP/IP网络协议的深入浅出归纳

    前段时间做了一个开发,涉及到网络编程,开发过程比较顺利,但任务完成后始终觉得有一些疑惑.主要是因为对网络协议不太熟悉,对一些概念也没弄清楚.后来 我花了一些时间去了解这些网络协议,现在对TCP/IP网 ...

  6. 【USACO 1.2】Name That Number

    给你一串数字(≤12个),每个数字可以对应3个字母,求生成的所有字符串里,在字典内的有哪些. 我做的时候想的是字典树(Trie 树),模拟数串生成的所有字符串,然后在字典树里查找一下. /* TASK ...

  7. 【POJ 2826】An Easy Problem?!(几何、线段)

    两个木条装雨水能装多少. 两线段相交,且不遮盖的情况下才可能装到水. 求出交点,再取两线段的较高端点的较小值h,(h-交点的y)为三角形的高. 三角形的宽即为(h带入两条线段所在直线得到的横坐标的差值 ...

  8. Java中Unicode的编码和实现

    Unicode的编码和实现 大概来说,Unicode编码系统可分为编码方式和实现方式两个层次. 编码方式 字符是抽象的最小文本单位.它没有固定的形状(可能是一个字形),而且没有值.“A”是一个字符,“ ...

  9. GitHub项目大全

    [微信网页版]: [查看被删的微信好友]https://github.com/0x5e/wechat-deleted-friends [网页版微信API,包含终端版微信及微信机器人]https://g ...

  10. android备忘录

    1.跑马灯-滚动字幕 多用于广告,在屏幕上方滚动显示,可以是文字,图片等 #滚动字幕 TextView 中加(singleLine="true",ellipsize="m ...