-
Notifications
You must be signed in to change notification settings - Fork 1
/
regularity.m
23 lines (22 loc) · 949 Bytes
/
regularity.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
%调用举例:
%image=rgb2gray(imread('example.jpg'));
%Freg=regularity(image,64)
function Freg=regularity(graypic,windowsize) %windowsize为计算规则度的子窗口大小
[h,w]=size(graypic);
k=0;
for i=1:windowsize:h-windowsize
for j=1:windowsize:w-windowsize
k=k+1;
crs(k)=coarseness(graypic(i:i+windowsize-1,j:j+windowsize-1),5); %粗糙度
con(k)=contrast(graypic(i:i+windowsize-1,j:j+windowsize-1)); %对比度
[dire(k),sita]=directionality(graypic(i:i+windowsize-1,j:j+windowsize-1));%方向度
lin=linelikeness(graypic(i:i+windowsize-1,j:j+windowsize-1),sita,4)*10; %线性度,*10与crs、con、dire同量级化
end
end
% Find the standard deviation of the above parameters
Dcrs=std(crs,1);
Dcon=std(con,1);
Ddir=std(dire,1);
Dlin=std(lin,1);
Freg=1-(Dcrs+Dcon+Ddir+Dlin)/4/100;
end