Search code examples
python-3.xnumpyimage-processingscipyscikit-image

modify a numerical array or an image based on the given threshold


I have an image, and would like to modify the image based on a given threshold. The function such as

binary = image > threshold 

will create a binary image. What I want is the image pixels will remain the same if it is higher than the threshold. Are there any convenient function to do that?


Solution

  • image[image < threshold] = 0
    

    will clip every pixel below the threshold to 0 and will leave the rest intact