Author Topic: Colors (Mixing color or paint: R/G/B)  (Read 428290 times)

Fu-Kwun Hwang

  • Administrator
  • Hero Member
  • *****
  • Posts: 3062
    • Enjoy the fun of physics with simulations
Colors (Mixing color or paint: R/G/B)
« on: January 29, 2004, 11:13:21 pm »
Registed user can get files related to this applet for offline access.
Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
If java program did not show up, please download and install latest Java RUN TIME


Thomas Young, in the early 1800s, showed that a broad range of colors can be generated by mixing three beams of light, provided their frequencies were widely separately.
When three such beams combine to produce white light, there are called primary colors.
There is no single unique set of these primaries, nor do they have to be monochromatic.
The three components (emitted by three phoshors) that generate the whole gamut of hues seen on a color TV set are Red, Green, Blue.

Looking through a colored window or cloth is another story.
 Yellow cloth, paper, dye, paint, and ink all selectively absorb blue and reflect what remains - yellow - and that is why they appear yellow.
This java applet let you play with mixing light beams and paint pigments.





Click the right mouse button twice quickly to switch between two different modes:


Modebackground
Mixing light beamsblack
Mixing paint pigmentswhite


Click left mouse button and drag one of the colored oval to move it around.

Enter RGB values into the text field to change the color of the selected oval.
The color code (RGB value) at the mouse tip are shown in colored background.


Registed user can get files related to this applet for offline access.
Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
If java program did not show up, please download and install latest Java RUN TIME

noob

  • Newbie
  • *
  • Posts: 1
Java Code
« Reply #1 on: May 24, 2005, 06:09:40 pm »
Hello!
I need the java code
i hope you can help me!
thx noob :D

Fu-Kwun Hwang

  • Administrator
  • Hero Member
  • *****
  • Posts: 3062
    • Enjoy the fun of physics with simulations
topic39
« Reply #2 on: May 25, 2005, 09:21:25 am »
Java code: java source code or java class code?
If you just want the java class files , login and press the GET APPLETS FILEdS button, the system will send file to your email acount.

Simone_P

  • teacher
  • Newbie
  • *
  • Posts: 2
  • physics
topic39
« Reply #3 on: August 18, 2005, 12:10:48 am »
I remember the first applet I saw about optic,was yours [with lens and mirrors]...
I liked it very much.I shall show it to my pupils,soon.

squika

  • Newbie
  • *
  • Posts: 1
Hello fellow nerds
« Reply #4 on: February 28, 2006, 11:13:40 am »
I really enjoy Science, espceially the hard ones. I am really smart but, so if u are trublles dont feel free to hesistatie to even think about calling me :)

newton_83

  • Newbie
  • *
  • Posts: 1
color
« Reply #5 on: April 04, 2006, 07:43:54 pm »
Hey hwang, can u send me the complete JAVA file, class and code to my email address?
i really appreciate it..
n a question about RGB: the subject is a supervising camera, and in order to set an alarm, a difference in the picture taken should occur different than the oroginal one, so i thought of performing a pixel comparaison with RGB values. I need to know how to compare them both n how can i get the values, is there any equation for it?
thanks..


plz reply to me on lethe_83@yahoo.com

rhipple

  • Jr. Member
  • **
  • Posts: 22
  • Relativity, Electromagnetism, Open Source Physics
Need clarification
« Reply #6 on: April 05, 2006, 02:52:08 am »
I don't understand the question. Pixel by pixel comparison means

(R1,G1,B1) - (R2,G2,B2) = (0,0,0)

in my mind so please clarify!

santhosh

  • Newbie
  • *
  • Posts: 1
Pls give me the Java souce code of this applet...
« Reply #7 on: September 26, 2006, 02:23:34 am »

Mr Huang...can u pls send me the JAVA SOURCE CODE to my email account..??..It will be
a great favour..Thanks in advance....

Santhosh..

Email : santhoshkv99@gmail.com





mariegoodlad

  • Newbie
  • *
  • Posts: 1
f
« Reply #8 on: October 08, 2006, 07:35:12 pm »
it has been sent to my email but will not work.  can you help?

berkeley74

  • Newbie
  • *
  • Posts: 1
topic39
« Reply #9 on: November 10, 2006, 03:01:05 am »
thanks

tankw

  • Newbie
  • *
  • Posts: 1
Java Source Code
« Reply #10 on: November 12, 2006, 12:46:31 pm »
Hi Mr Hwang,

I would like to know how to calculate the mixing of color or paint together. Is that possible for me to get the Java source codes from you. Please email to me: kwtan21@gmail.com

Thanks

K.W.Tan


macavity042

  • Newbie
  • *
  • Posts: 1
topic39
« Reply #11 on: January 05, 2007, 04:58:29 am »
Mr. Huang,
I have a question I was hoping you might help with. It actually has nothing to do with physics, but I'm in the process of coding a neural network that can read 'hand'-written (or rather, mouse-written) characters. Ironically, while creating a neural network was no problem, I couldn't figure out how to do something you did in the applet up there. I was wondering how you managed to detect the colour of a given pixel.

If you could either point me in the right direction, or even better, if you'd be willing to send the source code, I'd be greatly appreciative. Thanks!

macavity042AThotmail.com



garima

  • Newbie
  • *
  • Posts: 1
how to compare RGB values of two images
« Reply #12 on: March 06, 2007, 02:36:34 pm »
hello..
how can we compare RGB values of two images and show the percentage of matching..??


Fu-Kwun Hwang

  • Administrator
  • Hero Member
  • *****
  • Posts: 3062
    • Enjoy the fun of physics with simulations
