__2017-12-16 如一模式识别研究

如一模式识别研究

智能算法>>基于阈值的图像分割

转自:http://www.cnblogs.com/xiangshancuizhu/archive/2010/12/25/1916905.html

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

% Find a good threshold automatically, using the isodata algorithm (Ridler

% and Calvard 1978)

%

% Example:

% vImage = Image(:);

% [n xout]=hist(vImage, );

% threshold = isodata(n, xout)

%

% Parameters: count and intensity are vectors,

% there are count(i) pixels of intensity(i)

% (see "hist" function)

function threshold = isodata(count, intensity)

T(1) = round(sum(count.*intensity) ./ sum(count));

delta = 1; % initialisation before while loop

i=1; %counter for the generations of T (threshold)

% the index of the threshold in the intensity list (T(i) is a threshold, not an index... it can be <0, for example.

while (delta ~= 0) && (i<15)

% after the call to the "hist" function, the intensities are sorted

% (ascending).

T_indexes = find(intensity >= T(i));

T_i = T_indexes(1); % finds the value (in "intensity") that is closest to the threshold.

% calculate mean below current threshold: mbt

mbt = sum(count(1:T_i) .* intensity(1:T_i) ) ./ sum(count(1:T_i));

% calculate mean above current threshold: mat

mat = sum(count(T_i:end) .* intensity(T_i:end) ) ./ sum(count(T_i:end));

% the new threshold is the mean of mat and mbt

i= i+1;

T(i) = round( (mbt+mat)./2 );

delta = T(i) - T(i-1);

end

threshold = T(i);

save T

分类: 学术研究

评论留言区

:
  

作者: 游客 ; *
评论内容: *
带*号为必填项目

如一模式识别更新提示

matlab在图像处理方面的应用有更新

如一模式识别 友情链接

关于本站作者     chinaw3c     mozilla