binarize
Ibw = binarize(I::GMTimage, threshold::Int=0; band=1, threshold::Int=0, revert=false, bool::Bool=false) -> GMTimage
or
Ibw = binarize(I::GMTimage, threshold::Vector{Int}; band::Int=1, revert::Bool=false, bool::Bool=false)
Convert an image to a binary image (black-and-white) using a threshold.
Args
I::GMTimage: input image of type UInt8.threshold: A number in the range [0 255]. If the default (0) is kept and the keywordthresholdis not used, then the threshold is computed using the isodata method. Alternatively, a vector of two numbers in the range [0 255] can be used. In this case, the threshold is set to the first value and the second value is used to set the upper limit of the threshold range. That is, values between the two values are set to 255 and the rest to 0 (ortrueand false respectively when theboolkeyword is set totrue). Note that with this second form, thethresholdkeyword does not exist.
Kwargs
band: If theIimage has more than one band, usebandto specify which one to binarize. By default the first band is used.bool: Iftrue, the output image is of type Bool, otherwise it is of type UInt8.threshold: Alternative keyword argument to the positionalthresholdargument. Meaning, one can either use thebinarize(I, ??)orbinarize(I, threshold=??).revert: Iftrue, values below the threshold are set to 255, and values >= the threshold are set to 0.
Return
A new GMTimage.
Example
using GMT
I = gdalread(GMT.TESTSDIR * "assets/coins.jpg");
Ibw = binarize(I, band=1)
# Show the two side-by-side
grdimage(I, figsize=6)
grdimage!(Ibw, figsize=6, xshift=6.1, show=true)
See Also
imcomplementThese docs were autogenerated using GMT: v1.33.0