Fluoroscopy systems introduce significant image distortion. This must be corrected in MATLAB.
What you need:
- XrayProject MATLAB scripts
- Images of a punched metal grid: one for each camera
What you get:
- One undistortion transform file (*UNDTFORM.mat) per camera
When an *UNDTFORM file is created, it uses a single image of a geometric grid that is taken from the fluoroscope, and creates an undistortion algorithm that can then be applied to calibration cube images and digitized data points.
The image above shows a screenshot of the same grid, distorted on the left, and undistorted on the right.
The first step of XrayProject MATLAB procedure is creating undistortion files from grid images. Grid images are taken during each recording session, as they are specific to the particular orientation of the camera. The grid is a piece of perforated stainless steel (http://www.mcmaster.com/ part number 9358T321; sheet thickness .048"; hole diameter .125"; Center-to-Center Spacing 3/16"; Opening pattern - staggered) cut to fit the circular rim around the image intensifier. Instructions for using these grids is found on the C-arm usage pages.
Open MATLAB, and in the Command Window run the XrayProject.mat script by typing "XrayProject" and press Enter or Return.
The XrayProject workflow window will open up.
- On XrayProject Window, select the radio button "I need to create Undistortion files from Grid Images".
- Click the Undistort button that is now enabled. The Undistorter window will open.
- Click the Open Image button on the Undistorter.
- Select your grid image file (.tif, .jpg or .avi). The image will open with most of the cells filled in with red. The Gray level threshold and Size threshold sliders will be enabled. See image below.
- The goal is to use the Gray level threshold and Size threshold to fill as many complete cells as possible while excluding partial cells at the edge (thereby minimizing error at the edge).
- If you have complete cells that are showing up light colored instead of red, decrease the Gray level threshold until all of the complete cells are red (caveat: if you go too low, some of the cells may bleed into each other - this will cause the process to fail)
- Increase the Size threshold to eliminate as many partial cells around the edge as possible without causing cells in the center of the image to black out.
- You can use the Zoom in and Zoom out tools to look more closely at the red fill pattern.
- Hit the set button. Working... will appear on the Undistorter window. The process will take about 5 minutes on average (depending on your processor).
- You will see the image change such that blue asterisks fill the holes instead of the red fill. This indicates which cells were used to create the undistortion.
- You will be asked to save the undistortion transform. The default file name will be yourimagenameUNDTFORM.mat. You will need this file later XrayProject steps
- You will also be asked to save an undistorted version of your grid image as a .tif. This image will print to the screen - inspect it to make sure the grid looks more regular than your original.