do gaussian filtering to an image ,but it shows dark

1 次查看(过去 30 天)
L00 ,L01 can show ,but L02,L03.L04 seems dark,what's wrong?
function sift_01()
clear;
%contruct scale space
I = imread('lena.jpg');
I0 = double(rgb2gray(I));
%[m,n]=size(I0);
sigma =1.6;
S=5;k=1/S;
L00 = Lspace(I0,sigma);
L01 = Lspace(I0,k*sigma);
L02 = Lspace(I0,k*k*sigma);
L03 = Lspace(I0,k^3*sigma);
L04 = Lspace(I0,k^4*sigma);
figure;
imshow(uint8(L00));
figure;
imshow(uint8(L01));
figure;
imshow(uint8(L02));
figure;
imshow(uint8(L03));
figure;
imshow(uint8(L04));
end
function L=Lspace(I0,sigma)
N=10;N1=(N+1)/2;
G = zeros(N,N);
for x = 1:N
for y = 1:N
G(x,y) = 1/(2*pi*sigma^2)*exp(-((x-N1)^2+(y-N1)^2)/(2*sigma^2));
end
end
L= conv2(I0,G);
function J=downsample(I)
J = I(1:2:end,1:2:end);

采纳的回答

Image Analyst
Image Analyst 2014-8-10
The numbers just get so small that they're less than 1 so when you uint8() them, they're zero. Even if you don't do that and view the floating point numbers, your G is essentially all zero as you move along. Print out G just before you exit the function to see how small it gets.
  5 个评论
Winston
Winston 2020-6-22
Hi, when I filter the image, it shows different contrast comparing witht the orginal, any method that can adjusted filtered image to show the similar or same contrast with the orginal?
orginal=openfig('f.fig');
f=getimage;
g=imadjust(imfilter(f,fspecial('unsharp'),0.2), [], [], 0.5);
figure,
imshow(g,[]), colormap gray;
title('Sharpened image');

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by