Skip to content

Instantly share code, notes, and snippets.

@sherbondy
Created January 3, 2015 03:09
Show Gist options
  • Save sherbondy/d443befd6bd30cb73804 to your computer and use it in GitHub Desktop.
Save sherbondy/d443befd6bd30cb73804 to your computer and use it in GitHub Desktop.
Image Pyramid
# generates a lower level of the Gaussian pyramid decomposition of an image.
function impyramid(A; sizes="downsampled")
a = 0.375
kernel = [1/4 - a/2, 1/4, a, 1/4, 1/4 - a/2]
B = imfilter(imfilter(A,kernel), kernel') # slowest part of impyramid, by far
if (sizes == "downsampled")
return (B[1:2:end, 1:2:end])
elseif (sizes == "both")
return (B, B[1:2:end,1:2:end])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment