Welcome to Laser Pointer Forums - discuss green laser pointers, blue laser pointers, and all types of lasers

LPF Donation via Stripe | LPF Donation - Other Methods

Links below open in new window

ArcticMyst Security by Avery

Convert Wavelength (nm) to RGB & HEX - Online Calculator

HIMNL9

0
Joined
May 26, 2009
Messages
5,318
Points
0
Auto balances are easy to disable in drivers, the worse problem is, as said, the resout of interferent colors ..... i mean, if the CCD get red and blue on the same pixels, it read "magenta", that is not a wavelenght, but the combination of two different colors.

Maybe the more easy and accurate system for not get those errors is the "pseudo-monochromator" system ..... i had built a setup similar to this, in the past (but then i broke the prisms, and actually it's lost somewhere) ..... the light was diffracted from prisms, then shooted on a linear CCD i got from an old HP scanner, and the CCD was simply drived for give out a data stream with a trigger signal at the start, so it was visualized on an oscilloscope.

There was some main problems, anyway ..... the output was not linear (each tipology of sensors have its own sensitivity curve, and i had no ways for make a correction amplifier that follow an irregular curve) ..... also, the spectrum was a bit compressed on the red side, due to the usual nonlinearity of the prisms in light diffraction ..... diffraction gratings are more linears (also they have problems, they compress a bit more the BLUE side, opposite to the prisms ..... i'm wondering if this can be corrected shooting first the light in a prism, and then through a grating) ..... anyway, i suppose it can be done, with some little optomechanical works ..... for me the main problem is not the hardware part, is the software part :p

Uhm, i think i have to start to make some experiments, when i get a decent glass grating (or, anyway, a decent grating with the maximum possible lines-per-mm)


@Leo: sorry, but they are secondary colors, made from the add-on of two different "primary" colors ..... so, as example, magenta is not a wavelenght, is just the interaction of two different wavelenghts in our eyes.
 





rhd

0
Joined
Dec 7, 2010
Messages
8,475
Points
0
combined HEX values.

Actually they have a wavelength because light is emitted in waves so, if it is visible, it has a wavelength (or more). :D

That's definitely not the case. Any magenta on the Line of purples) for example, cannot have a single corresponding wavelength. You can combine red and violet wavelengths to achieve the colour, the same way you can combine red and green to get yellow, but unlike yellow, magenta does not have a wavelength.

If you think this is an inaccurate claim, try to come up with a wavelength for THIS COLOUR, which is probably #FF00FF.
 

HIMNL9

0
Joined
May 26, 2009
Messages
5,318
Points
0
^ this is cause, being between two adjacent (primary) colors, yellow is in the spectrum, same as colors combined from green and blue, and their variants.

But magenta is made combining two colors that are at the opposite sides of the spectrum, so it cannot be part of the spectrum itself as single color.
 

rhd

0
Joined
Dec 7, 2010
Messages
8,475
Points
0
Agreed. That was exactly my point - Not every HEX/RGB value will have a wavelength.

Some hex values produce colours hat don't exist on the spectrum anywhere. Like, as mentioned, the hex value for magenta. It is impossible to convert this into a wavelength, because magenta can only be produced by combining multiple different wavelengths.
 

rhd

0
Joined
Dec 7, 2010
Messages
8,475
Points
0
FYI - I tweaked the calculator a bit so that it displays properly in modern smartphones (IE, androids etc with moderately good screens)
 

rhd

0
Joined
Dec 7, 2010
Messages
8,475
Points
0
You're right - that's the threshold were falloff begins to be implemented - but it wasn't done properly. I'll adjust this afternoon. Typo in my code :(
 

rhd

0
Joined
Dec 7, 2010
Messages
8,475
Points
0
Fixed - thanks for the alert :)

For anyone that used the indicated values and wants to revise to reflect the adjustment to code here - the problem had affected wavelengths below 420 and above 700. Nothing else changed.
 

mpagel

0
Joined
May 18, 2011
Messages
2
Points
0
This is a really cool web application. Thanks for making this.

I'm considering adapting this to absorption, rather than emission spectra as well as taking into account multiple peaks.

I think I'll start off with the simple case of a user just inputting a wavelength, determining the color that it would be if this was the emission spectrum and subtracting the ensuing hex value from #FFFFFF (i.e. inverting the wavelength). Or would I have to do a crazy conversion to CMYK colorspace first? Or alternatively, does this result in an undersampling or oversampling of "yellow" colors (which are such a small band in the UV/vis spectrum). Or is this entirely not the correct approach (e.g. is it not as simple as inverting RGB/CMYK to go to absorption spectra).

Eventually I want to take an entire input spectrum (csv or R-array) and show a little box of what the expected color of this pigment would be. Essentially normalizing the data to the max absorption peak (setting the peak at a value of 1) - then take the inverse of this (1-value) and somehow determining the corresponding maximum/average "emission" (or rather transmission). I don't know if I'd have to do a logarithmic transformation or anything...

If you have any tips on this or alternatively wish to work with me on developing this tool, it'd be much appreciated. Most of my experience is in PHP and mysql databases, but I have a bit of experience programming in python and R [cran.r-project.org] (which I believe would be ideal for processing these CSVs and outputting good plots). I also have a series of datasets of ~200-900nm and know (approximately) what the color SHOULD be.

There's a chance this resulting application will be used in an academic publication, but I don't have any plans for a commercial application, so was planning on doing either open-source or you-contact-me-and-I'll-probably-share-the-source-with-you.

Alternatively, if you know something like this has already been developed, please let me know, so I don't waste my time;)

Thanks for your time
 

mpagel

0
Joined
May 18, 2011
Messages
2
Points
0
I *may* have found a solution.

https://r-forge.r-project.org/R/?group_id=160 has the "spectral" package, which as I understand it implements a more accurate representation of RGB colorspace (I think considers the overall luminosity of a color, as our eyes are attuned to some frequencies more than others, which should be more appropriate for my application)

Currently having some difficulties installing the appropriate libraries.

See https://r-forge.r-project.org/forum/forum.php?thread_id=3645&forum_id=493&group_id=160

(I have since been able to install the dialectric package via
install.packages("C:\\R\\packages\\photonics\\pkg\\dielectric",type="source",repos=NULL), but have not been successful with the other 3 and still get the same 3 errors upon script execution)
 

fuf

0
Joined
Mar 12, 2012
Messages
2
Points
0
rhdThank you for this useful calculator

Is there a reverse operation for finding out wavelength for given RGB?
Not talking about "RGB to wavelength problem", I see a lot of discussions in google results, but my question is much simple
I mean... You put in calculator (in this one or in other web calculator) certain wavelength and it gives three certain RGB values. This set of RGB corresponds to certain wavelength.

Where can I find tables or data with nm and corresponding RGB values?
Thank you in advance.
:)

Edit- I found http://www.uvm.edu/~kspartal/Physlets/Lecturedemo/LambdaToRGB.html and it gives the other results, but both calculators use the same algorithm :undecided: or the same algorithm plus developer's adds?
 
Last edited:

rhd

0
Joined
Dec 7, 2010
Messages
8,475
Points
0
I'm not really sure what you're looking for. You just want to go backwards from RGB to wavelength?

You have to first understand that not every RGB value has a corresponding Wavelength. As long as you understand this, then you really could just apply the formula in reverse, could you not?
 

fuf

0
Joined
Mar 12, 2012
Messages
2
Points
0
Sorry my awkward writing style
I understand, but I have neither formula nor programmer
It would take too much time to put manually every wavelength and writing down RGB set for it. I just wonder if these pairs "nm-RGB" can be found in form of tables or datasheets
(longer alternative way is RGB->XYZ->dominant wavelength)
 
Last edited:

rhd

0
Joined
Dec 7, 2010
Messages
8,475
Points
0
Sorry my awkward writing style
I understand, but I have neither formula nor programmer
It would take too much time to put manually every wavelength and writing down RGB set for it. I just wonder if these pairs "nm-RGB" can be found in form of tables or datasheets

Not that I know of, but they might be.

If you're not a programmer, why not just take the math and put it into Excel? Then you could rapidly populate a table?
 





Top