!!++ !! BMP_TO_SOURCE.INR !! Title: Creating and Tracing a Bitmap Source !! Category: Demo Project !! Keywords: Tracing, BMP2DIS, DIS2BMP, bitmap, $SYS, SCALE, TOWARDS, diffuser !! Description: This is the main script file that !! demostrates how a bitmap image may be used as a source !! (scene) to image through a camera system. The rays from !! the source are turned into scatter rays at a diffuser !! mounted directly in front of the source. In this way !! only those rays directed TOWARDS the camera's entrance !! pupil are traced, dramatically improving raytrace !! time. !! File was originally written by Marie Cote for IODC !! (Hawaii 98). It was the first attempt at creating !! a color picture with ASAP using the parrots.bmp picture !! which is translated into 3 display files (red green and !! blue) using the bmp2dis executable found in the !! ASAPXX\Bin folder. These 3 sources are separately traced !! through a digital camera system and focused onto a CCD !! imager, where they are recombined with the dis2bmp !! converter back into a single 3-color image. !! Edit History (latest first) !! 05/30/2001 - cp - added description; modified syntax !! 05/07/1999 - mc - created !!-- SYSTEM NEW RESET $SCR SCREEN1 'Tracing a BMP Image Through a Camera' UNITS MM 'W' WAVELENGTHS 0.4861327 0.5875618 0.6562725 MICRON SPECTRUM 1 1 1 S1="YES" $SCR 5 'Create camera system?' YES or NO? \S1"? YES will create the digital camera system needed for the following demo. The required system file will be generated. You may skip this with a NO, if already performed with this version of ASAP. $IF S1" EQS "YES" THEN $READ CAMERA_SYSTEM.INR $ENDIF !! Get digital camera geometry SYSTEM FROM CAMERA $SCR SCREEN2 'Tracing a BMP Image Through a Camera' !! Create object (a diffuser) that fills camera FOV @ 5 !! meters from camera. This diffuser is located next to !! the source such that rays leaving the source will hit !! the diffuser and be scattered towards the lens entrance !! pupil. This technique optimizes the raytrace efficiency !! such that all rays leaving the source will propagate !! towards the camera. !! Important edge definition at entrace pupil EDGE (EP=1000) !! Assign edge number to reference later with TOWARDS ELLIPSE Z 4.408018 2@1.879831/2 !! Diffuser MODEL LAMBERTIAN 1 RETURN LEVEL 1 SURFACE PLANE Z -5000 RECT 1832 1374 !! Matches AR of CCD detector OBJECT 'DIFF' INTERFACE 0 1E-12 !! Only allow scatter rays to transmit SCATTER MODEL 1 TOWARDS (EP) 1 RETURN !!Source creation and raytrace $SCR 3 'Tracing a BMP Image Through a Camera' Using the BMP2DIS converter in the ASAP Bin folder, the BMP image is broken into separate R, G, and B components. \DUMMY:? !! Creation of 3 ASAP distribution files (R B G) !! using the parrot bmp file $SYS BMP2DIS PARROTS R !! RED PARROTSR.DIS $SYS BMP2DIS PARROTS G !! GREEN PARROTSG.DIS $SYS BMP2DIS PARROTS B !! BLUE PARROTSB.DIS !! Weighting of the 3 source's flux !! based on the average of their distribution file $SCR 1 'Tracing a BMP Image Through a Camera' Red component of parrot picture! \DUMMY:? DISPLAY PARROTSR.DIS PICTURE 'Red Component' $GRAB 'Average' 0 1 WR RETURN $SCR 1 'Tracing a BMP Image Through a Camera' Green component of parrot picture! \DUMMY:? DISPLAY PARROTSG PICTURE 'Green Component' $GRAB 'Average' 0 1 WG RETURN $SCR 1 'Tracing a BMP Image Through a Camera' Blue component of parrot picture! \DUMMY:? DISPLAY PARROTSB PICTURE 'Blue Component' $GRAB 'Average' 0 1 WB RETURN ASUM=(WR+WG+WB)/3 WR=WR/ASUM WB=WB/ASUM WG=WG/ASUM ® WR WG WB NRAY=20000 !! 5000000 rays were used for the paper DIF_AREA=1832*1374 SOLAR_C=1368/1000000 !! W/MM2 - Solar constant POWER=0.1*DIF_AREA*SOLAR_C !! Assuming 10% reflected rays from Sun $SCR 3 'Tracing a BMP Image Through a Camera' First, the red source image is traced through the lens system and focused onto the CCD detector. 20,000 rays are used for each color, or you may enter more here. \NRAY.? !! RED raytrace SEED 1 QUASI WAVELENGTH 0.6562725 EMITTING DATA PARROTSR (NRAY) ROTATE Z 90 0 0 SCALE 22 22 1 !! To get close to size of diffuser with some trimming SHIFT 0 0 -5000.001 FLUX TOTAL (POWER*WR) SOURCE 0.1 TRACE CONSIDER ONLY IMAGE_SURF !! From camera system !! WINDOW and PIXELS set to detector size and resolution !! Set up here for all traces WINDOW Y -2@1.45 X -2@1.92 PIXELS 481 SPOTS POS ATTRIBUTE 0 DISPLAY TRANSPOSE PICTURE 'Red Imaged Component' WRITE PARROTS_IMR RETURN CONSIDER ALL $SCR 2 'Tracing a BMP Image Through a Camera' The green and blue sources are also traced through the lens system. \DUMMY:? !! GREEN raytrace SEED 1 QUASI WAVELENGTH 0.5875618 EMITTING DATA PARROTSG (NRAY) ROTATE Z 90 0 0 SCALE 22 22 1 SHIFT 0 0 -5000.001 FLUX TOTAL (POWER*WG) SOURCE 0.1 TRACE CONSIDER ONLY IMAGE_SURF SPOTS POS ATTRIBUTE 0 DISPLAY TRANSPOSE PICTURE 'Green Imaged Component' WRITE PARROTS_IMG RETURN CONSIDER ALL !! BLUE raytrace SEED 1 QUASI WAVELENGTH 0.4861327 EMITTING DATA PARROTSB (NRAY) ROTATE Z 90 0 0 SCALE 22 22 1 SHIFT 0 0 -5000.001 FLUX TOTAL (POWER*WB) SOURCE 0.1 TRACE CONSIDER ONLY IMAGE_SURF !!WINDOW Y -2@-1.45 X -2@1.92 SPOTS POS ATTRIBUTE 0 DISPLAY TRANSPOSE PICTURE 'Blue Imaged Component' WRITE PARROTS_IMB RETURN CONSIDER ALL $SCR 5 'Tracing a BMP Image Through a Camera' Finally, the three separate (RGB) imaged components are combined into one image. The DIS2BMP executable does this. You may look at this file (PARROTS_IM.BMP) with any picture viewer. The more rays traced, the better it will look. See script file for further comments.\DUMMY:? !! Creating bmp file that contains the parrot image $SYS "DIS2BMP PARROTS_IMR PARROTS_IMG PARROTS_IMB PARROTS_IM" $SYS "DEL DISPLA*.TMP" !! Clean up temporary display files RETURN