Home > SaliencyToolbox > attenuateBorders.m

attenuateBorders

PURPOSE ^

attentuateBorders - linearly attentuates the border of data.

SYNOPSIS ^

function result = attenuateBorders(data,borderSize)

DESCRIPTION ^

 attentuateBorders - linearly attentuates the border of data.

 result = attenuateBorders(data,borderSize)
   linearly attenuates a border region of borderSize
   on all sides of the 2d data array.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % attentuateBorders - linearly attentuates the border of data.
0002 %
0003 % result = attenuateBorders(data,borderSize)
0004 %   linearly attenuates a border region of borderSize
0005 %   on all sides of the 2d data array.
0006 
0007 % This file is part of the SaliencyToolbox - Copyright (C) 2006-2013
0008 % by Dirk B. Walther and the California Institute of Technology.
0009 % See the enclosed LICENSE.TXT document for the license agreement.
0010 % More information about this project is available at:
0011 % http://www.saliencytoolbox.net
0012 
0013 function result = attenuateBorders(data,borderSize)
0014 
0015 result = data;
0016 dsz = size(data);
0017 
0018 if (borderSize * 2 > dsz(1)) borderSize = floor(dsz(1) / 2); end
0019 if (borderSize * 2 > dsz(2)) borderSize = floor(dsz(2) / 2); end
0020 if (borderSize < 1) return; end
0021 
0022 bs = [1:borderSize];
0023 coeffs = bs / (borderSize + 1);
0024 
0025 % top and bottom
0026 rec = repmat(coeffs',1,dsz(2));
0027 result(bs,:) = result(bs,:) .* rec;
0028 range = dsz(1) - bs + 1;
0029 result(range,:) = result(range,:) .* rec;
0030 
0031 % left and right
0032 rec = repmat(coeffs,dsz(1),1);
0033 result(:,bs) = result(:,bs) .* rec;
0034 range = dsz(2) - bs + 1;
0035 result(:,range) = result(:,range) .* rec;

Generated on Thu 18-Jul-2013 06:10:46 by m2html © 2005