How to I get a threshold value from looking at histogram

조회 수: 12 (최근 30일)
Chok Chuan
Chok Chuan 2015년 3월 29일
답변: Youssef Khmou 2015년 3월 29일
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
Youssef  Khmou
Youssef Khmou 2015년 3월 29일
what is the purpose of this threshold ?
Chok Chuan
Chok Chuan 2015년 3월 29일
편집: Chok Chuan 2015년 3월 29일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Youssef  Khmou
Youssef Khmou 2015년 3월 29일
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.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by