digital fluoroscope

From Noah.org
Jump to: navigation, search

Digital Fluoroscope

First prototype was arranged in an open top cardboard box. X-ray interference was bad. I arranged some steel shielding and experimented with mirror placement so I could get the camera out of the x-ray beam. I still had a lot of trouble with backscatter. Focus was difficult. Fixed-focus cameras had poor light sensitivity and were not sharp. Autofocus cameras could not work in the dark. Scintillating screen was old and poor quality.

I discovered a good camera that was intrinsically resistant to x-rays, Logitech c910. This camera also allows manual focus, so I could set focus in the light and keep it focused in the dark. I moved my equipment upstairs where it was easier to work on and shield.

Second prototype was made in a 9*9*9 cardboard box. Fully enclosed with c910 fixed behind screen. Camera was directly in the beam. X-ray noise was reduced with applying a median filter to multiple exposures. Focus was set with box open and lights on. With box closed I set previously established focus.

Third version is made with two 9*9*9 cardboard boxes. All surfaces were sprayed with matte black paint. Boxes were glued and tapped together with black gaffers tape -- $26 a roll! But this stuff is totally light tight. All seams and edges are tapped with black gaffers tape. I cut three inches off a 12 inch square mirror. This made an almost perfect 45 degree angle. Camera takes pictures to the side of the scintillating screen, outside of the direct x-ray beam. Camera is wrapped in lead foil. This also helps since the imaging chip surface now presents a less perpendicular target, so it has a smaller cross-section. External LED lights are used to illuminate a scale under the scintillating screen in order to allow focus calibration without opening the box.

camera

My system uses a motion video camera with a USB interface (UVC).

snap-shot emulation with a motion video camera

Most low-end USB cameras have no ability to take single frame snap-shots with long exposures. I emulate a snap-shot by recording a video stream while the sensor is under exposure. The video stream recording begins just before x-ray exposure and ends just after x-ray exposure is turned off. After exposure the recorded video stream is converted to a sequence of individual frames. Artifacts caused by the recording process need to be removed. Dark frames at the beginning and end of the recording are deleted. This typically results in a sequence of 5 to 10 frames. These frames are blended into a single frame. A median algorithm for blending gives good results. A variety of post-processing techniques are used to clean up the image.

mirror

I am using a second-surface mirror. I was unable to find a large first-surface mirror at a reasonable price. First surface mirrors are also easily damaged. I am looking into purchasing some gallium metal to make a custom mirror. This will likely be more expensive than simply ordering a ready-made first-surface mirror, but this gives me the option to repair the mirror. Gallium is relatively safe to handle; although, it will cause many metals, especially aluminum, to rot and crumble.

noise

See also:

fixed pattern noise

dark frame subtraction, dark field subtraction, flat field correction

LRGB (Luminance, Red, Green and Blue) is a used in amateur astronomy combining a high-quality black-and-white image with a lower-quality color image.

bias frame

screen noise: The scintillation screen and mirror have large surfaces that collect more dust relative to the other parts of the optical system. Dust and dirt on these components also creates high-contrast noise as opposed to dust on the camera lens which creates log-contrast noise because the dust is out of the focal plane.

mirror ghost image: The mirror will be a source of a ghost image if the mirror is not a first surface mirror. The glass creates a second reflection, which is slightly offset from the main reflection from the metal layer of the mirror. A first surface mirror will create a much better image, but first surface mirrors are more expensive and are easily damaged... Using gallium metal to custom make a mirror is an alternative I plan to attempt.

x-ray photons: back-scatter x-ray photons often strike the image sensor and cause spot flashes. The occur in random locations and usually affect several pixels near each other. These spot flashes are best prevented with shielding and optics geometry. Some spots will remain in the video stream, which are removed by combining several exposures using a blending algorithm (median). Despeckling does not work well because the spots are usually too big for the algorithm to distinguish them.

aliasing: appears as a flicker in the video stream. A single frame will show dark and light bands. Most x-ray heads actually flicker at 30 Hz (probably 25 Hz in Europe), which is half-cycle of the AC power mains. A motion video camera recording at any given frame rate will fixed pattern noise

dark frame noise: see DSNU

photo response non-uniformity (PRNU) variation of pixel responsivity under illumination.

dark signal non-uniformity (DSNU) variation of pixel responsivity when not illuminated (dark).

processing tools

gst-launch v4l2src device=/dev/video1 ! video/x-raw-yuv,width=640,framerate=30/1 ! xvimagesink 
guvcview --control_only --device=/dev/video1 
devinfo.py /dev/video0 
focuswatcher.py changes /dev/video1 
v4l2ucp /dev/video1 
v4l2ctrl -d /dev/video1 -s video1.conf 
v4l2-ctl --all --device=/dev/video1 -L 
v4l2-ctl --device=/dev/video1 --list-ctrls 
v4l2-ctl --device=/dev/video1 --list-ctrls-menus 
v4l2-ctl --device=/dev/video1 --get-ctrl=focus_absolute 
v4l2-ctl --device=/dev/video1 --set-ctrl=focus_absolute=160 
convert -evaluate-sequence Median frames*.png frames-median.png 
imagej 
mplayer -nosound -vo png movie.mov 
mplayer "mf://frames*.png" -mf fps=10 -loop 0 
mencoder -vf rotate=3 "mf://*.png" -mf fps=15 \
                      "mf://*.png" -mf fps=15 \
                      "mf://*.png" -mf fps=15 \
                      "mf://*.png" -mf fps=15 \
                      "mf://*.png" -mf fps=15 \
         -o movie.mov -ovc lavc -lavcopts vcodec=mpeg4

# Convert video to a format that may be viewed on an iphone.
ffmpeg -i movie.mov -vcodec mpeg4 -b 1200kb -mbd 2 -cmp 2 -subcmp 2 -s 480x640 movie-iphone.mov 

# Play a video. Add '''-idx''' option to allow seeking in raw MJPEG streams.
mplayer -idx movie.mov

# Generate a log of PNG filename and corresponding average image brightness.
# This is used to identify black frames and to find clusters of bright frames.
for fn in *.png; do echo -n "${fn} : "; convert ${fn} -colorspace gray -scale 1x1 -format "%[fx:floor(1000*g)]" info:; done | tee -a gray_average.log

# Rotate an image frame counter-clockwise.
convert -rotate -90 seq-170.png test.png 

# Crop a frame to size 400x400, offset by (10,280).
# Note the use of the '''+repage''' option!!!
# ImageMagick rarely does the intuitive thing, so there are lots
# little tricky details like this to get ImageMagick operations to work properly.
convert -crop 400x400+10+280 +repage frame_001.png test.png

# This takes a slice (#280) from a set of images used to 
# generate a Radon projection. This example assumes the
# originals are 400 pixels wide.
convert -crop 400x1+0+280 +repage seq-*.png slice-%03d.png 
montage slice-*.png -mode Concatenate -tile 1x radon.png

glass shielding

Lead glass or flint glass may be used for x-ray shielding. Look for optical glass window. It may be that density and lead content of glass not specifically intended for radiation shielding is suitable. Even ordinary glass has some limited shielding effect.

Prices for x-ray glass shielding are very high. One of the few places I found with reasonable prices is UQG Optics Lead Glass. Even including the absurd $50 shipping from the UK it's still cheaper than anything else I've found.