<< Chapter < Page Chapter >> Page >

The rgb model

Colors are represented by a triple of numbers, each giving the intensity of the primary colorsRed, Green, and Blue. Each number can be an unsigned integer, thus taking values between0 and 255, or be expressed as a floating point number between 0.0 and 1.0 . With even larger flexibility, the model, type, and range of colors can be set with the function colorMode() . The RGB model is additive.

Hsb model

Colors are represented by a triple of numbers, the first number giving the Hue, the second giving Saturation, and thethird giving the Brightness.

Often the model is called HSV, where V stands for Value.
The hue takes values in degrees between 0 (red) and 360 , being the various hues arranged along a circumference and being red positioned at 0 ˚ . Saturation and brightness vary between 0 and 100 . The saturation is the degree of purity of color. If a pure color is added with a white light its degree of puritydecreases until the color eventually sits on a gray scale when saturation is zero. In physical terms, the brightness isproportional to the signal power spectrum. Intuitively, the brightness is increased when the light intensityincreases. The three-dimensional HSB space is well represented by a cylinder, with the hue (nominal scale) arranged along thecircumference, the saturation (ratio scale) arranged along the radius, and the brightness (interval scale) arranged along thelongitudinal axis. Alternatively, such three-dimensional space can be collapsed into two dimensions, as in the color chooser of the image-processing program Gimp , displayed in [link] . Along the circumference, the three primary colors (red, green, and blue) are visible, 120 ˚ apart from each other, separated from the secondary colors (magenta, cyan, yellow). Each secondary color iscomplementary to the primary color in front of it in the circumference. For instance, if we take the green componentout of a white light, we obtain a magenta light. The triangle inscribed in the circumference has a vertex pointing to aselected hue. The opposite side contains the gray scale, thus representing colors with null saturation and variablebrightness. Going from the reference vertex to the opposite side we have a gradual decrease in saturation.

Gimp color chooser

Color chooser of the software Gimp

Alpha channel

It is a byte used to blend and interpolate between images, for example to render transparency. It can be obtained, from avariable of type color , with the method alpha() . The alpha channel can be manipulated with the method blend() of the class PImage .

Loading and visualizing an image with transparency

size(400,300);PImage b = loadImage("gondoliers.jpg"); PImage a = loadImage("gondoliers.jpg");float ramp = 0; for (int j = 0; j<b.height; j++) for (int i = 0; i<b.width; i++) { b.set(i, j, b.get(i,j) +color(0,0,0, 255 - (int)((1-ramp)*255)) ); ramp = ramp + 1/(float)(b.width * b.height);} a.blend(b, 0, 0, b.width, b.height,80, 10, 450, 250, BLEND); image(a, 0, 0, 400, 300);
Got questions? Get instant answers now!

In Processing, it is possible to assign a color to a variable of type color by means of the function color() , and the model can be previously set with colorMode() . The functions red() , green() , blue() , hue() , saturation() , and brightness() allow to move from one model to the other. colorMode(RGB); color c1 = color(102, 30,29);colorMode(HSB); color c2 = color(hue(c1), saturation(c1), brightness(c1));colorMode(RGB); color c3 = color(red(c2), green(c2), blue(c2));// the variables c1, c2, and c3 contain the coding of the same color

Questions & Answers

how to create a software using Android phone
Wiseman Reply
how
basra
what is the difference between C and C++.
Yan Reply
what is software
Sami Reply
software is a instructions like programs
Shambhu
what is the difference between C and C++.
Yan
yes, how?
Hayder
what is software engineering
Ahmad
software engineering is a the branch of computer science deals with the design,development, testing and maintenance of software applications.
Hayder
who is best bw software engineering and cyber security
Ahmad
Both software engineering and cybersecurity offer exciting career prospects, but your choice ultimately depends on your interests and skills. If you enjoy problem-solving, programming, and designing software syste
Hayder
what's software processes
Ntege Reply
I haven't started reading yet. by device (hardware) or for improving design Lol? Here. Requirement, Design, Implementation, Verification, Maintenance.
Vernon
I can give you a more valid answer by 5:00 By the way gm.
Vernon
it is all about designing,developing, testing, implementing and maintaining of software systems.
Ehenew
hello assalamualaikum
Sami
My name M Sami I m 2nd year student
Sami
what is the specific IDE for flutter programs?
Mwami Reply
jegudgdtgd my Name my Name is M and I have been talking about iey my papa john's university of washington post I tagged I will be in
Mwaqas Reply
yes
usman
how disign photo
atul Reply
hlo
Navya
hi
Michael
yes
Subhan
Show the necessary steps with description in resource monitoring process (CPU,memory,disk and network)
samuel Reply
What is software engineering
Tafadzwa Reply
Software engineering is a branch of computer science directed to writing programs to develop Softwares that can drive or enable the functionality of some hardwares like phone , automobile and others
kelvin
if any requirement engineer is gathering requirements from client and after getting he/she Analyze them this process is called
Alqa Reply
The following text is encoded in base 64. Ik5ldmVyIHRydXN0IGEgY29tcHV0ZXIgeW91IGNhbid0IHRocm93IG91dCBhIHdpbmRvdyIgLSBTdGV2ZSBXb3puaWFr Decode it, and paste the decoded text here
Julian Reply
what to do you mean
Vincent
hello
ALI
how are you ?
ALI
What is the command to list the contents of a directory in Unix and Unix-like operating systems
George Reply
how can i make my own software free of cost
Faizan Reply
like how
usman
hi
Hayder
The name of the author of our software engineering book is Ian Sommerville.
Doha Reply
what is software
Sampson Reply
the set of intruction given to the computer to perform a task
Noor
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Media processing in processing. OpenStax CNX. Nov 10, 2010 Download for free at http://cnx.org/content/col10268/1.14
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Media processing in processing' conversation and receive update notifications?

Ask