;===================================================================== ; PV-WAVE ARL ; ; PV-Wave Advanced Rendering Library ; 11/90 D. Carr ; ; (c) Copyright Precision Visuals, Inc., 1990 ; Boulder, Colorado, U.S.A. ; ; All Rights Reserved. ; ; This software is confidential information which is proprietary to ; and a trade secret of Precision Visuals, Inc. Use, duplication or ; disclosure is subject to the terms of an appropriate license ; agreement. ; ------------------------------------------------------------------ ; Use, duplication, or disclosure by the Government is subject to ; restrictions set forth in paragraph (b)(3)(B) of the Rights in ; Technical Data and Computer Software clause in DAR 7-104.9(a). ; ; Contractor : Precision Visuals, Inc., Boulder, Colorado, U.S.A. ; ------------------------------------------------------------------- ; ; Program Overview : FUNCTION Vol_Rend ; Vol_Rend renders volumetric data in a translucent manner. ; Vol_Rend returns an 8 bit image. ; ; SEE ALSO : Grid_Vol Vol_Trans ; ; MANDATORY INPUTS : ; ; volume : A 3 dimensional array containing volumetric data. ; Volume is normally scaled into the range 0 - 255 . ; ; imgx : The X dimension of the image to return. ; ; imgy : The Y dimension of the image to return. ; ; OPTIONAL INPUTS : ; ; opaque : A 3 dimensional array (with the same dimensions ; as volume) containing the translucency values ; for each voxel. Opaque is normally scaled into ; the range 0 - 255 . (0 is clear and 255 is ; completely opaque). If opaque is not specified ; then the default is clear. ; ; depth_q : A scalar depth queing factor. Depth_q should be ; between 0.0 and 1.0 . A depth_q factor of 1.0 ; causes voxels in the back to be just as bright ; as the voxels in the front. A depth_q factor of ; 0.5 causes voxels in the back to be half as bright ; as those in front. ; ;===================================================================== ; FUNCTION Vol_Rend, volume, imgx, imgy, opaque=opaque, depth_q=depth_q B0 = Byte(0) L0 = Long(0) L1 = Long(1) sv = Size(volume) IF (sv(0) NE 3) THEN BEGIN Print, "Volume array not 3 dimensional." STOP ENDIF IF (((sv(1) LT 2) OR (sv(2) LT 2)) OR (sv(3) LT 2)) THEN BEGIN Print, "Volume dimensions must be at least 2" STOP ENDIF imgx = Fix(imgx(0)) imgy = Fix(imgy(0)) IF ((imgx LT 2) OR (imgy LT 2)) THEN BEGIN Print, "Image dimensions must be >= 2" STOP ENDIF IF (N_Elements(depth_q) GT 0) THEN BEGIN depth_q = (Float(depth_q(0)) > 0.0) < 1.0 ENDIF ELSE BEGIN depth_q = 1.0 ENDELSE vx = sv(1) vy = sv(2) vz = sv(3) vmax = vx - 1 vmay = vy - 1 vmaz = vz - 1 img = Bytarr(vx, vy) dq = 1.0 - ((Findgen(vz) * (1.0 - depth_q)) / Float(vmaz)) IF (N_Elements(opaque) GT 0) THEN BEGIN sq = Size(opaque) IF (sq(0) NE 3) THEN BEGIN Print, "Opaque array not 3 dimensional." STOP ENDIF IF (((sq(1) NE sv(1)) OR (sq(2) NE sv(2))) OR (sq(3) NE sv(3))) THEN BEGIN Print, "Dimansions of opaque array do not match volume." STOP ENDIF FOR k=1, vmaz DO BEGIN opaque(*, *, k) = (Float(opaque(*, *, k)) + Float(opaque(*, *, (k -1)))) < 255 ENDFOR FOR j=0, vmay DO BEGIN FOR i=0, vmax DO BEGIN img(i, j) = Max(Fix(Float(volume(i, j, *) - opaque(i, j, *)) * dq)) ENDFOR ENDFOR ENDIF ELSE BEGIN FOR j=0, vmay DO BEGIN FOR i=0, vmax DO BEGIN img(i, j) = Max(Fix(Float(volume(i, j, *)) * dq)) ENDFOR ENDFOR ENDELSE xfract = Float(imgx) / Float(vx) yfract = Float(imgy) / Float(vy) IF (xfract EQ Float(Fix(xfract))) AND (yfract EQ Float(Fix(yfract))) THEN BEGIN img = Rebin(Smooth(img, 2), imgx, imgy) ENDIF ELSE BEGIN img = Congrid(Smooth(img, 2), imgx, imgy, /Interp) ENDELSE RETURN, img END