图像阈值处理与区域分割-全局+局部+OSTU分割自定义输出

sgrdf

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 阈值处理与区域分割
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all; close all;clc;

% cd(“D:\Pictures\ACNN\running”);
[filename filepath]=uigetfile({’.jpg’;’.tif’;’.png’;'All files (.*)’},…
‘D:\Pictures\ACNN\running’);
RGB = imread([filepath filename]);

%% % 全局阈值分割
% subplot(221);imshow(RGB); title(“原始图像”,‘FontSize’,16);
% % subplot(222);imhist(RGB);title(“灰度直方图”,‘FontSize’,16);
% subplot(222); num0=numel(RGB);
% KKL=0:255;bar(KKL,imhist(RGB)/num0);title(“归一化直方图”,‘FontSize’,16);
%
% count=0;T=mean2(RGB); done=false;
% f=RGB;
% while ~done
% count=count+1;
% g=RGB>T;
% Tnext=0.5*(mean(f(g))+mean(f(~g)));
% done=abs(T-Tnext)<0.5;
% T=Tnext;

你可能感兴趣的:(新,matlab,图像处理,计算机视觉)