ฉันมีรูปภาพวัตถุเดียวกันหลายภาพซึ่งฉันต้องการจัดอันดับตามความคมชัด เช่น เพื่อจัดอันดับคุณภาพของการมุ่งเน้น
ตามทฤษฎีแล้ว ฉันรู้ว่าเมื่อคุณทำให้ภาพมีความคมชัดน้อยลง คุณจะสูญเสียความถี่สูงไป เพื่อทดสอบสิ่งนี้ ฉันแปลงภาพสามภาพเป็นโดเมนความถี่:
เห็นได้ชัดว่าภาพที่เบลอมีความถี่ที่สูงกว่าสม่ำเสมอมากขึ้นเนื่องจากสัญญาณรบกวน แต่อะไรคือวิธีที่ดีในการหาปริมาณสิ่งนี้? ฉันพยายามหาค่าเฉลี่ยพิกเซลที่ระยะห่างจากพิกเซลที่สว่างที่สุด แต่ก็ไม่ได้แสดงความแตกต่างมากนัก
ฉันจะใช้วิธีนี้เพื่อหาภาพที่คมชัดที่สุดได้อย่างไร
นี่คือโค้ดที่ฉันใช้สร้างภาพด้านบน:
%make gaussian filter
S=10;P=1.5;
x = [-S/2:1:S/2];
x = exp(-x.^2/(2*P^2));
filt = x'*x;filt = filt/sum(filt(:));
%laplacian kernel
LapK = [0 1 0; 1 -4 1 ; 0 1 0];
%get demo image
Iorg = imread('peppers.png');
Iorg = mean(Iorg,3);
Iorg = Iorg./max(Iorg(:));
%mesh grid
[X,Y]=meshgrid(1:size(Iorg,2),1:size(Iorg,1));
R = sqrt(X.^2+Y.^2);
Rmax = min(size(Iorg)./2);
%Add noise and fourier transform
I = Iorg+randn(size(Iorg))*0.01;I = I./max(I(:));
L = conv2(I,LapK); L1 = max(L(:));
F = fft2(Iorg);
%Radial mean
RadM1=nan([1,Rmax]);
for ct = 1:Rmax
RadM1(ct) = mean(abs(F(R<=ct&R>(ct-1))));
end
figure(1);clf;colormap jet
subplot(3,3,1);imagesc(repmat(Iorg,[1,1,3]));axis image off;title('image');
subplot(3,3,2);imagesc(log(abs(fftshift(F))),[-4 10]);axis image off;title('fourier transform');
subplot(3,3,3);plot(1:Rmax,log(RadM1),'.-');title('radial mean');
ylabel('log(|F|)');ylim([2 12])
%filter
I=conv2(Iorg, filt, 'same');
%Add noise and fourier transform
I = I+randn(size(Iorg))*0.01;I = I./max(I(:));
L = conv2(I,LapK); L2 = max(L(:));
F = fft2(I);
%Radial mean
RadM2=nan([1,Rmax]);
for ct = 1:Rmax
RadM2(ct) = mean(abs(F(R<=ct&R>(ct-1))));
end
subplot(3,3,4);imagesc(repmat(I,[1,1,3]));axis image off;title('filtered once');
subplot(3,3,5);imagesc(log(abs(fftshift(F))),[-4 10]);axis image off;title('fourier transform');
subplot(3,3,6);plot(1:Rmax,log(RadM2),'.-');title('radial mean');
ylabel('log(|F|)');ylim([2 12])
%filter twice
I=conv2(Iorg, filt, 'same');I=conv2(I, filt, 'same');
%Add noise and fourier transform
I = I+randn(size(Iorg))*0.01; I = I./max(I(:));
L = conv2(I,LapK); L3 = max(L(:));
F = fft2(I);
%Radial mean
RadM3=nan([1,Rmax]);
for ct = 1:Rmax
RadM3(ct) = mean(abs(F(R<=ct&R>(ct-1))));
end
subplot(3,3,7);imagesc(repmat(I,[1,1,3]));axis image off;title('filtered twice');
subplot(3,3,8);imagesc(log(abs(fftshift(F))),[-4 10]);axis image off;title('fourier transform');
subplot(3,3,9);plot(1:Rmax,log(RadM3),'.-');title('radial mean');
ylabel('log(|F|)');ylim([2 12])
xlabel('radius(pix)');
fprintf(1,'1: %.2f \n2: %.2f \n3: %.2f\n',L1,L2,L3)
ผลลัพธ์
1: 1.04
2: 0.35
3: 0.27
[แก้ไข] นี่เป็นสิ่งที่ซ้ำกันอย่างแน่นอน การโน้มน้าวด้วยเคอร์เนล laplacian และมองหาการทำงานสูงสุดในกรณีนี้ [/แก้ไข]