圖像清晰度評價
阿新 • • 發佈:2017-06-23
replicate 歸一化 base sof 輸入 boa view input fun
http://blog.csdn.net/liuuze5/article/details/50773160
1.灰度差
[plain] view plain copy
- 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.邊緣強度
[plain] view plain copy
- function outval = edge_intensity(img)
- % OUTVAL = EDGE_INTENSITY(IMG)
- if nargin == 1
- img=rgb2gray(img);
- 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!‘);
- end
3.main
[plain] view plain copy
- 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);plot(a,‘-r+‘);hold on
- plot(b,‘-b*‘);hold on
- xlabel(‘len.s position‘);
- ylabel(‘value‘);
- title(‘清晰度評價函數‘);
4.輸入圖片
5.對兩組結果歸一化後如下所示:
第14張圖片最清晰,與人眼觀察結果一致。
對另一組圖片進行測試,結果如下:
處理效果上邊緣算子明顯優於灰度差,但時間上消耗很大。
邊緣算子:96.872847 seconds.
灰度差: 4.645993 seconds.
圖像清晰度評價