NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
August 31, 2016, 11:13:08 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Like what you dislike of those things are imortant. ...Wisdom
Google Bookmarks Yahoo My Web MSN Live Netscape Del.icio.us FURL Stumble Upon Delirious Ask FaceBook

Pages: [1] 2   Go Down
  Print  
Author Topic: Colors (Mixing color or paint: R/G/B)  (Read 374120 times)
0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3075



WWW
: 1 users think this message is good
1 Colors (Mixing color or paint: R/G/B)
«
Embed this message
on: January 29, 2004, 10:13:21 pm » posted from:,,Satellite Provider

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
There are 13 translations,
Higher number at the end means more translation been done.
or


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
There are 13 translations,
Higher number at the end means more translation been done.
or


*** There are 2 more attached files. You need to login to acces it!
Logged
noob
Newbie
*
Offline Offline

Posts: 1

«
Embed this message
Reply #1 on: May 24, 2005, 05:09:40 pm »

Hello!
I need the java code
i hope you can help me!
thx noob Cheesy
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3075



WWW
«
Embed this message
Reply #2 on: May 25, 2005, 08: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.
Logged
Simone_P
teacher
Newbie
*
Offline Offline

Posts: 2

«
Embed this message
Reply #3 on: August 17, 2005, 11:10:48 pm »

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.
Logged
squika
Newbie
*
Offline Offline

Posts: 1

«
Embed this message
Reply #4 on: February 28, 2006, 10: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 Smiley
Logged
newton_83
Newbie
*
Offline Offline

Posts: 1

6 color
«
Embed this message
Reply #5 on: April 04, 2006, 06: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
Logged
rhipple
Jr. Member
**
Offline Offline

Posts: 22

Relativity, Electromagnetism, Open Source Physics


«
Embed this message
Reply #6 on: April 05, 2006, 01: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!
Logged

Always interested in meeting like-minded individuals
santhosh
Newbie
*
Offline Offline

Posts: 1

«
Embed this message
Reply #7 on: September 26, 2006, 01: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




Logged
mariegoodlad
Newbie
*
Offline Offline

Posts: 1

9 f
«
Embed this message
Reply #8 on: October 08, 2006, 06:35:12 pm »

it has been sent to my email but will not work.  can you help?
Logged
berkeley74
Newbie
*
Offline Offline

Posts: 1

10 topic39
«
Embed this message
Reply #9 on: November 10, 2006, 02:01:05 am »

thanks
Logged
tankw
Newbie
*
Offline Offline

Posts: 1

«
Embed this message
Reply #10 on: November 12, 2006, 11:46:31 am »

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

Logged
macavity042
Newbie
*
Offline Offline

Posts: 1

12 topic39
«
Embed this message
Reply #11 on: January 05, 2007, 03: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


Logged
garima
Newbie
*
Offline Offline

Posts: 1

«
Embed this message
Reply #12 on: March 06, 2007, 01:36:34 pm »

hello..
how can we compare RGB values of two images and show the percentage of matching..??

Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3075



WWW
«
Embed this message
Reply #13 on: March 06, 2007, 05:11:52 pm » posted from:Taipei,T'ai-pei,Taiwan

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
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3075



WWW
«
Embed this message
Reply #14 on: March 21, 2007, 05: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)

Logged
shoutroy
Newbie
*
Offline Offline

Posts: 1

«
Embed this message
Reply #15 on: May 28, 2007, 04:06:10 pm » posted from:Kuala Lumpur,Kuala Lumpur,Malaysia

please send to me this flash.i want to use it as my teaching.please.i cannot download it
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3075



WWW
«
Embed this message
Reply #16 on: May 28, 2007, 11:49:39 pm »

It is a java simulation (it is not a flash program).
You can select download or email to your account the file:image.zip
Unzip it and open rgbColor.html with your browser.

Logged
mrel
Newbie
*
Offline Offline

Posts: 2

«
Embed this message
Reply #17 on: March 03, 2008, 10:42:40 am » posted from:-,-,ICELAND

Hi, I am an undergraduate student of electrical engineering, and I am interested in math of light and pigment color mixing.

Can you please clarify your way of thinking for OR light mixing logic?
It don't make sense to me, because you say that if you put together two of the same colours like (128,0,0) + (128,0,0) you will get (128,0,0), but if you change one of them for smallest possible amount(almost indistinguishable colors) like say for example (128,0,0) + (127,0,0) you get completely different result (255,0,0)
I am not an expert on colors but I don't think it works quite that way in our eye(we don't need perturbations, and chaos theory in this).

I'm interested in colors and i would like to learn this "color math" but I want it to be at least a little more on correct side of reasoning.
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3075



WWW
«
Embed this message
Reply #18 on: March 04, 2008, 08:27:04 pm »

Yes. You are right.  Shocked It should not happened like the way you just pointed out. Tongue  This is what need to be improved. I hope someone can find out a better way of doing it (I will try to think about it,too.).  Embarrassed

The frequency response for electromagnetic wave to our eye is not a linear function. The color mixing for vision is not a simple process.

Logged
mrel
Newbie
*
Offline Offline

Posts: 2

«
Embed this message
Reply #19 on: March 05, 2008, 05:11:44 am » posted from:Belgrade,,Serbia

I gave it some thought and came up with possibility of applying fuzzy logic theory.

