RECON3
The RECON3 function can reconstruct a three-dimensional data array from two or more images (or projections) of an object. For example, if you placed a dark object in front of a white background and then photographed it three times (each time rotating the object a known amount) then these three images could be used with RECON3 to approximate a 3-D volumetric representation of the object. RECON3 also works with translucent projections of an object. RECON3 returns a 3-D byte array.
This routine is written in the IDL language. Its source code can be found in the file recon3.pro
in the lib
subdirectory of the IDL distribution.
Using RECON3
Images used in reconstruction should show strong light/dark contrast between the object and the background. If the images contain low (dark) values where the object is and high (bright) values where the object isn’t, the MODE keyword should be set to +1 and the returned volume will have low values where the object is, and high values where the object isn’t. If the images contain high (bright) values where the object is and low (dark) values where the object isn’t, the MODE keyword should be set to -1 and the returned volume will have high values where the object is, and low values where the object isn’t.
In general, the object must be CONVEX for a good reconstruction to be possible. Concave regions are not easily reconstructed. An empty coffee cup, for example, would be reconstructed as if it were full.
The more images the better. Images from many different angles will improve the quality of the reconstruction. It is also important to supply images that are parallel and perpendicular to any axes of symmetry. Using the coffee cup as an example, at least one image should be looking through the opening in the handle. Telephoto images are also better for reconstruction purposes than wide angle images.
Syntax
Result = RECON3( Images, Obj_Rot, Obj_Pos, Focal, Dist,Vol_Pos, Img_Ref, Img_Mag, Vol_Size [, /CUBIC] [, MISSING=value] [, MODE=value] [, /QUIET])
Return Value
Returns a 3-D data array.
Arguments
Images
A 3-D array containing the images to use to reconstruct the volume. Execution time increases linearly with more images. Images must be an 8-bit (byte) array with dimensions (x, y, n) where x is the horizontal image dimension, y is the vertical image dimension, and n is the number of images. Note that n must be at least 2.
Obj_Rot
A 3 x n floating-point array specifying the amount the object is rotated to make it appear as it does in each image. The object is first rotated about the X axis, then about the Y axis, and finally about the Z axis (with the object’s reference point at the origin). Obj_Rot[0, *] is the X rotation for each image, Obj_Rot[1, *] is the Y rotation, and Obj_Rot[2, *] is the Z rotation.
Obj_Pos
A 3 x n floating-point array specifying the position of the object’s reference point relative to the camera lens. The camera lens is located at the coordinate origin and points in the negative Z direction (the view up vector points in the positive Y direction). Obj_Pos should be expressed in this coordinate system. Obj_Pos[0, *] is the X position for each image, Obj_Pos[1, *] is the Y position, and Obj_Pos[2, *] is the Z position. All the values in Obj_Pos[2, *] should be less than zero. Note that the values for Obj_Pos, Focal, Dist, and Vol_Pos should all be expressed in the same units (mm, cm, m, in, ft, etc.).
Focal
An n-element floating-point array specifying the focal length of the lens for each image. Focal may be set to zero to indicate a parallel image projection (infinite focal length).
Dist
An n-element floating-point array specifying the distance from the camera lens to the image plane (film) for each image. Dist should be greater than Focal.
Vol_Pos
A 3 x 2 floating-point array specifying the two opposite corners of a cube that surrounds the object. Vol_Pos should be expressed in the object’s coordinate system relative to the object’s reference point. Vol_Pos[*, 0] specifies one corner and Vol_Pos[*, 1] specifies the opposite corner.
Img_Ref
A 2 x n integer or floating-point array that specifies the pixel location at which the object’s reference point appears in each of the images. Img_Ref[0, *] is the X coordinate for each image and Img_Ref[1, *] is the Y coordinate.
Img_Mag
A 2 x n integer or floating-point array that specifies the magnification factor for each image. This number is actually the length (in pixels) that a test object would appear in an image if it were n units long and n units distant from the camera lens. Img_Mag[0, *] is the X dimension (in pixels) of a test object for each image, and Img_Mag[1, *] is the Y dimension. All elements in Img_Mag should be greater than or equal to 1.
Vol_Size
A 3-element integer or floating-point array that specifies the size of the 3-D byte array to return. Execution time (and resolution) increases exponentially with larger values for Vol_Size. Vol_Size[0] specifies the X dimension of the volume, Vol_Size[1] specifies the Y dimension, and Vol_Size[2] specifies the Z dimension.
Keywords
CUBIC
Set this keyword to use cubic interpolation. The default is to use tri-linear interpolation, which is slightly faster.
MISSING
Set this keyword equal to a byte value for cells in the 3-D volume that do not map to any of the supplied images. The value of MISSING is passed to the INTERPOLATE function. The default value is zero.
MODE
Set this keyword to a value less than zero to define each cell in the 3-D volume as the minimum of the corresponding pixels in the images. Set MODE to a value greater than zero to define each cell in the 3-D volume as the maximum of the corresponding pixels in the images. If MODE is set equal to zero then each cell in the 3-D volume is defined as the average of the corresponding pixels in the images.
MODE should usually be set to -1 when the images contain a bright object in front of a dark background or to +1 when the images contain a dark object in front of a light background. Setting MODE=0 (the default) requires more memory since the volume array must temporarily be kept as an integer array instead of a byte array.
QUIET
Set this keyword to suppress the output of informational messages when the processing of each image is completed.
Examples
Assumptions for this example:
- The object’s major axis is parallel to the Z axis.
- The object’s reference point is at its center.
- The camera lens is pointed directly at this reference point.
- The reference point is 5000 mm in front of the camera lens.
- The focal length of the camera lens is 200 mm.
If the camera is focused on the reference point, then the distance from the lens to the camera’s image plane must be:
dist = (d * f) / (d - f) = (5000 * 200) / (5000 - 200) = (1000000 / 4800) = 208.333 mm
The object is roughly 600 mm wide and 600 mm high. The reference point appears in the exact center of each image.
If the object is 600 mm high and 5000 mm distant from the camera lens, then the object image height must be:
hi = (h * f) / (d - f) = (600 * 200) / (5000 - 200) = (120000 / 4800) = 25.0 mm
The object image appears 200 pixels high so the final magnification factor is:
img_mag = (200 / 25) = 8.0
From these assumptions, we can set up the following reconstruction:
; First, define the variables:
imgx = 256
imgy = 256
frames = 3
images = BYTARR(imgx, imgy, frames)
obj_rot = Fltarr(3, frames)
obj_pos = Fltarr(3, frames)
focal = Fltarr(frames)
dist = Fltarr(frames)
vol_pos = Fltarr(3, 2)
img_ref = Fltarr(2, frames)
img_mag = Fltarr(2, frames)
vol_size = [40, 40, 40]
Now determine the image location, focal length and distance from the lens:
; The object is 5000 mm directly in front of the camera:
obj_pos[0, *] = 0.0
obj_pos[1, *] = 0.0
obj_pos[2, *] = -5000.0
; The focal length of the lens is constant for all the images:
focal[*] = 200.0
; The distance from the lens to the image plane is also constant:
dist[*] = 208.333
Determine the remaining relevant information about the object:
; The cube surrounding the object is 600 mm x 600 mm:
vol_pos[*, 0] = [-300.0, -300.0, -300.0]
vol_pos[*, 1] = [ 300.0, 300.0, 300.0]
; The image reference point appears at the center of all the
; images:
img_ref[0, *] = imgx / 2
img_ref[1, *] = imgy / 2
; The image magnification factor is constant for all images.
; (The images have not been cropped or resized):
img_mag[*,*] = 8.0
; Only the object rotation changes from one image to the next.
; Note that the object is rotated about the X axis first, then Y,
; and then Z. Create some fake images for this example:
images[30:160, 20:230, 0] = 255
images[110:180, 160:180, 0] = 180
obj_rot[*, 0] = [-90.0, 0.0, 0.0]
images[70:140, 100:130, 1] = 255
obj_rot[*, 1] = [-70.0, 75.0, 0.0]
images[10:140, 70:170, 2] = 255
images[80:90, 170:240, 2] = 150
obj_rot[*, 2] = [-130.0, 215.0, 0.0]
; Reconstruct the volume:
vol = RECON3(images, obj_rot, obj_pos, focal, dist, $
vol_pos, img_ref, img_mag, vol_size, Missing=255B, Mode=(-1))
Now display the volume in a window using TVSCL:
; Display the volume:
shade_volume, vol, 8, v, p
scale3, xrange=[0,40], yrange=[0,40], zrange=[0,40]
image = polyshade(v, p, /t3d, xs=400, ys=400)
tvscl, image
Version History
Pre-4.0 |
Introduced |