|
interpreting images produced by a spectroscope |
hammeraxe
Member #9,488
February 2008
|
for my school physics essay i have produced a number of images with a spectroscope |
Thomas Harte
Member #33
April 2000
|
I'm a bit confused, are you asking how to take an image like this: {"name":"Daylight.gif","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/b\/bbe49deddd5cd6bddb22498d8592af54.gif","w":374,"h":249,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/b\/b\/bbe49deddd5cd6bddb22498d8592af54"} And read the values off the graph into your own program? Do you know the size of the scale in advance? If not, is it too much effort for you to enter scales and have the program do the rest? And are your graphs coloured the same as the one shown here? If so, it should be a relatively easy task of scanning around using getpixel, looking for the first line with a red pixel in it, then on that and each subsequent column scanning from the top to find the first red pixel, then down to the first black pixel after that to work out the height. Then you know the height at that point (i.e. distance along y) and the number of columns across (i.e. distance along x), so if you know the scale then you can get the information you want. [My site] [Tetrominoes] |
LennyLen
Member #5,313
December 2004
|
I assume he wants to interpret these: {"name":"Daylight.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/5\/f57ac34f9f398ba8d54aa670c5768a1f.jpg","w":250,"h":90,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/5\/f57ac34f9f398ba8d54aa670c5768a1f"} With the intention of producing such a graph.
|
Thomas Harte
Member #33
April 2000
|
I'm a science thicky — is the graph just the intensity of each column of that? If so, then try this to convert an (r,g,b) triplet to an intensity: /* GetIntensity returns a value between 0 (black) and 1 (brightest) */ float GetIntensity(int r, int g, int b) { return 0.299f*((float)r / 255.0f) + 0.587f*((float)g / 255.0f) + 0.114f*((float)b / 255.0f); } EDIT: that's the CCIR 601 standard conversion from R, G, B to Y, U, V but with the U and V missing. It's the way that colour television is encoded — brightness is one channel, colour information is in two other channels. That's why colour TV transmissions can be picked up and displayed by black and white televisions that were invented before colour television. [My site] [Tetrominoes] |
Schyfis
Member #9,752
May 2008
|
Quote:
I assume he wants to interpret these:
I would assume that as well. Your best bet is to write the program yourself, just convert whatever formulas you have into code. It's definitely possible to create a graph like that from pixel information alone, seeing as the person who made that website did just that. ________________________________________________________________________________________________________ |
Matthew Leverton
Supreme Loser
January 1999
|
I ran one test, and TH's code provides fairly similar graphs. The graphs on the website are a bit more exaggerated than what Open Office gave me, but that could be due to it trying to smooth out the lines. |
hammeraxe
Member #9,488
February 2008
|
thanks everyone, I'll try that as soon as possible Thomas: what is the algorithm you are using to convert the colours? why are the constants the way they are? and why exactly R,G and B are in the range from 0 to 1 not from 0 to 256? i tried to look for CCIR 601 but all i found was some cumbersome theoretical information and this Y = (0.257 * R) + (0.504 * G) + (0.098 * B) + 16 which has different constants |
gnolam
Member #2,030
March 2002
|
Quote: why are the constants the way they are? Because of the frequency response of the average human eye. -- |
hammeraxe
Member #9,488
February 2008
|
hmmm... i tried it on two pics. one went fine but the other returned 1 for every pixel. EDIT:
apparently its too late for programming... good night |
Thomas Harte
Member #33
April 2000
|
Sorry, I'm a C++ thickie, shouldn't: cin>>j; cin.get(); cause your program to wait for the user to enter something? Can anyone else confirm or deny that it is likely to work with Allegro/Windows progerams? [My site] [Tetrominoes] |
Timorg
Member #2,028
March 2002
|
White space isn't read in by >>, so it leaves the '\n' in the stream, which you need to remove. ____________________________________________________________________________________________ |
hammeraxe
Member #9,488
February 2008
|
the problem is that even the terminal/command line doesnt show up so i cant enter anything... all i get is a black window that can only be killed by killing the process EDIT: never mind, I got it to work |
|