Download SExSeg
(Requires Python
and of course SExtractor
NOTE: Please install SExtractor from source. There appears to be a bug in the Scisoft Mac OS X distribution of SExtractor. Thanks to Sahar Allam and Marc Rafelski for isolating this problem and tracking down the solution! To install from source, just unpack the files and then run: "./configure; sudo make install". )

Download the code, plus an example image:
Please download the latest and most thoroughly tested version of SExSeg available in the ColorPro package
(Previous version: sexseg.tar.gz Or just download the code by itself: sexsegonly.tar.gz)

Includes:
reid.py -- Alter IDs of a segmentation map
sppatchnew.py -- Combine segmenation maps from multiple detections
 (Requires spcensus.py)



Run SExSeg

Create a new SExSeg directory and unzip & untar the code there.  Add this directory to your PYTHONPATH, and alias a new command "sexseg", like this:
setenv SEXSEG /home/coe/sexseg/ (use your pathname instead!)
setenv PYTHONPATH ${PYTHONPATH}:$SEXSEG
alias sexseg "python $SEXSEG/sexseg.py"

If you downloaded the example, go into the example/ directory and try SExSeg out!  In this directory, you will find a detection image det.fits, a segmentation map segm.fits, an analysis image i.fits, and two configuration files det.sexseg & i.sexseg.  Now try the following (in any order):

1. Run SExSeg on the detection image:
sexseg det segm -c det.sexseg

SExSeg is sloppy right now: it talks too much and it doesn't clean up after itself, leaving all the intermediate files.  But if everything works right, the very last line of output should say:

"Saving  det_sexseg.cat ..."

This is the file you're interested in: the final catalog.  Check it out!

2. Run SExSeg on the analysis (i-band) image:
sexseg det segm i -c i.sexseg

This time the output will be i_sexseg.cat.

3. Run SExSeg on either image, outputting the final segmentation map:
sexseg det segm i -c i.sexseg -segmout

Compare segm_out.fits to segm.fits.  Not the best example.  Only one pixel was carved out.

Notes:

You probably didn't notice, but SExSeg converted the segment image (segm.fits) to my "sparse pixel" format (segm.spl).  I mention this because this step takes a long time with large images.  But don't worry, it only needs to be performed once for a given segmentation map.

(After writing the following, I realized that it's too cumbersome, and I'll probably have to re-engineer the code a little to make it easier.  But for now...)
    If you try to re-run SExSeg on the same images, it won't do a whole lot.  That's because SExSeg looks to see what files have already been created and then skips ahead to the next step.  If SExSeg finds segm.spl, then it doesn't bother reproducing it.  Ditto if a background-subtracted image already exists.  And so on.  If everything has been done already, SExSeg assumes you wanted to do something, and it reassembles the final catalog det_sexseg.cat, given the SExtractor output catalog det_sexseg_sex.cat.
    So, if you really want to re-run SExSeg, you should delete the files you want SExSeg to reproduce.  Delete all the output to be safe.  But if you're using the same segmentation map, then you can save segm.spl.  If you're also using the same detection image, save det_segmcutflag.dat, det_seggap.fits, & det_sexseg.fits.  Unless you want SExSeg to calculate new analysis images (background-subtracted & RMS), you can keep those, too (det-back.fits & det_rms.fits).  DO delete the catalog files (det_sexseg_sex.cat & det_sexseg.cat), otherwise SExSeg won't do much of anything.

By the way, when I say "segm.fits", that doesn't mean your segmentation map has to be named segm.fits.  You can name it sexsegsux.fits, and SExSeg will still run.  The same goes for det.fits and all the other files.

But, if your analysis image is i.fits, then the background-subtracted image will be named i-back.fits, and the weight image (RMS or otherwise) will be named i_rms.fits.  So if you already have a nice variance weight image, you'll have to rename it with the confusing name of i_rms.fits (or link i_rms.fits to your image), and then set WEIGHT_TYPE to MAP_VAR in i.sexseg.  (Something else I should fix to make more intuitive!)

I created segm.fits "by hand" (using the GIMP image editor) because SExtractor's segmentation of this image just wasn't cutting it!  That's just one example of how SExSeg & pre-defined segmentation maps can be useful.