Create histogram to determine the threshold value to use [image processing]
이전 댓글 표시
Hi. as above question mentioned. I want to know how do i determine the threshold value to use. probably creating histogram? how do i do it? thanks!:)
댓글 수: 7
Walter Roberson
2012년 10월 1일
Before you can determine the threshold value to use, you need to decide what you want to use the thresholding for.
Ashish Uthama
2012년 10월 1일
Ester, that is implied. But the value of the threshold controls what value of the input is 1 and what is 0 in the output. You need to tell us, in words, what you want in the output and we can suggest ways to obtain the threshold number.
For example, you could use the mean of the image, if you want values above the mean to have a value 1 and those equal or below to have a value 0:
threshold = mean(im(:));
bw = im>threshold;
Image Analyst
2012년 10월 2일
So, find the objects that are darker than the white background with this:
binaryImage = yourImage < thresholdValue;
ANCHIT
2014년 6월 9일
hii all as the question asked thresholding by histogram I have an RGB Image of a graph paper from which I want to xtract the data wwhat is the best way of doing the thresholding. please explain me thanks
Image Analyst
2014년 6월 9일
Depends on the data. Post your image in a new question.
답변 (3개)
Image Analyst
2012년 10월 1일
Isn't it 42? If not, then how about the threshold given by
normalizedThreshold = graythresh(grayImage);
That uses the famous Otsu method, which is sometimes okay for certain kinds of images, but rarely good (it seems like) for yours and mine. There are lots of methods: http://fiji.sc/wiki/index.php/Auto_Threshold. I really like the triangle method best. It's useful in lots of particle sizing/blob detection situations. It basically draws a line from the peak to the baseline of your histogram. Then it extends a line perpendicular to that. The perpendicular line that hits the histogram that is the longest indicates the threshold to use. In other words, it finds the "corner" at the base of the histogram. It's really good for skewed histograms, which are quite common.
Which thresholding method is best for you depends on your image and what you say is the best. Upload your image so we can see it. Try tinypic.com.
Mahua Nandy(Pal)
2012년 10월 1일
편집: Walter Roberson
2012년 10월 2일
I = imread('coins.png');
level = graythresh(I);
BW = im2bw(I,level);
figure, imshow(BW)
댓글 수: 3
Esther
2012년 10월 1일
preeti visweswaran
2016년 4월 10일
The variable 'level' would return the threshold value
Image Analyst
2016년 4월 10일
Yes, but there's a fair chance that level is no good. im2bw works well for high contrast images with a nicely bimodal histogram. You may need a different algorithm. You can use my manual, interactive thresholding app to try to decide which threshold is best for your type of images. http://www.mathworks.com/matlabcentral/fileexchange/29372-thresholding-an-image
Vedpal Singh
2016년 10월 7일
편집: Vedpal Singh
2016년 10월 7일
0 개 추천
Hi Esther, You can use the imthresh method to determine the threshold value of an image. The code of imthresh is available here: https://searchcode.com/codesearch/view/13889967/
In addition, you can try im2bw, but it's not a better option, because its good for high contrast images.
카테고리
도움말 센터 및 File Exchange에서 Histograms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!