Home > cellorganizer > utilities > ims2index.m

ims2index

PURPOSE ^

IMG2INDEX Converts an intensity image into an indexed image.

SYNOPSIS ^

function indexed = ims2index( img, mapping )

DESCRIPTION ^

IMG2INDEX Converts an intensity image into an indexed image.

Input arguments    Description
img                A cell array of multidimensional images of the same size
mapping            Indices to assign to each image in img (to control 
                   precedence of one pattern over another)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function indexed = ims2index( img, mapping )
0002 %IMG2INDEX Converts an intensity image into an indexed image.
0003 %
0004 %Input arguments    Description
0005 %img                A cell array of multidimensional images of the same size
0006 %mapping            Indices to assign to each image in img (to control
0007 %                   precedence of one pattern over another)
0008 
0009 % Author: Michelle Mackie (mmackie@andrew.cmu.edu)
0010 % June 6, 2012 M. Mackie Removed parameter 'indexOption', only uses
0011 %                        'priority'
0012 % June 19, 2012 I. Cao-Berg Removed top header and added a check of the
0013 %                           input arguments
0014 % July 26, 2012 R.F. Murphy Fix output for last image; add mapping to
0015 %                           control priority of indices
0016 %
0017 % Copyright (C) 2012 Murphy Lab
0018 % Lane Center for Computational Biology
0019 % School of Computer Science
0020 % Carnegie Mellon University
0021 %
0022 % This program is free software; you can redistribute it and/or modify
0023 % it under the terms of the GNU General Public License as published
0024 % by the Free Software Foundation; either version 2 of the License,
0025 % or (at your option) any later version.
0026 %
0027 % This program is distributed in the hope that it will be useful, but
0028 % WITHOUT ANY WARRANTY; without even the implied warranty of
0029 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0030 % General Public License for more details.
0031 %
0032 % You should have received a copy of the GNU General Public License
0033 % along with this program; if not, write to the Free Software
0034 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0035 % 02110-1301, USA.
0036 %
0037 % For additional information visit http://murphylab.web.cmu.edu or
0038 % send email to murphy@cmu.edu
0039 
0040 %icaoberg june 19, 2012
0041 indexed = [];
0042 if isempty( img )
0043     return
0044 end
0045 
0046 if nargin < 2
0047     mapping = eye(length(img),1)
0048 end
0049 
0050 for i=1:length(img)
0051     image = double(img{i});
0052     image(image>0) = mapping(i);
0053     %check to see if sizes are equal
0054     if ~isequal(size(image),size(img{end}))
0055         warning('image sizes are not equal');
0056         return;
0057     end
0058     img{i} = image;
0059 end
0060 
0061 indexed = zeros(size(img{i}));
0062 
0063 
0064 for i=1:length(img)
0065     %check to see if images are empty
0066     if isempty(img{i})
0067         warning('image is empty');
0068         return;
0069     end
0070     indexed = indexed+img{i};
0071     indexed(indexed>i)=i;
0072 end
0073 % end

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