Understand and Visualize Color Spaces to Improve Your Machine Learning and Deep Learning Models

栏目: IT技术 · 发布时间: 4年前

内容简介:These questions came to my mind and I absolutely had to find the answers. So IAt first I started by exploring different color spaces that I foundThere is a wide (infinite) number of color spaces, so I made a

Introduction

“Why do we use the RGB color space as a standard in our training models? Sure, it’s the simplest color space because it’s the default color space. But are there other color spaces that may be more suitable? And can it improve our models?”

These questions came to my mind and I absolutely had to find the answers. So I investigated and did some experiments . I would like to share my results with you. 

At first I started by exploring different color spaces that I found inspiring . So in the first part of this article I will introduce you briefly to these color spaces and their possible applications in Machine Learning and Deep Learning .

There is a wide (infinite) number of color spaces, so I made a selection of the most interesting ones for you. 

  • RGB – CMYK
  • CIE XYZ – CIE L*a*b – CIE L*u*v
  • HSV- HSL- HSI
  • Y’UV – Y’IQ – YCbCr – YDbDr
  • C1C2C3 – I1I2I3
  • HED

In the second part of this post, I experienced these color spaces with a same model , in the same configurations . We will see that from one color space to another, the accuracy of our model can go from simple to twice.

RGB — BGR —CMYK

So how is an image in RGB structured? Basically by adding red, green and blue with different “proportions “. But I don’t tell you more than you already know, I think. The more you add the colors, the more you get a lighter color. That is because they emit light (it is this same principle that we can observe by looking very closely to a screen).

RGB and CMYK — Convertion

This is to be distinguished from primary light-reflecting colors. It is the reverse mechanism, the subtractivity . The more you add the colors together, the darker the color you get. This is the system that is used in printing , the CMYK (Cyan, Magenta, Yellow, and Black).

Then why the RGB? The truth is, there are as many color spaces as you want. We will see how we build them. But the RGB is about simplicity . That’s how our computer hardware is composed.

RGB decomposition (source : Pixabay )

RGB is the default color space , even in Machine Learning and Deep Learning. But take a look at the alternatives .

CIE XYZ — CIE L*a*b — CIE L*u*v

We saw that the RGB is device-oriented . The International Commission on Illumination, CIE for its French name “Commission Internationale de l’Eclairage” has set standards in colorimetry. It designs more abstract color spaces to break the boundaries of the RGB standard .

CIE XYZ decomposition (source : Pixabay )

The RGB space, encoded on 3 bytes, allows to represent 40% of the colors that the human eye can perceive. This is why the CIE suggests colour spaces to extend the field of possibilities to what man can actually perceive. Hence the color space CIE XYZ . It provides an extension of the boundaries of the color space to contain all the visible . If we simplify it a moment:

  • X roughly corresponds to the red stimulation
  • Y corresponds more or less to luminance
  • Z roughly corresponds to the blue stimulation
RGB and CIE XYZ — Convertion and Schema (source : Wikipedia )

Take a look at the schematic and the way we switch from one color space to another and you will understand two key elements :

  • Any choice of three “primary” color can only lead to one subset of available colors .
  • There is an infinite number of different color spaces with a matrix passage

The CIE XYZ space is an instrumental spac e which serves as a support for other spaces: The CIE L*a*b and the CIE L*u*v will be interesting to deal with because it introduces the notion of lightness .

RGB and CIE L*a*b*— Convertion and Schema (source : Wikipedia )

The eye has 3 distinct cones to detect colors . One for red, one for green, one for blue. But these cones don’t have the same responsiveness . So the perception of colors is different from the real color (speaking in wavelengths). The CIE L*a*b* color space try to distort the CIE XYZ space to better represent color perception for the human eye :

  • L* for lightness black → white
  • a* to represent the value on an axis green → red ;
  • b* to represent the value on an axis blue → yellow .
CIE L*a*b* decomposition (source : Pixabay )

To train learning models, the CIE L*a*b may be suitable. This can be seen in Wilson Castro’s paper, where they try to classify Cape Gooseberries according to their ripeness. He and his team tried SVM, ANN, DT and KNN. On each of these models, the CIE L*a*b* color space proved to be more effective than the RGB color space.

RGB and CIE L*u*v* — Convertion and Schema (source : Wikipedia )

Finally, the CIE L*u*v* space is another attempt to approach the perception of human eye. It has the advantage of being good at representing images of natural scenes . Color distances are easier to estimate, especially for distances between greens . In M.P. Rico-Fernándeza’s paper where they use a SVM approach to categorize cultivated species , the CIE L*u*v* color space allows greater accuracy .

CIE L*u*v* decomposition (source : Pixabay )

HSV- HSL- HSI

Other color spaces are based on a psycological approach . This is the case for HSV , HSL and HSI spaces . All are based on the concepts of color psycology , which is the best way to explain what you see :

  • Hue : the predominant color
  • Saturation : the purity of the color
  • Luminance : the brilliance of colour
Schema HSV — HSL — HSI (source : mathworks )

These color spaces are said to be cylindrical since they are represented by a cylindrical or conical shape around the color hue . All these spaces have the same base: the hue representing the dominant wavelength.


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

交互设计之路

交互设计之路

库帕 / Chris Ding / 电子工业出版社 / 2006-3 / 38.00元

本书是基于众多商务案例,讲述如何创建更好的、高客户忠诚度的软件产品和基于软件的高科技产品的书。本书列举了很多真实可信的实际例子,说明目前在软件产品和基于软件的高科技产品中,普遍存在着“难用”的问题。作者认为,“难用”问题是由这些产品中存在着的高度“认知摩擦”引起的,而产生这个问题的根源在于现今软件开发过程中欠缺了一个为用户利益着想的前期“交互设计”阶段。“难用”的产品不仅损害了用户的利益,最终也将......一起来看看 《交互设计之路》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具