ADJUSTRESOLUTIONS resized a 3D image according to the input and output resolutions given Inputs: img = array of image data initres = initial resolution at which the img is being passed in finalres = final resolution at which the img is being returned
0001 function [img] = AdjustResolutions(img,initres,finalres) 0002 %ADJUSTRESOLUTIONS resized a 3D image according to the input and output resolutions given 0003 % 0004 %Inputs: 0005 % img = array of image data 0006 % initres = initial resolution at which the img is being passed in 0007 % finalres = final resolution at which the img is being returned 0008 0009 %Author: Devin Sullivan Summer 2013 0010 % Copyright (C) 2013 Murphy Lab 0011 % Carnegie Mellon University 0012 % 0013 % This program is free software; you can redistribute it and/or modify 0014 % it under the terms of the GNU General Public License as published 0015 % by the Free Software Foundation; either version 2 of the License, 0016 % or (at your option) any later version. 0017 % 0018 % This program is distributed in the hope that it will be useful, but 0019 % WITHOUT ANY WARRANTY; without even the implied warranty of 0020 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0021 % General Public License for more details. 0022 % 0023 % You should have received a copy of the GNU General Public License 0024 % along with this program; if not, write to the Free Software 0025 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 0026 % 02110-1301, USA. 0027 % 0028 % For additional information visit http://murphylab.web.cmu.edu or 0029 % send email to murphy@cmu.edu 0030 0031 0032 %since the cell is built conditionally on the nucleus, they should 0033 %ALWAYS have the same resolution 0034 % initres = param.resolution.cell;%e.g. [0.05,0.05,0.35] 0035 % finalres = param.resolution.objects; 0036 % maxval = max(img(:)); 0037 param.outputres=finalres; 0038 0039 %nucleus 0040 finalsize_x = floor(initres(1)./finalres(1).*size(img,1)); 0041 finalsize_y = floor(initres(2)./finalres(2).*size(img,2)); 0042 finalsize_z = floor(initres(3)./finalres(3).*size(img,3)); 0043 0044 img = imresize(img,[finalsize_x finalsize_y],'bilinear'); 0045 %need to resize the z 0046 img = tp_stretch3d(img,finalsize_z); 0047 % img = (img>0).*maxval; 0048 img = (img>0); 0049 0050 % %cell 0051 % %Note: the recalculation of final size should be unnecessary since the 0052 % %cell and nucleus images should always be the same size, but since the 0053 % %arithmatic is trivially fast I recalculate to deal with potential 0054 % %weird situations in the future(e.g. if we need the nuclear image to be 0055 % %a smaller object that we add in to the cell image for space)DPS 0056 % finalsize_x = floor(initres(1)./finalres(1).*size(param.cell,1)); 0057 % finalsize_y = floor(initres(2)./finalres(2).*size(param.cell,2)); 0058 % finalsize_z = floor(initres(3)./finalres(3).*size(param.cell,3)); 0059 % param.cell = imresize(param.cell,[finalsize_x finalsize_y],'bilinear'); 0060 % %need to resize the z 0061 % param.cell = tp_stretch3d(param.cell,finalsize_z); 0062 % param.cell = param.cell>0;