MATLAB Answers

0

How to I get a threshold value from looking at histogram

Asked by Chok Chuan on 29 Mar 2015
Latest activity Answered by Youssef Khmou
on 29 Mar 2015
I need to get a threshold value not by looking at the graph I was told there is a way to calculate the threshold value from the histogram, Can someone help me

  2 Comments

what is the purpose of this threshold ?
I = imread('Test1.tif'); J=rgb2gray(I); figure; imhist(J);
thresholdValue = 100; bw = J > thresholdValue;
I am currently putting a casual 100 inside after looking at the histogram. I need the threshold value to segment the picture into fore and background. Is the a way to calculate a precise threshold value.

Sign in to comment.

1 Answer

Youssef Khmou 님의 답변 29 Mar 2015

Otsu's method exists as built in function with name graythresh, here is an example taken from Mathworks help page :
I = imread('coins.png');
level = graythresh(I);
BW = im2bw(I,level);
there might be other techniques to choose an adequate threshold.

  0 Comments

Sign in to comment.