Search code examples
matlabcomputer-visiongrayscaleedge-detection

Otsu method (graythresh function in matlab) produces a scaled result on which scale? 0:255, 0:max(px intensity), min:max?


Just clarifying a point about the Otsu thresholding method that lacks definition in the documentation & wikipedia articles. If you apply the Otsu method (in matlab the function graythresh) it returns a threshold value between 0 and 1.

Given 2 hypothetical grayscale images:

  • dark (with pixel intensities in the range of 0 to 100) and
  • light (with pixel intensities in the range of 155 to 255)

If I got an Otsu threshold of 0.75 for both dark and light images respectively, what grayscale pixel intensity would it map to in each case?

  • dark -> 75 and light -> 231 E.g. relative to the range of values in each image
  • dark -> 75 and light -> 191 E.g. relative to the range 0 to max pixel value
  • dark -> 191 and light -> 191 E.g. relative to the full range of grayscale pixel values (0-255)?

Solution

  • The correct answer is the first one :

    dark = 75 and light = 230, relative to the range of values in each image

    graythresh uses the min and max values in the image as boundaries, which is the most logical behavior.