Skip to content

ClementKim/spectrometer

Repository files navigation

Compressive Sensing Spectrometer

This project demonstrates a compressive sensing-based spectrometer. It reconstructs spectral data from a set of measurements using an L1-regularized least squares algorithm. The project includes scripts for theoretical calculations, experimental data processing, and the core recovery algorithm.

Dependencies

The following Python libraries are required to run this project:

  • opencv-python
  • numpy
  • scipy
  • matplotlib

You can install these dependencies using pip:

pip install opencv-python numpy scipy matplotlib

How to Run

The main execution script is run.sh. This script runs the main.py file in three different modes, with the output of each mode being saved to a text file.

./run.sh

This will generate the following files:

  • filter_experiment_result.txt: Contains the transmission, reflection, and absorption data for each of the 36 filters, based on the experimental data in the present-filter-picture/ directory.
  • wavelength_experiment_result.txt: Contains the transmission, reflection, and absorption data for different wavelengths, based on the recovered spectral data.
  • theorical_result.txt: Contains the theoretically calculated transmission, reflection, and absorption data for the filters.

Project Structure

  • main.py: The main script of the project. It can be run in three different modes to perform theoretical calculations, experimental data processing, and analysis of the recovered data.
  • cs_recovery.py: Contains the core compressive sensing recovery algorithm. It reads the measurement data, applies the reconstruction algorithm, and saves the recovered data.
  • l1_ls_nonneg.py: Implements the L1-regularized least squares with non-negativity constraints algorithm used for the reconstruction.
  • wb_Find_IR_filter.py: A script for designing and analyzing wideband infrared cut-off filters using the transfer matrix method.
  • run.sh: The main execution script that runs the different modes of the project.
  • meas/: This directory contains the measurement data, which is generated by main.py from the images in present-filter-picture/.
  • recovered/: This directory contains the recovered spectral data, which is generated by cs_recovery.py.
  • present-filter-picture/: This directory contains the raw images of the filters used for the experimental measurements.
  • *.png: These are image files that visualize the results of the reconstruction and analysis.

Workflow

The project follows this general workflow:

  1. Measurement Processing: The experimental_t_r_a_by_filter() function in main.py processes the images in the present-filter-picture/ directory. It crops the 36 filter squares from each image, calculates the average intensity, and saves the data as .mat files in the meas/ directory.

  2. Compressive Sensing Recovery: The cs_recovery() function in cs_recovery.py is called to perform the spectral reconstruction. It reads the measurement data from the meas/ directory, uses the sensing matrix and the l1_ls_nonneg algorithm to recover the spectral data for each pixel, and saves the results as .mat files in the recovered/ directory.

  3. Analysis: The experimental_t_r_a() function in main.py analyzes the recovered spectral data. It calculates and prints the transmission, reflection, and absorption for different wavelengths.

  4. Theoretical Calculation: The theorical_t_r_a() function in main.py calculates the theoretical transmission, reflection, and absorption of the filters based on their physical properties.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors