Skip to content

Python class for Image Processing and Gamma Ray detection using OpenCV, PIL and NumPy libraries

Notifications You must be signed in to change notification settings

ahestevenz/gamma-ray-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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).

$ 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:

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

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

$ mkvirtualenv venv_py 
$ workon venv_py

Setting up the environment

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

(venv_py)$ git clone https://github.com/ahestevenz/gamma-ray-detection
(venv_py)$ cd gamma-ray-detection
(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
ahestevenz@columbia:~/IP/work/gamma-ray-detection$ python setCalibrationGrid.py -h
usage: setCalibrationGrid.py [-h] -d DIRECTORY -b BACKGROUND -i INDEX
                             [-m FRAME] [-f FILE_CALIB] [-s] [-v] [-w]

optional arguments:
  -h, --help            show this help message and exit
  -d DIRECTORY, --directory DIRECTORY
                        path to directory of images acquire with the calibration
                        set
  -b BACKGROUND, --background BACKGROUND
                        path to directory of images acquire in background
  -i INDEX, --index INDEX
                        image index for the image processing in the directory
  -m FRAME, --frame FRAME
                        frame of the image selected, the default value is 0
  -f FILE_CALIB, --file_calib FILE_CALIB
                        calibration file location
  -s, --show            show graphics
  -v, --verbose         verbose mode
  -w, --write_images    save images

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

Threshold detects a square

Corrected Shape
| x | y | width | height |
| 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
ahestevenz@columbia:~/IP/work/gamma-ray-detection$ python getCentroids.py -h
usage: getCentroids.py [-h] -r RADIOACTIVE_SOURCE -b BACKGROUND -i INDEX
                       [-m FRAME] [-f FILE_CALIB] [-s] [-v] [-w]

optional arguments:
  -h, --help            show this help message and exit
  -r RADIOACTIVE_SOURCE, --radioactive_source RADIOACTIVE_SOURCE
                        path to essay directory of images acquire with
                        the radioactive sources
  -b BACKGROUND, --background BACKGROUND
                        path to essay directory of images acquire in
                        background
  -i INDEX, --index INDEX
                        image index for the image processing in the essay
                        directory
  -m FRAME, --frame FRAME
                        frame of the image selected, the default value is 0
  -f FILE_CALIB, --file_calib FILE_CALIB
                        calibration file location
  -s, --show            show graphics
  -v, --verbose         verbose mode
  -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

About

Python class for Image Processing and Gamma Ray detection using OpenCV, PIL and NumPy libraries

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages