


dsSpace Downsample 2D matrix spatially. data = 2D matrix factor = 1 integer. The dimensions of data should better be divisible by the factor. average = if true, the multiple values for one pixel is averaged. If false, then only the value in the middle is considered.


0001 function dataDS = dsSpace(data,factor,average) 0002 %dsSpace Downsample 2D matrix spatially. 0003 % data = 2D matrix 0004 % factor = 1 integer. The dimensions of data should better be divisible by 0005 % the factor. 0006 % average = if true, the multiple values for one pixel is averaged. If 0007 % false, then only the value in the middle is considered. 0008 0009 dataDS = reshape(data,[factor size(data,1)/factor factor size(data,1)/factor]); 0010 if average 0011 dataDS = mean(dataDS,1); 0012 dataDS = mean(dataDS,3); 0013 else 0014 numValInPix = size(dataDS,1); 0015 middleInd = round(numValInPix/2); 0016 dataDS = dataDS(middleInd,:,middleInd,:); 0017 end 0018 dataDS = squeeze(dataDS); 0019 end 0020