Home > detect > get_DT_cell_location.m

get_DT_cell_location

PURPOSE ^

-------------------------------------------------------------------------%

SYNOPSIS ^

function [centroids, areas, orientations, majorAxisLengths, minorAxisLengths] = get_DT_cell_location(R,C,cell_list)

DESCRIPTION ^

-------------------------------------------------------------------------%
 DESCRIPTION: Find the centroid cell location for each cell.

 INPUT: R,C : size of the test image.
        cell_list: list of detected cell locations

 OUTPUT: mX2 matrix of cell centroid position in r,c coordinate
-------------------------------------------------------------------------%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [centroids, areas, orientations, majorAxisLengths, minorAxisLengths] = get_DT_cell_location(R,C,cell_list)
0002 %-------------------------------------------------------------------------%
0003 % DESCRIPTION: Find the centroid cell location for each cell.
0004 %
0005 % INPUT: R,C : size of the test image.
0006 %        cell_list: list of detected cell locations
0007 %
0008 % OUTPUT: mX2 matrix of cell centroid position in r,c coordinate
0009 %-------------------------------------------------------------------------%
0010 
0011 % % just to get the size
0012 % test_im = imread('rhod74-10-110.mn.png');
0013 % [R C] = size(test_im);
0014 %
0015 % % Load cell_location file
0016 % cell_list = csvread('PT-hod74-10-110.mn.csv');
0017 
0018 
0019 mask = zeros(R,C);
0020 if (size(cell_list,1)~=0)
0021     for num = 1:size(cell_list,1)
0022         row = cell_list(num,1);
0023         col = cell_list(num,2);
0024         mask(row,col) = 1;
0025     end
0026 
0027     mask= bwlabel(mask,4);
0028 
0029     s = regionprops(mask,'Centroid','Area',...
0030         'Orientation','MajorAxisLength','MinorAxisLength');
0031     centroids = cat(1, s.Centroid);
0032     areas = cat(1,s.Area);
0033     orientations = cat(1,s.Orientation);
0034     majorAxisLengths = cat(1,s.MajorAxisLength);
0035     minorAxisLengths = cat(1,s.MinorAxisLength);
0036     
0037     % hold on;
0038     % plot(centroids(:,1), centroids(:,2), 'b*');
0039     % hold off;
0040 
0041     % switch to r,c coordinate
0042     temp = centroids(:,1);
0043     centroids(:,1) = centroids(:,2);
0044     centroids(:,2) = temp;
0045 
0046 else
0047     centroids = [];
0048     areas = [];
0049 
0050     orientations =[];
0051     majorAxisLengths = [];
0052     minorAxisLengths =[];
0053 end
0054 
0055 end

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