# Creating a Gaussian Pyramid

I'm trying to recreate a gassuain pyramid using the following scales: There seems to be two concepts used here:

1) When an image is halved, applying a gaussian kernel of σ will apply as 2σ.

2) When an image has a scale of σ, and a gaussian kernel of σ is applied, then the resulting image will have a scale of sqrt(2)*σ.

So when I'm constructing the above scale space, I do the following: Where the sigmas shown are the sigma of the gaussian kernel applied to the image at the specified scale.

I implemented this in matlab with:

for i = 0:3 % Cycle over octaves - 4 total
for j = 0:4 % Cycle over scales - 5 total
if(i == 0 && j == 0)
% This is the first octave and first octave
obj.gaussianpyramid{i+1,j+1} = blob_class_image.filt_gaussian(obj.gs,1/sqrt(2));
elseif(i > 0 && j == 0)
% This is the first scale after the first
% octave, take 3rd image from previous row
obj.gaussianpyramid{i+1,j+1} = obj.gaussianpyramid{i,3}(1:2:end,1:2:end);
else
% These are second + scales. Take image from
% previous column and apply the same scale
obj.gaussianpyramid{i+1,j+1} = blob_class_image.filt_gaussian(obj.gaussianpyramid{i+1,j},sqrt(2)^(j-2));

% Store logpyramid
obj.logpyramid{i+1,j} = obj.gaussianpyramid{i+1,j+1} - obj.gaussianpyramid{i+1,j};
end
end
end


Is this the correct line of thinking? I've implemented this and when I look at the laplacian of guassian pyramid, it seems to skip over some scales.

EDIT: After some tests it appears I'm not able to implement #2) listed above, where two guassian convolutions with σ is the same as a single guassian convolution with sqrt(2)*σ. When I test it out and then substract the images, they are not the same...

EDIT2: Also made a small mistake on calculating the sigmas. The above idea should be correct now. I double checked by comparing the scale obtained at σ = 22.627 by convolving the original image with a gaussian kernel of σ = 22.627 and then down sampling and comparing the two images and they appear to be the same.

• I think I was doing something stupid, in that with MATLAB you specify the window size of the guassian kernel, I think I had the windowsize set as a function of sigma which resulted in a even integer and thus did not center the gaussian kernel correctly. – Justin Aug 11 '13 at 18:14
• Yep, I fudged with the generation of the kernel. I'll leave this question here anyway just incase someone else makes the same mistake as I did. – Justin Aug 11 '13 at 19:18
• It would be helpful if you posted your fix as an answer. – Phonon Aug 12 '13 at 20:43
• Could you explain exactly what are you trying to do? – Royi Jan 12 '15 at 9:04
• @Drazick I was trying to make a gaussian pyramid for a sift routine I wrote. I noticed my results look a little off so I asked if what I was doing was correct. It turns out my thought process was correct but I was making an implementation error by using a non-odd dimenioned kernel in a Matlab convolution routine, so the solution was basically completely irrelevant to my question. – Justin Jan 12 '15 at 23:19