Re: topic39
« Reply #13 on: March 06, 2007, 06:11:52 pm »
Mr. Huang,
I have a question I was hoping you might help with. It actually has nothing to do with physics, but I'm in the process of coding a neural network that can read 'hand'-written (or rather, mouse-written) characters. Ironically, while creating a neural network was no problem, I couldn't figure out how to do something you did in the applet up there. I was wondering how you managed to detect the colour of a given pixel.

If you could either point me in the right direction, or even better, if you'd be willing to send the source code, I'd be greatly appreciative. Thanks!

macavity042AThotmail.com

The source code are included in the ZIP file you will received if you click DOWNLOAD APPLET FILES FOR OFFLINE USE button.
However, there are all written many years ago with JDK1.0.2

Fu-Kwun Hwang

  • Administrator
  • Hero Member
  • *****
  • Posts: 3062
    • Enjoy the fun of physics with simulations
Re: Colors (Mixing color or paint: R/G/B)
« Reply #14 on: March 21, 2007, 06:34:28 pm »
The following is a message I received in my email box:
Quote
john welch :
> Hi. I just tried out your color mixing applet. I changed the three ovals to these values:
> 100,100,55
> 100,55,100
> 55,100,100
>
> I wanted to show students that you didn't have to add 3 monochromatic sources to get white.
> But it looks like the applet is averaging the values rather than adding them, so that in the center of these three ovals I get 119, 119,199, where I would expect 255,255,255.
> I know you don't want to go over 255, but could you do something like max(a+b+c, 255) ?
> Actually, I guess that would distort the color balance if one of the rgb's was cut off at 255 and the other's weren't.
> So how about a scaling factor, like:  taking the maximum value of the sum of the individual rgb's then scaling that down to 255 if it goes over, and applying that scaling factor to all the other sums.
> for example:
>
> max value= max(ar+br+cr, ag+cg+cg, ab+bb+cb)
> if max_value > 255 then scale_factor = 255/max_value
> else scale factor =1
>
> red_value = (ar+br+cr) * scale_factor
> green_value = (ag+bg+cg) * scale factor
> etc
>
> what do you think?
>


In the world of computer, everything is done in binary form.
And that is how the above applet works.
The Red,Green, Blue value will be shown in (R,G,B), i.e. (255,0,0) means red light
For example: For mixing light beams, it not adding the decimal value or binary value to give us the sum (final color value). It is a (OR) operation between two (or more) binary values.

  • (255,0,0)+(0,255,0)=(255,255,0) : Most of us will not have problem with this, because red + green will give us yellow light. 
    In binary term: it is (1111 1111,0000 0000,0000 0000) OR (0000 0000,1111 1111,0000 0000) = (1111 1111,1111 1111,0000 0000)
  • (255,0,0)+ (255,0,0) = (255,0,0) : Two red lights emitted at the same place will give us red light.
    So the result is not the algebra sum of decimal values.
    In binary term: it is  (1111 1111,0000 0000, 0000 0000) OR (1111 1111,0000 0000, 0000 0000) = (1111 1111,0000 0000,0000 0000)
  • (64,64,64)+(64,64,64)=(64,64,64) : The same light mixing together, what is changing is the light intensity (not the color)
    In binary term: it is (0100 0000,0000 0000, 0000 0000) OR (0100 0000,0100 0000,0100 0000)= (0100 0000,0100 0000, 0100 0000)
  • (64,64,64)+(32,32,32)=(92,92,92) : Because it is a sum of two different color, so the final color is different
    In binary term: it is (0100 0000,0100 0000,0100 0000) OR (0010 0000,0010 0000,0010 0000)= (0110 0000,0110 0000, 0110 0000)

I hope the above examples, will help most of you understand how this applet works.
And it is also the same way, how our vision about color works.
For more information, please check out The human eye
The following information are from the above page.
Quote
Four kinds of light-sensitive receptors are found in the retina:

  * rods
  * three kinds of cones, each "tuned" to absorb light from a portion of the spectrum of visible light
  o cones that absorb long-wavelength light (red)
  o cones that absorb middle-wavelength light (green)
  o cones that absorb short-wavelength light (blue)
Cone Vision

Although cones operate only in relatively bright light, they provide us with our sharpest images and enable us to see colors. Most of the 3 million cones in each retina are confined to a small region just opposite the lens called the fovea. So our sharpest and colorful images are limited to a small area of view. Because we can quickly direct our eyes to anything in view that interests us, we tend not to be aware of just how poor our peripheral vision is.

The three types of cones provide us the basis of color vision. Cones are "tuned" to different portions of the visible spectrum.

  * red absorbing cones; those that absorb best at the relatively long wavelengths peaking at 565 nm
  * green absorbing cones with a peak absorption at 535 nm
  * blue absorbing cones with a peak absorption at 440 nm.

Retinal is the prosthetic group for each pigment. Differences in the amino acid sequence of their opsins accounts for the differences in absorption.

The response of cones is not all-or-none. Light of a given wavelength (color), say 500 nm (green), stimulates all three types of cones, but the green-absorbing cones will be stimulated most strongly. Like rods, the absorption of light does not trigger action potentials but modulates the membrane potential of the cones.

Because there are three different color censors in our eye. It is the combination of those signals help us interpret the color of any object. For the color: It is similar to the logical OR operation in computer term.

For your case: (100,100,55)+(100,55,100)+(55,100,100)
100=64+32+4, 55=32+16+4+2+1
So the result is (0110 0100,0110 0100,0011 0111)+(0110 0100,0011 0111,0110 0100)+(0011 0111,0110 0100,0110 0100)=(0111 0111,0111 0111,0111 0111)
In decimal terms it give you the final result of (119,119,119)