Home > cellorganizer > utilities > ml_findmainobj.m

ml_findmainobj

PURPOSE ^

finds the largest non-zero pixel region in an image

SYNOPSIS ^

function [ imobj ] = ml_findmainobj(img )

DESCRIPTION ^

finds the largest non-zero pixel region in an image

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ imobj ] = ml_findmainobj(img )
0002 %finds the largest non-zero pixel region in an image
0003 
0004 % grj 3/29/13
0005 % Copyright (C) 2007-2013  Murphy Lab
0006 % Carnegie Mellon University
0007 %
0008 % This program is free software; you can redistribute it and/or modify
0009 % it under the terms of the GNU General Public License as published
0010 % by the Free Software Foundation; either version 2 of the License,
0011 % or (at your option) any later version.
0012 %
0013 % This program is distributed in the hope that it will be useful, but
0014 % WITHOUT ANY WARRANTY; without even the implied warranty of
0015 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0016 % General Public License for more details.
0017 %
0018 % You should have received a copy of the GNU General Public License
0019 % along with this program; if not, write to the Free Software
0020 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0021 % 02110-1301, USA.
0022 %
0023 % For additional information visit http://murphylab.web.cmu.edu or
0024 % send email to murphy@cmu.edu
0025 
0026 objs = ml_findobjs(img);
0027 
0028 [~, ind] = max(cellfun(@(x) size(x, 1), objs));
0029 
0030 vox = objs{ind};
0031 
0032 pix = vox(:,4);
0033 vox = double(vox(:,1:3));
0034 
0035 inds = sub2ind(size(img), vox(:,1), vox(:,2), vox(:,3));
0036 
0037 imobj = zeros(size(img));
0038 imobj(inds) = pix;
0039 
0040 end
0041

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