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 3D volumetric representation of the object. RECON3 also works with translucent projections of an object. RECON3 returns a 3D 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.
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.
Result = RECON3(
Images, Obj_Rot, Obj_Pos, Focal, Dist, $
Vol_Pos, Img_Ref, Img_Mag, Vol_Size
)
A 3D 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.
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.
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.).
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).
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 .
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.
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.
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.
A 3-element integer or floating-point array that specifies the size of the 3D 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.
Set this keyword equal to a byte value for cells in the 3D 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.
Set this keyword to a value less than zero to define each cell in the 3D 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 3D volume as the maximum of the corresponding pixels in the images. If MODE is set equal to zero then each cell in the 3D 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.
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
From these assumptions, we can set up the following reconstruction. First, define the variables:
images = BYTARR(imgx, imgy, frames)
The object is 5000 mm directly in front of the camera:
The focal length of the lens is constant for all the images.
The distance from the lens to the image plane is also constant.
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.
The image magnification factor is constant for all images. (The images haven't been cropped or resized).
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]
vol = RECON3(images, obj_rot, obj_pos, focal, dist, $
vol_pos, img_ref, img_mag, vol_size, Missing=255B, Mode=(-1))
scale3, xrange=[0,40], yrange=[0,40], zrange=[0,40]