연구관련

Laplacian of Gaussian vs Gaussian of Laplacian 같을까?

우주여행가 2013. 4. 4. 20:13

LoG (Laplacian of Gaussian) 과 GoL (Gaussian of Laplacian) filtering은 같을까?


L : laplacian filter

G : gaussian filter

I : image


라 가정하자.


LoG 는 L*G*I

GoL 은 G*L*I


convolution은 교환법칙이 성립하므로


이론적으로 L*G*I = G*L*I 가 성립한다.


실제 구현에서는 어떨까?


1) lena image를 입력한 경우

좌측상단: 원본 이미지

우측상단: Gaussian filtering 된 이미지

좌측하단: LoG filtered image

우측하단: GoL filtered image


희미하지만 LoG결과와 GoL 결과의 차이가 보인다.



2) Gaussian noise가 섞인 Lena image


좌측상단: 원본 이미지

우측상단: Gaussian filtering 된 이미지

좌측하단: LoG filtered image

우측하단: GoL filtered image


원본 이미지에 noise가 섞여있을 경우, LoG와 GoL의 차이는 보다 뚜렷해진다.


이론적으로는 두 결과가 같아야 하는데, 왜 이런 차이점이 생기는 것일까?


답은 data 표현형에 있다.


image를 unsigned char로 load한 경우, 

filtering 결과가 data형에 맞게 clipping되기 때문에, 

정확도 면에서 손실이 발생한다.

(image를 double형으로 cast하면, 두 결과가 유사하게 나온다.)

따라서, 실제 구현에서는 이 점을 염두하고, 

image를 unsigned char로 읽어 들이는 경우에는, LoG를 사용해야 한다.





소스


  I=loadImage('lena.jpg', 640); % image resize

  

%   I = imnoise(I,'gaussian',0,0.02);

%    I = imnoise(I,'salt & pepper',0.02);

  figure(1);

  imshow(I);

  

%   I = double(I);

  

  G = fspecial('gaussian',[5 5], 2);

  L = fspecial('laplacian');

  LoG = fspecial('log',[7 7],2);

  LoG1= conv2(L,G);

  LoG2= conv2(G,L);

  

  Ig = imfilter(I,G,'same');

  figure(2);

  imshow(Ig);

  Ilg = imfilter(Ig,L,'same');

  

  figure(3);

  imshow(Ilg);

  

  Il=imfilter(I,L,'same');

  figure(4);

  imshow(Il);

  

  Igl = imfilter(Il,G,'same');

   figure(5);

  imshow(Igl);

  


  diff1 = abs(int8(Ilg)-int8(Igl));

%   diff1 = int8(abs(int8(Ilg - Igl)));

  figure(6);

  imshow(diff1);

  sum(sum(diff1))

  

  Ilog = imfilter(I,LoG,'same');

  figure(7);

  imshow(Ilog);

  

  Ilog1 = imfilter(I,LoG1,'same');

  Ilog2 = imfilter(I,LoG2,'same');

  

  figure(8);

  imshow(Ilog1);

  figure(9);

  imshow(Ilog2);


%   diff=Ilog1-Ilog2;

%   abs(int8(Ilg)-int8(Igl));

diff=abs(int8(Ilog1)-int8(Ilog2));

  sum(sum(diff))

'연구관련' 카테고리의 다른 글

The Computer Vision Industry  (0) 2013.05.30
SIFT 설명 slide  (0) 2013.04.04
Separable Gaussian Filtering  (1) 2013.04.04
패턴인식 자료 참고  (0) 2013.03.25
Statistical Pattern Recognition Toolbox (matlab)  (0) 2013.03.25