The thresh code computes a threshold image. In other words, all pixels in the input image (named in.fits) are assigned a value of 1 in the output image (named out.fits) if it has a greater than some user-specified level. All other pixels in the output image are set to 0.
thresh 1000.0 3 0.75 a1 a2 a3 arg1 - threshold level arg2 - size of scan bin arg3 - fractional fill level in scan bin
Some further explanation is needed here. The first argument (arg1) is obviously the level that I want to set the threshold at, and hence is probably the most important. The next two arguments may seem obscure, but are really quite simple. The arg2 value (refereed to ism for i_smooth in the thresh.f code) is an integer that specifies the "radius" of a box within which each pixel is inspected. If arg2 is non-zero, then a box is defined at each (i,j) pixel value whose limits are:
ism = arg2 i1 = i-ism (x min) i2 = i+ism (x max) j1 = j-ism (y min) j2 = j+ism (y max)For each pixel location (i,j) this box is searched and the number of pixels with values larger than arg1 is counted. This number of pixels, divided by the total number of pixels in the inspection box, gives a fraction value, frac. I pixel (i,j) is marked in the output image (given a value of 1) when
frac >= arg3
![]() |
FIGURE 1: Results of thresh. The image on the left is the original HST image of a spiral galaxy. The right image is a thresh result using arg1=40.0. |
I wanted a short run script for the thresh code that allows me to demonstrate how it is used, and also I wanted to provide a means of changing the run parameters easily. The script below (in Test_Data_for_Codes/T_runs) does the job. I can feed in the 3 arguments (see above) and an output image with a name that shows the parameter values is written. Additioanlly, a ds9 regions file (same_name.reg) is made that can be loaded when I view the image with ds9. With the ds9 tile option I can make a whole host of well-labeled images resulting from thresh runs. Here is the script:
% pwd /home/sco/sco/projects/Test_Data_for_Codes/T_runs/thresh/ex01 % cp ./S/* . % ls GRAB* RUN* S/ % RUN 40.0 1 0.5 Local test image = hst4_Sp.fits, and in.fits . .. GRAB hst4_Sp.fits in.fits RUN S Need local "log.make" for log file. Writing FITS image: out.fits % ls GRAB* in.fits RUN* S/ t_40.0_1_0.5.reg hst4_Sp.fits junc runner* t_40.0_1_0.5.fits % ds9 t_40.0_1_0.5.fits **** I can load the *.reg file in the usual way **** **** BTW, the GRAB script just retrieves my test image: % cat GRAB #!/bin/sh # Collect image cp $tdata/T_images/S1/hst4_Sp.fits . echo "Local test image = hst4_Sp.fits, and in.fits" cp hst4_Sp.fits in.fits ls -a
![]() |
Results of several thresh runs with the (arg1,arg2,arg3) values labeled in the upper left corner of each map. Here the threshold level is changed to progressively larger values. |
![]() |
Results of several thresh runs with the (arg1,arg2,arg3) values labeled in the upper left corner of each map. Here the smoothing bin size (arg2) is progressively increased. |