Home > convert > im2obj.m

im2obj

PURPOSE ^

Get WBCFrame object from detection images in a folder

SYNOPSIS ^

function frames = im2obj(iFolder)

DESCRIPTION ^

Get WBCFrame object from detection images in a folder

INPUTS:
 iFolder  -  name of the folder which contains detection images

OUTPUTS:
 frames  -  (struct) contains the WBCFrame object.

EXAMPLES:
 detectedCellStruct = im2obj('detectedImageFolder');

Written by Rich Nguyen (rich.uncc@gmail.com)
Version 1.0, Jul 2009

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function frames = im2obj(iFolder)
0002 %Get WBCFrame object from detection images in a folder
0003 %
0004 %INPUTS:
0005 % iFolder  -  name of the folder which contains detection images
0006 %
0007 %OUTPUTS:
0008 % frames  -  (struct) contains the WBCFrame object.
0009 %
0010 %EXAMPLES:
0011 % detectedCellStruct = im2obj('detectedImageFolder');
0012 %
0013 %Written by Rich Nguyen (rich.uncc@gmail.com)
0014 %Version 1.0, Jul 2009
0015 
0016 frames = [];
0017 % some thresholds
0018 AREA_THRESHOLD = 30;
0019 iFiles = dir(strcat(iFolder,'/DT/*.png'));
0020 
0021 for f = 1: length(iFiles)
0022     im = imread(strcat(iFolder,'/DT/',iFiles(f).name));
0023 %     im = im(:,:,1);
0024 %     mask = im2bw(im);
0025     mask = zeros(size(im));
0026     mask(20:end-20,20:end-20) = im(20:end-20,20:end-20);
0027     
0028     % go cell stats
0029     im = bwlabel(mask,4);
0030     s= regionprops(im, 'Centroid','Area',...
0031             'Orientation','MajorAxisLength','MinorAxisLength');
0032 
0033     centroids = cat(1, s.Centroid);
0034     areas = cat(1,s.Area);
0035     orientations = cat(1,s.Orientation);
0036     majorAxisLengths = cat(1,s.MajorAxisLength);
0037     minorAxisLengths = cat(1,s.MinorAxisLength);  
0038     
0039     frame = WBCFrame(iFolder,f);
0040     id = 0;
0041     for i = 1: length(centroids)
0042         % set condition to be considered as cell
0043         if (areas(i) > AREA_THRESHOLD)
0044             id = id+1;
0045             shape = [orientations(i) majorAxisLengths(i) minorAxisLengths(i)];
0046             cell = WBC(f,id,centroids(i,2), centroids(i,1),areas(i),shape);
0047             frame.add(cell);
0048             frame.Cells(end).Type = [0 0];
0049         end
0050     end
0051     frames = [frames; frame];
0052 end
0053 
0054 
0055 
0056 
0057 
0058 end

Generated on Thu 17-Mar-2011 14:45:51 by m2html © 2005