Sciencemadness Discussion Board

Spectral Image To "Raw" Data

smaerd - 13-5-2015 at 05:15

So I ran into a pretty huge issue the other week. I was left in a situation where I did not have access to the raw data of an FT-IR spectra but had images of it. I needed peak locations and the graduations on the spectra were not fine at all.

After not being able to find a soft-ware suite to open the raw data files I had, I knew I was in a bad spot. My report was due in a couple days. I found soft-ware/free-ware that could convert 'some' images back into data, but they lacked the ability to do this with spectra (too complicated I think?). Necessity is the mother of invention I guess.
I wrote a program (has a few flaws and pretty limited) in JAVA to turn these images into CSV (comma separated value files) which nearly any serious soft-ware suite can access and retrieve values from.

If anyone else finds themselves in a similar spot I will provide the source code (attached). This same type of algorithm could work for things like UV-VIS, or 1D NMR.

screenshot.jpg - 311kB

The code currently assumes a few things...
1. The background color of the spectra is white, the boundaries/graduations are in black
2. The spectra/data set is in another color which can be specified by RGB minimum and maximum values
3. The boundaries of the spectra can be found at exactly half its height and width (IE: there are no graduations or text preceeding these locations).
4. That only the minimum and maximum y values at any given X value matters

I will admit, the data doesn't come out exactly how it looks in the image, with very fine transitions and large zooming things get a little buggy but, the peak locations remain solid as far as I have seen. I can think of a few ways to fix several flaws in the algorithm, but I no longer need the program. So I figured I would open the project up to the community.

It could help someone out of a jam! It definitely saved my ass... In true open source fashion here ya go:

Attachment: (10kB)
This file has been downloaded 1191 times

[Edited on 13-5-2015 by smaerd]

m1tanker78 - 13-5-2015 at 15:57

I've been in a similar jam before. Nice thinking-outside-the-box solution to the problem. What's the format of the original image file?

smaerd - 13-5-2015 at 17:08

The original file format is a .bmp file. Which was a copy and paste of an OLE object that I had dragged into a powerpoint presentation (how I typically mass transfer FT-IRs). Thanks, it was the only thing that I could think to do.

[Edited on 14-5-2015 by smaerd]

Chemosynthesis - 15-5-2015 at 17:33

Pretty impressive. Even though I don't see myself requiring this type of code anymore, I am glad to see it.