Image definition Evaluation _ image Clarity

Source: Internet
Author: User

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.





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.