Direkt zum InhaltDirekt zur SucheDirekt zur Navigation
▼ Zielgruppen ▼

Humboldt-Universität zu Berlin - Faculty of Mathematics and Natural Sciences - Strukturforschung / Elektronenmikroskopie


function imgOut3d = smoothEdges(img,Nedge)
% This function smoothes the edges of all the images in a stack of images.
% Nothe, the third dimension is the index through the image stack.
[Nx,Ny,Nz] = size(img);

for iz=1:Nz
imgOut = img(:,:,iz);

% startwith horizontal edge:
edge = 0.5*(imgOut(1,:)+imgOut(Nx,:));
for j=0:Nedge
beta = sin(0.5*pi*j/Nedge);
imgOut(1+j,:) = beta*imgOut(1+j,:)+(1-beta)*edge;
imgOut(Nx-j,:) = beta*imgOut(Nx-j,:)+(1-beta)*edge;
% horizontal edges:
edge = 0.5*(imgOut(:,1)+imgOut(:,Ny));
for j=0:Nedge
beta = sin(0.5*pi*j/Nedge);
imgOut(:,1+j) = beta*imgOut(:,1+j)+(1-beta)*edge;
imgOut(:,Ny-j) = beta*imgOut(:,Ny-j)+(1-beta)*edge;
imgOut3d(1:Nx,1:Ny,iz) = imgOut;