资源简介
matlab开发-三角法灰度阈值。计算阈值三角形方法。
代码片段和文件信息
%Demo triangle_th.m performing gray image thresholding
using the Triangle Method.
%The demo reads a RGB image of vegetation against soil background.
%This image is converted to a gray level image
%% Read image RGB image and convert to gray level
%Reads RGB
Ib=imread(‘coins.png‘);
%%
[lehisto x]=imhist(Ib);
[level]=triangle_th(lehisto256);
I_bw=im2bw(Iblevel);
%%
%Show results
%Input image
subplot(231); imshow(Ib); axis off; title(‘Input image‘);
%Binary image
subplot(232); imshow(I_bw); axis off; title(‘Triangle method‘);
%graythresh for comparison
subplot(233); imshow(im2bw(Ibgraythresh(Ib))); axis off; title(‘graythresh - Image Toolbox‘);
%Histogram
subplot(23[4:6]); bar(xlehisto); xlim([0 255]);
line([73 255][4264 0]‘Color‘‘r‘‘LineWidth‘2);
l
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1170 2010-07-12 14:53 Demo_Triangle_th.m
文件 2554 2010-06-29 12:52 triangle_th.m
文件 1316 2014-02-12 13:13 license.txt
评论
共有 条评论