Home > cellorganizer > utilities > create_sphere.m

create_sphere

PURPOSE ^

MYSPHERE Helper method that creates a 3d sphere image

SYNOPSIS ^

function s = create_sphere(radius,x,y,z)

DESCRIPTION ^

MYSPHERE Helper method that creates a 3d sphere image

Input: size of the image (x,y,z), and radius of the sphere(radius > 10)
Output: 3d image

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function s = create_sphere(radius,x,y,z)
0002 %MYSPHERE Helper method that creates a 3d sphere image
0003 %
0004 %Input: size of the image (x,y,z), and radius of the sphere(radius > 10)
0005 %Output: 3d image
0006 
0007 % Author: Yue Yu(yuey1@andrew.cmu.edu)
0008 %
0009 % Copyright (C) 2012 Murphy Lab
0010 % Lane Center for Computational Biology
0011 % School of Computer Science
0012 % Carnegie Mellon University
0013 %
0014 % October 12, 2012 I. Cao-Berg Documented method, added check of input
0015 % arguments, encapsulated method in try/catch method so that method returns
0016 % empty array if it fails
0017 %
0018 % This program is free software; you can redistribute it and/or modify
0019 % it under the terms of the GNU General Public License as published
0020 % by the Free Software Foundation; either version 2 of the License,
0021 % or (at your option) any later version.
0022 %
0023 % This program is distributed in the hope that it will be useful, but
0024 % WITHOUT ANY WARRANTY; without even the implied warranty of
0025 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0026 % General Public License for more details.
0027 %
0028 % You should have received a copy of the GNU General Public License
0029 % along with this program; if not, write to the Free Software
0030 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0031 % 02110-1301, USA.
0032 %
0033 % For additional information visit http://murphylab.web.cmu.edu or
0034 % send email to murphy@cmu.edu
0035 [X,Y,Z] = ndgrid(-x/2:x/2,-y/2:y/2,-z/2:z/2);
0036  sphere = (X.^2+Y.^2+Z.^2 <= radius^2);
0037  sp = double(sphere);
0038  s = double(bwperim(sp));
0039  %trim the top and bottom of the sphere
0040  s(:,:,1:z/2-radius+5) = 0;
0041  s(:,:,z/2+radius-5:end) = 0;
0042  
0043                 
0044

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