{"id":319,"date":"2024-03-09T20:07:33","date_gmt":"2024-03-09T20:07:33","guid":{"rendered":"https:\/\/www.photometric.io\/blog\/?p=319"},"modified":"2024-05-19T13:06:51","modified_gmt":"2024-05-19T13:06:51","slug":"vis-spectrometer-wavelength-calibration","status":"publish","type":"post","link":"https:\/\/www.photometric.io\/blog\/vis-spectrometer-wavelength-calibration\/","title":{"rendered":"VIS Spectrometer &#8211; Wavelength Calibration"},"content":{"rendered":"\n<p>When you take an image with a spectrometer, you don&#8217;t get calibrated intensity readings for each wavelength. Instead you get a unitless intensity value for each pixel, which is not particularly useful. There are two steps to making sense of this measurement. Firstly, mapping each pixel to its corresponding wavelength and secondly, adjusting the intensity values at each wavelength to compensate for any wavelength dependent efficiency of the device.<\/p>\n\n\n\n<p>In order to find out which pixel corresponds to which wavelength we need to capture the spectrum of a known source. For the visible range a CFL bulb is perfect. It&#8217;s cheap and will provide several emission lines over the visible spectrum.<\/p>\n\n\n\n<p>A completely uncalibrated capture will look like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" width=\"955\" height=\"498\" src=\"https:\/\/www.photometric.io\/blog\/wp-content\/uploads\/2024\/03\/cfl_raw.png\" alt=\"raw spectrum capture of a fluorescent light\" class=\"wp-image-321\" style=\"width:782px;height:auto\" srcset=\"https:\/\/www.photometric.io\/blog\/wp-content\/uploads\/2024\/03\/cfl_raw.png 955w, https:\/\/www.photometric.io\/blog\/wp-content\/uploads\/2024\/03\/cfl_raw-300x156.png 300w, https:\/\/www.photometric.io\/blog\/wp-content\/uploads\/2024\/03\/cfl_raw-768x400.png 768w\" sizes=\"(max-width: 955px) 100vw, 955px\" \/><\/figure>\n\n\n\n<p>For each peak we need to write down both the pixel number as well as its wavelength. Labelled spectral lines can be found here: <a href=\"https:\/\/en.wikipedia.org\/wiki\/File:Fluorescent_lighting_spectrum_peaks_labelled.gif\" target=\"_blank\" rel=\"noopener\">https:\/\/en.wikipedia.org\/wiki\/File:Fluorescent_lighting_spectrum_peaks_labelled.gif<\/a><\/p>\n\n\n\n<p>When we have several of those points we can do a polynomial fit through all of them to get a simple mapping function. I found a 3rd degree polynomial to work well, although the relationship is highly linear anyways:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" width=\"982\" height=\"667\" src=\"https:\/\/www.photometric.io\/blog\/wp-content\/uploads\/2024\/03\/wavelength_cal.png\" alt=\"plotted polynomial fit of the spectrometer wavelength calibration\" class=\"wp-image-322\" style=\"width:799px;height:auto\" srcset=\"https:\/\/www.photometric.io\/blog\/wp-content\/uploads\/2024\/03\/wavelength_cal.png 982w, https:\/\/www.photometric.io\/blog\/wp-content\/uploads\/2024\/03\/wavelength_cal-300x204.png 300w, https:\/\/www.photometric.io\/blog\/wp-content\/uploads\/2024\/03\/wavelength_cal-768x522.png 768w\" sizes=\"(max-width: 982px) 100vw, 982px\" \/><\/figure>\n\n\n\n<p>We can use this polynomial to map each pixel to its corresponding wavelength and plot the result like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"943\" height=\"609\" src=\"https:\/\/www.photometric.io\/blog\/wp-content\/uploads\/2024\/03\/cfl.png\" alt=\"calibrated spectrum capture of a fluorescent light\" class=\"wp-image-323\" srcset=\"https:\/\/www.photometric.io\/blog\/wp-content\/uploads\/2024\/03\/cfl.png 943w, https:\/\/www.photometric.io\/blog\/wp-content\/uploads\/2024\/03\/cfl-300x194.png 300w, https:\/\/www.photometric.io\/blog\/wp-content\/uploads\/2024\/03\/cfl-768x496.png 768w\" sizes=\"(max-width: 943px) 100vw, 943px\" \/><\/figure>\n\n\n\n<p>You can use this MATLAB script to get started. I&#8217;ve also included a sample measurement from my scanner. The output of pyCCDGUI needs to be adapted to match this format.<\/p>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-ddc6f5a2-041a-477c-a78b-7bcae4d946b7\" href=\"https:\/\/www.photometric.io\/blog\/wp-content\/uploads\/2024\/03\/wavelength_calibration.zip\">wavelength_calibration<\/a><a href=\"https:\/\/www.photometric.io\/blog\/wp-content\/uploads\/2024\/03\/wavelength_calibration.zip\" class=\"wp-block-file__button wp-element-button\" aria-describedby=\"wp-block-file--media-ddc6f5a2-041a-477c-a78b-7bcae4d946b7\" download>Download<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>When you take an image with a spectrometer, you don&#8217;t get calibrated intensity readings for each wavelength. Instead you get a unitless intensity value for each pixel, which is not particularly useful. There are two steps to making sense of this measurement. Firstly, mapping each pixel to its corresponding wavelength and secondly, adjusting the intensity [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"_links":{"self":[{"href":"https:\/\/www.photometric.io\/blog\/wp-json\/wp\/v2\/posts\/319"}],"collection":[{"href":"https:\/\/www.photometric.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.photometric.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.photometric.io\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.photometric.io\/blog\/wp-json\/wp\/v2\/comments?post=319"}],"version-history":[{"count":5,"href":"https:\/\/www.photometric.io\/blog\/wp-json\/wp\/v2\/posts\/319\/revisions"}],"predecessor-version":[{"id":345,"href":"https:\/\/www.photometric.io\/blog\/wp-json\/wp\/v2\/posts\/319\/revisions\/345"}],"wp:attachment":[{"href":"https:\/\/www.photometric.io\/blog\/wp-json\/wp\/v2\/media?parent=319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.photometric.io\/blog\/wp-json\/wp\/v2\/categories?post=319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.photometric.io\/blog\/wp-json\/wp\/v2\/tags?post=319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}