Histogram threshold Value Method

Source: Internet
Author: User
The histogram threshold method is  implemented by using MATLAB histogram threshold method:
clc;clear;close;
I=imread (' e:\role0\003i.bmp ');
I1=rgb2gray (I);
Figure;
Subplot (2,2,1);
Imshow (I1);
Title (' Grayscale image ')
grid on;% display gridlines axis on
;                  % display coordinate system
[M,n]=size (I1);                            % measurement image size parameter
gp=zeros (1,256);                           % pre-created vector for
k=0:255
    GP (k+1) =length (Find (I1==k))/(M*n) that holds the probability of grayscale occurrence;    % calculates the probability of each level of grayscale appearing, storing it in GP in the corresponding position
end
subplot (2,2,2), bar (0:255,GP, ' g ')                   % plotting histogram
title (' Grayscale histogram ')
Xlabel (' Gray value ')
ylabel (' probability of occurrence ')
I2=IM2BW (i,150/255);
Subplot (2,2,3), Imshow (I2);
Title (' Segmented image of threshold 150 ')
grid on;                  % Display grid line
axis on;                  % display coordinate system
I3=IM2BW (i,200/255);   %
subplot (2,2,4), Imshow (I3);
Title (' Segmented image of Threshold 200 ')
grid on;                  % Display grid line
axis on;                  % Display coordinate system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.