Thresholding Filters


    itk-BinaryThresholdImage:

    This filter tranforms an image into a binary image by transforming each pixel according to whether it is inside or outside a specified range. The user chooses lower and upper threshold values to process. If a pixel is inside of this range, it is assigned an "inside" value. Otherwise it is assigned an "outside" value.

    Usage: itk-BinaryThresholdImage inputImageFile outputImageFile dimension lower_threshold [upper_threshold] [inside_value] [outside_value].
    lower_threshold: required, upper_threshold: default = 255, inside_value: default = 255; outside_value: default = 0.

    Below is a set of sample output files, next to their parent input file. The lower and upper threshold values are respectively: 0-100,100-150,150-200,200-250. The inside value is set to 200. The outside value is set to 100, with the following set of commands:
    itk-BinaryThresholdImage lafarge3col.tif test1.tif 2 0 100 200 100
    itk-BinaryThresholdImage lafarge3col.tif test2.tif 2 100 150 200 100
    itk-BinaryThresholdImage lafarge3col.tif test3.tif 2 150 200 200 100
    itk-BinaryThresholdImage lafarge3col.tif test4.tif 2 200 250 200 100

original data original data original data original data original data

    itk-ThresholdImage:

    The user selects a range of pixel values to leave alone, and a value to set pixels outside of this range. The user can select a range in 3 ways:
    1. Pixels below a certain value are replaced by the "outside value." Pixels above this value are unchanged.
    2. Pixels above a certain value are replaced by the "outside value." Pixels below this value are unchanged.
    3. Pixels above an upper value and below a lower value are replaced by the "outside value." Pixels between the upper and lower values are unchanged.

    Usage: itk-ThresholdImage inputImageFile outputImageFile dimension method# (1,2,or3) outside_value lower_threshold [upper_threshold].
    The outside value is used by all 3 methods as the value to which pixels outside the specified ranges are assigned. Methods 1 and 2 require only 1 threshold value. Method 3 requires both an upper and lower threshold value.

    Below is a set of sample output files, next to their parent input file.
    The first set uses method 1 to set all pixels below a value of 100, first to 50 and then to 255, using the commands:
    itk-ThresholdImage lafarge3col.tif thres1.tif 2 1 50 100
    itk-ThresholdImage lafarge3col.tif thres2.tif 2 1 255 100

original data original data original data

    The second set uses method 2 to set all pixels above 150 to a value of 50, and then to a value of 255:
    itk-ThresholdImage lafarge3col.tif thres3.tif 2 2 50 150
    itk-ThresholdImage lafarge3col.tif thres4.tif 2 2 255 150

original data original data original data

    The third set uses method 3 to set all pixels that are below 100 or above 200, to a value of 50, and then to a value of 255:
    itk-ThresholdImage lafarge3col.tif thres5.tif 2 3 50 100 200
    itk-ThresholdImage lafarge3col.tif thres6.tif 2 3 255 100 200

original data original data original data


Last updated November 18, 2005