How about using fuzzy logic OR function for light and fuzzy logic AND function for pigment betwin each component in two of the colors normalized to 1 insted of 255 and then scaled back to 255 after evaluating, insted of using bitwise OR and AND.

Usual prototypes for fuzzy OR are: Y = X1 + X2 - X1*X2 and Y = max(X1,X2), and for fuzzy AND: Y = X1*X2 and Y = min(X1,X2), but other can be chosen.

Function prototypes for fuzzy logic can even be chosen to incorporate logarithmic behavior of human eye.
For example R = 255*log2(1 + {[2^(R1/255)-1] + [2^(R2/255)-1] - [2^(R1/255)-1]*[2^(R2/255)-1]} ) for OR, but I'm not sure what to do for AND in this case.
Also because problems that came from saturation effects on commuter interpretations, this formula can be beater adjusted for match with eye vision.

Can, you pleas give me your opinion of this thoughts? Undecided
Logged
sonu
Newbie
*
Offline Offline

Posts: 1

«
Embed this message
Reply #20 on: July 27, 2008, 06:36:51 pm »

hii,could u plz send me a copy of source code of this program in my mail id.plzz
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3075



WWW
«
Embed this message
Reply #21 on: July 28, 2008, 11:09:56 am »

I just added source code for the applet as attachement at the first posted message.
rgbLight.java is the code for the applet and fkhStage.java contains public functions used by rgbLight.java.
However, the code was written in 1999 with JDK1.0.2.
Logged
BlackRose18
Newbie
*
Offline Offline

Posts: 1

«
Embed this message
Reply #22 on: July 31, 2009, 07:23:06 pm » posted from:San Juan,Batangas,Philippines

It don't accomplish faculty to me, because you say that if you put calm two of the aforementioned colours like (128,0,0) + (128,0,0) you will get (128,0,0), but if you change one of them for aboriginal accessible amount(almost duplicate colors) like say for archetype (128,0,0) + (127,0,0) you get absolutely altered aftereffect (255,0,0)

-*-


Logged
hunter4774
Newbie
*
Offline Offline

Posts: 1

«
Embed this message
Reply #23 on: January 18, 2011, 08:41:17 pm » posted from:Kuala Selangor,Selangor,Malaysia

mr hwang..
can u please email me the java source code for this Colors..
thanks...
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3075



WWW
«
Embed this message
Reply #24 on: January 18, 2011, 09:55:00 pm » posted from:Taipei,T\'ai-pei,Taiwan

The source code is inlcuded in the same message as attached files.
Please download it by yourself! Wink
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1779


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #25 on: June 21, 2012, 01:46:54 pm » posted from:SINGAPORE,SINGAPORE,SINGAPORE

Dear Prof Hwang,

would u be interested to create a EJS version?
i search OSP and NTNU and there is EJS version of the color mixing applet yet.


i wish to adapt and create a 3 circle applet that can show the TPCK diagram
http://www.tpck.org/


for your consideration
Smiley
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1779


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #26 on: August 29, 2013, 03:50:17 pm » posted from:SINGAPORE,SINGAPORE,SINGAPORE

hi prof,
can make an EJS version for this applet!
i wish to study the source code of color mixing.
thanks!
« Last Edit: August 29, 2013, 04:09:49 pm by lookang » Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3075



WWW
«
Embed this message
Reply #27 on: August 29, 2013, 08:55:23 pm » posted from:,,Satellite Provider

EJS does not has GUI or build in library to calculate the color mixing, so I did not create an EJS version.

However, the source code is available as attached file (at the first posted message) if you want to study it.  Cheesy
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1779


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #28 on: September 03, 2013, 10:04:55 pm »

http://weelookang.blogspot.sg/2013/09/light-mixing-model.html

Light Mixing Model made in Geogebra.
http://www.geogebratube.org/student/m47961?post_id=731464494_10151686914399495#_=_
i decided to make one myself referencing some of the codes from many thanks to http://www.geogebratube.org/material/show/id/4579 Shared by ukukuku — February 12th, 2012 - 21:24

based on a conversation here http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=39, since EJS does not have the capability to create this more easier than GeoGebra.



Thinking Questions by lookang.

what do you get when red mix with green?

answer is yellow

what do you get when red mix with blue?

answer is magenta

what do you get when green mix with blue?

answer is teal

what do you get when red mix with green and blue?

answer is white
« Last Edit: September 03, 2013, 10:08:54 pm by lookang » Logged
Pages: [1] 2   Go Up
  Print  
Like what you dislike of those things are imortant. ...Wisdom
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
Shadow/Image and Color
Optics
Fu-Kwun Hwang 6 169072 Last post September 29, 2012, 12:49:16 pm
by tookkatababi
Color magic show
Optics
Fu-Kwun Hwang 5 53070 Last post July 24, 2016, 04:03:15 pm
by midas2010
How to change color to the cube_old?
Question related to Physics or physics related simulation
yliu 5 9135 Last post November 24, 2008, 07:47:20 pm
by Fu-Kwun Hwang
Two-Color Multiple Slit Diffraction
Optics
Fu-Kwun Hwang 1 8902 Last post June 23, 2015, 01:22:31 am
by elim
Example for color change and action
Examples for beginner who want to learn EJS
Fu-Kwun Hwang 2 9764 Last post September 23, 2015, 04:49:29 pm
by boyer1982
Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.594 seconds with 22 queries.since 2011/06/15