do gaussian filtering to an image ,but it shows dark

조회 수: 4 (최근 30일)
Roger
Roger 2014년 8월 10일
댓글: Image Analyst 2020년 6월 22일
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');
Image Analyst
Image Analyst 2020년 6월 22일
Yes, just don't call imadjust() to change the contrast.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by