Skip to content

Instantly share code, notes, and snippets.

@bryansills
Created November 11, 2013 00:46
Show Gist options
  • Save bryansills/7406024 to your computer and use it in GitHub Desktop.
Save bryansills/7406024 to your computer and use it in GitHub Desktop.
function smim = REDUCE(im)
wgt = [0.0500 0.2500 0.4000 0.2500 0.0500];
m = -2:2;
smim = zeros(ceil(size(im,1)/2), ceil(size(im,2)/2));
im = padarray(im, [2 2]);
window = wgt'*wgt;
for r=1:size(smim,1)
for c=1:size(smim,2)
A = im(2*r+m+1,2*c+m+1).*window;
smim(r,c) = sum(A(:));
end
end
end
function lgim = EXPAND(im)
wgt = [0.0500 0.2500 0.4000 0.2500 0.0500];
m = -2:2;
lgim = zeros(2*size(im,1), 2*size(im,2));
im = padarray(im, [2 2]);
window = wgt'*wgt;
for r = 1:size(lgim,1)
for c = 1:size(lgim,2)
pxr = (r - m)/2 + 2;
indr = find(floor(pxr)==pxr);
pxc = (c - m)/2 + 2;
indc = find(floor(pxc)==pxc);
A = im(pxr(indr),pxc(indc)) .* window(m(indr)+3,m(indc)+3);
lgim(r, c)= 4 * sum(A(:));
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment