1. 程式人生 > >圖像清晰度評價

圖像清晰度評價

replicate 歸一化 base sof 輸入 boa view input fun

http://blog.csdn.net/liuuze5/article/details/50773160

1.灰度差

[plain] view plain copy
  1. function out_val=difference_absolute(img);
  2. I=rgb2gray(img);
  3. [m,n]=size(I);
  4. f=0.0;
  5. I=double(I);
  6. for x=1:m-1;
  7. for y=1:n-1;
  8. Ix=I(x+1,y)-I(x,y);
  9. Iy=I(x,y+1)-I(x,y);
  10. f=f+abs(Ix)+abs(Iy);
  11. end
  12. end
  13. out_val=f/m/n;


2.邊緣強度

[plain] view plain copy
  1. function outval = edge_intensity(img)
  2. % OUTVAL = EDGE_INTENSITY(IMG)
  3. if nargin == 1
  4. img=rgb2gray(img);
  5. img = double(img);
  6. % Create horizontal sobel matrix
  7. w = fspecial(‘sobel‘);
  8. % Get the size of img
  9. [r c ] = size(img);
  10. gx = imfilter(img,w,‘replicate‘);
  11. gy = imfilter(img,w‘,‘replicate‘);
  12. for m = 1 : r
  13. for n = 1 : c
  14. g(m,n) = sqrt(gx(m,n)*gx(m,n) + gy(m,n)*gy(m,n));
  15. end
  16. end
  17. outval = mean(mean(g));
  18. else
  19. error(‘Wrong number of input!‘);
  20. end

3.main

[plain] view plain copy
  1. clear all;
  2. close all;
  3. clc;
  4. PathName = ‘.\2\‘;
  5. FileName = ‘.jpg‘ ;
  6. n=20
  7. tic
  8. for ii=1:n
  9. imageName=strcat(PathName,num2str(ii),FileName);
  10. im = imread(imageName);
  11. a(ii)=difference_absolute(im);
  12. b(ii)=edge_intensity(im);
  13. end
  14. toc;
  15. a=a/max(a);
  16. b=b/max(b);
  17. figure(1);plot(a,‘-r+‘);hold on
  18. plot(b,‘-b*‘);hold on
  19. xlabel(‘len.s position‘);
  20. ylabel(‘value‘);
  21. title(‘清晰度評價函數‘);


4.輸入圖片

技術分享

5.對兩組結果歸一化後如下所示:

技術分享

第14張圖片最清晰,與人眼觀察結果一致。

對另一組圖片進行測試,結果如下:

技術分享

技術分享

技術分享

處理效果上邊緣算子明顯優於灰度差,但時間上消耗很大。

邊緣算子:96.872847 seconds.
灰度差: 4.645993 seconds.

圖像清晰度評價