Skip to content

CreateMask

Adrian Quintana edited this page Dec 11, 2017 · 1 revision

#!/usr/bin/env csh

if ($#argv != 3) then
    echo "you must give three parameters:" 
    echo $0" <input volume> <threshold> <output mask>"
else
 set input=$1
 set threshold=$2
 set outputmask = $3

 
# Binarize based on threshold
 xmipp_threshold -i ${input} -o bin.vol -binarize -below ${threshold}

# Separate into objects and select the largest
 set mask=`xmipp_separate_objects -i bin.vol -o tt | awk 'BEGIN {max=0; imax=0} { if ($3>0) { if ($5>max) {max=$5; imax=$3} } } END {printf "%s%06.0f%s\n", "tt",imax,".vol"}'`

# Output the mask with the proper filename
 cp ${mask} ${outputmask}

# Clean up
 rm -f tt??????.vol bin.vol

 echo "done!"
 echo "You may expand the mask using (multiple times) the following command:"
 echo "xmipp_morphology -i ${outputmask} -dil"
 echo "You may shrink the mask using (multiple times) the following command:"
 echo "xmipp_morphology -i ${outputmask} -ero"


endif



-- Main.SjorsScheres - 14 Feb 2007

Clone this wiki locally