项目作者: ahestevenz

项目描述 :
Python class for Image Processing and Gamma Ray detection using OpenCV, PIL and NumPy libraries
高级语言: Python
项目地址: git://github.com/ahestevenz/gamma-ray-detection.git
创建时间: 2017-04-07T17:13:26Z
项目社区:https://github.com/ahestevenz/gamma-ray-detection

开源协议:

下载


Gamma Ray Detection

gamma-ray-detection detects the high energy values when a CMOS sensor and a 10x10 matrix of collimated scintillator crystals are exposed to a radioactive source that emits gamma-ray beams. The camera and the scintillator are inside of a light-trap black box (gamma camera).

Python classes

Two python classes have been developed:

  • ImageProcessing: processes the features of the image (filtering, canny and segmentation) to get the calibration parameters, which determine the scintillator dimension.
  • GammaDetection: calculates the values of the superpixels in the 10x10 matrix and determinates the centroid. The superpixel size depends on the focal distance lens and sensor size of the camera.

Installation

Python environment

It is highly recomomended to run the training scrips inside of python environment, in case the system does not have any use the following procedure (check Virtualenvwrapper Installation for more details).

  1. $ pip install --user virtualenvwrapper virtualenv

Add three lines to your shell startup file (.bashrc, .profile, etc.) to set the location where the virtual environments should live:

  1. export WORKON_HOME=$HOME/.virtualenvs
  2. export PROJECT_HOME=$HOME/Devel
  3. source /usr/local/bin/virtualenvwrapper.sh

After editing it, reload the startup file (e.g., run source ~/.bashrc) and create a python environment:

  1. $ mkvirtualenv venv_py
  2. $ workon venv_py

Setting up the environment

Once the python environment was configured, run the following procedure to install all the required packages

  1. (venv_py)$ git clone https://github.com/ahestevenz/gamma-ray-detection
  2. (venv_py)$ cd gamma-ray-detection
  3. (venv_py)$ pip install -r requirements.txt

Python scripts

First, the equipment (camera + 10x10 matrix scintillator crystals) must be calibrated with the setCalibrationGrid.py script. In this stage images with the following features are used:

  • Light: LED inside the equipment
  • Exposure time: 1 second
  • Depth: 8-bit
  1. ahestevenz@columbia:~/IP/work/gamma-ray-detection$ python setCalibrationGrid.py -h
  2. usage: setCalibrationGrid.py [-h] -d DIRECTORY -b BACKGROUND -i INDEX
  3. [-m FRAME] [-f FILE_CALIB] [-s] [-v] [-w]
  4. optional arguments:
  5. -h, --help show this help message and exit
  6. -d DIRECTORY, --directory DIRECTORY
  7. path to directory of images acquire with the calibration
  8. set
  9. -b BACKGROUND, --background BACKGROUND
  10. path to directory of images acquire in background
  11. -i INDEX, --index INDEX
  12. image index for the image processing in the directory
  13. -m FRAME, --frame FRAME
  14. frame of the image selected, the default value is 0
  15. -f FILE_CALIB, --file_calib FILE_CALIB
  16. calibration file location
  17. -s, --show show graphics
  18. -v, --verbose verbose mode
  19. -w, --write_images save images

Then, the size of the scintillator crystal is obtained as follows,

  1. Threshold detects a square
  2. Corrected Shape
  3. | x | y | width | height |
  4. | 400 | 304 | 516 | 536 |
Edge Detection Mask Grid

Then superpixels (10x10 crystals matrix) are carried out by the getCentroids.py script. Here, images with following features are used:

  • Light: from radioactive source
  • Exposure time: 6 minutes
  • Depth: 8-bit
  1. ahestevenz@columbia:~/IP/work/gamma-ray-detection$ python getCentroids.py -h
  2. usage: getCentroids.py [-h] -r RADIOACTIVE_SOURCE -b BACKGROUND -i INDEX
  3. [-m FRAME] [-f FILE_CALIB] [-s] [-v] [-w]
  4. optional arguments:
  5. -h, --help show this help message and exit
  6. -r RADIOACTIVE_SOURCE, --radioactive_source RADIOACTIVE_SOURCE
  7. path to essay directory of images acquire with
  8. the radioactive sources
  9. -b BACKGROUND, --background BACKGROUND
  10. path to essay directory of images acquire in
  11. background
  12. -i INDEX, --index INDEX
  13. image index for the image processing in the essay
  14. directory
  15. -m FRAME, --frame FRAME
  16. frame of the image selected, the default value is 0
  17. -f FILE_CALIB, --file_calib FILE_CALIB
  18. calibration file location
  19. -s, --show show graphics
  20. -v, --verbose verbose mode
  21. -w, --write_images save images

Results

The results from getCentroids.py is a cualitative pcolor graph with the grid of superpixels, as we can observe below,

  • Essay 1
Radioactive sources location (*) Results
  • Essay 2
Radioactive sources location (*) Results

(*) Note: The picture appear mirrored respect to the results