1. Grayscale Difference
function Out_val=difference_absolute (IMG);
I=rgb2gray (IMG);
[M,n]=size (I);
f=0.0;
I=double (I);
for x=1:m-1;
for y=1:n-1;
Ix=i (X+1,y)-I (x,y);
Iy=i (x,y+1)-I (x,y);
F=f+abs (Ix) +abs (Iy);
End
end
out_val=f/m/n;
2. Edge Strength
function outval = edge_intensity (img)
% outval = Edge_intensity (img)
If nargin = 1
img=rgb2gray (IMG); c16/>img = Double (img);
% Create Horizontal Sobel matrix
w = fspecial (' Sobel ');
% get the size of IMG
[R C] = Size (IMG);
GX = IMFilter (img,w, ' replicate ');
GY = IMFilter (img,w ', ' replicate ');
For m = 1:r for
n = 1:c
g (m,n) = sqrt (GX (m,n) *GX (m,n) + gy (m,n) *gy (m,n));
End-end
OutVal = mean (mean (g));
else
error (' Wrong number of input! ');
3.main
Clear all;
Close all;
CLC;
PathName = '. \2\ ';
FileName = '. jpg ';
N=20
tic
for ii=1:n
Imagename=strcat (PATHNAME,NUM2STR (ii), FileName);
im = Imread (imagename);
A (ii) =difference_absolute (IM);
B (ii) =edge_intensity (IM);
End
TOC;
A=a/max (a);
B=b/max (b);
Figure (1);p lot (A, '-r+ '); Hold on
plot (b, '-b* '); Hold on
xlabel (' len.s position ')
; Ylabel (' value ');
Title (' Definition evaluation function ');
4. Input picture
5. The normalization of the two sets of results is shown below:
The 14th picture is the clearest, consistent with the results of human eye observation.
Test another set of pictures, and the results are as follows:
The upper edge operator of the processing effect is obviously better than the gray difference, but the time consuming is very big.
Edge operator: 96.872847 seconds.
Grayscale difference: 4.645993 seconds.