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.
The following Python libraries are required to run this project:
opencv-pythonnumpyscipymatplotlib
You can install these dependencies using pip:
pip install opencv-python numpy scipy matplotlibThe 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.shThis 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 thepresent-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.
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 bymain.pyfrom the images inpresent-filter-picture/.recovered/: This directory contains the recovered spectral data, which is generated bycs_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.
The project follows this general workflow:
-
Measurement Processing: The
experimental_t_r_a_by_filter()function inmain.pyprocesses the images in thepresent-filter-picture/directory. It crops the 36 filter squares from each image, calculates the average intensity, and saves the data as.matfiles in themeas/directory. -
Compressive Sensing Recovery: The
cs_recovery()function incs_recovery.pyis called to perform the spectral reconstruction. It reads the measurement data from themeas/directory, uses the sensing matrix and thel1_ls_nonnegalgorithm to recover the spectral data for each pixel, and saves the results as.matfiles in therecovered/directory. -
Analysis: The
experimental_t_r_a()function inmain.pyanalyzes the recovered spectral data. It calculates and prints the transmission, reflection, and absorption for different wavelengths. -
Theoretical Calculation: The
theorical_t_r_a()function inmain.pycalculates the theoretical transmission, reflection, and absorption of the filters based on their physical properties.