Home > cellorganizer > im2projection.m

im2projection

PURPOSE ^

IM2GPROJECTION creates a sum or mean projection of the input image

SYNOPSIS ^

function out_img = img2projection( img, param )

DESCRIPTION ^

 IM2GPROJECTION creates a sum or mean projection of the input image

 Input:
 img = a 3D binary or realvalued image.
 param = struct with a 'method' field that can be set
 to 'mean' if a mean value projection is desired
 Output:
 out_img = a 2D image that contains a projection
 in each dimension of the original image

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function out_img = img2projection( img, param )
0002 % IM2GPROJECTION creates a sum or mean projection of the input image
0003 %
0004 % Input:
0005 % img = a 3D binary or realvalued image.
0006 % param = struct with a 'method' field that can be set
0007 % to 'mean' if a mean value projection is desired
0008 % Output:
0009 % out_img = a 2D image that contains a projection
0010 % in each dimension of the original image
0011 
0012 % Author: Yue Yu and Ivan Cao-Berg
0013 % Created: Summer 2012
0014 %
0015 % Copyright (C) 2012 Murphy Lab
0016 % Lane Center for Computational Biology
0017 % School of Computer Science
0018 % Carnegie Mellon University
0019 %
0020 % This program is free software; you can redistribute it and/or modify
0021 % it under the terms of the GNU General Public License as published
0022 % by the Free Software Foundation; either version 2 of the License,
0023 % or (at your option) any later version.
0024 %
0025 % This program is distributed in the hope that it will be useful, but
0026 % WITHOUT ANY WARRANTY; without even the implied warranty of
0027 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0028 % General Public License for more details.
0029 %
0030 % You should have received a copy of the GNU General Public License
0031 % along with this program; if not, write to the Free Software
0032 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0033 % 02110-1301, USA.
0034 %
0035 % For additional information visit http://murphylab.web.cmu.edu or
0036 % send email to murphy@cmu.edu
0037 
0038 if nargin == 1
0039     param.method = 'mean';
0040 end
0041 
0042 out_img = [];
0043 if isempty( img )
0044     warning( 'Input argument image is empty' );
0045     return
0046 end
0047 
0048 try
0049     [m,n,q] = size(img);
0050     out_img = zeros((m+q),(q+n));
0051     
0052     if strcmpi( param.method, 'sum' )
0053         sumq = sum(img,3);
0054         summ = squeeze(sum(img,1));
0055         sumn = squeeze(sum(img,2));
0056         out_img(1:m,q+1:end) = sumq;
0057         out_img(1:m,1:q) = sumn;
0058         out_img(m+1:end,q+1:end) = flipud(summ');
0059     elseif strcmpi( param.method, 'mean' )
0060         sumq = mean(img,3);
0061         summ = squeeze(mean(img,1));
0062         sumn = squeeze(mean(img,2));
0063         out_img(1:m,q+1:end) = sumq;
0064         out_img(1:m,1:q) = sumn;
0065         out_img(m+1:end,q+1:end) = flipud(summ');
0066     else
0067         out_img = [];
0068         warning('Unknown method');
0069     end
0070 catch
0071     out_img = [];
0072     warning('Unable to make projections');
0073     return
0074 end

Generated on Sun 29-Sep-2013 18:44:06 by m2html © 2005