Home > SuperSegger > batch > tryDifferentConstants.m

tryDifferentConstants

PURPOSE ^

tryDifferentConstants : displays images of cells segmented with

SYNOPSIS ^

function data = tryDifferentConstants(filename,resFlags)

DESCRIPTION ^

 tryDifferentConstants : displays images of cells segmented with
 different constants set in resFlags. It only does the initial
 segmentation (only the doSeg part) and not the regions decisions,
 linking and error resolution that come after.
 Images need to have the right naming convention - if they don't use
 renameImages before this script.

 INPUT :
       dirname : directory with images or filename of image (must be .tif)
 OUTPUT :
       data.SegFile: _seg file from segmentation
            .res: constants resolution for each seg file

 Copyright (C) 2016 Wiggins Lab
 Written by Stella Stylianidou
 University of Washington, 2016
 This file is part of SuperSegger.

 SuperSegger is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 SuperSegger is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with SuperSegger.  If not, see <http://www.gnu.org/licenses/>.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function data = tryDifferentConstants(filename,resFlags)
0002 % tryDifferentConstants : displays images of cells segmented with
0003 % different constants set in resFlags. It only does the initial
0004 % segmentation (only the doSeg part) and not the regions decisions,
0005 % linking and error resolution that come after.
0006 % Images need to have the right naming convention - if they don't use
0007 % renameImages before this script.
0008 %
0009 % INPUT :
0010 %       dirname : directory with images or filename of image (must be .tif)
0011 % OUTPUT :
0012 %       data.SegFile: _seg file from segmentation
0013 %            .res: constants resolution for each seg file
0014 %
0015 % Copyright (C) 2016 Wiggins Lab
0016 % Written by Stella Stylianidou
0017 % University of Washington, 2016
0018 % This file is part of SuperSegger.
0019 %
0020 % SuperSegger is free software: you can redistribute it and/or modify
0021 % it under the terms of the GNU General Public License as published by
0022 % the Free Software Foundation, either version 3 of the License, or
0023 % (at your option) any later version.
0024 %
0025 % SuperSegger is distributed in the hope that it will be useful,
0026 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0027 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0028 % GNU General Public License for more details.
0029 %
0030 % You should have received a copy of the GNU General Public License
0031 % along with SuperSegger.  If not, see <http://www.gnu.org/licenses/>.
0032 
0033 % modify this accoding to the constants you want to try
0034 if nargin < 1 || isempty( filename ) || strcmp(filename,'.')
0035     filename = pwd;
0036 end
0037 
0038 if ~exist('resFlags','var') || isempty(resFlags)
0039     [~,resFlags] = getConstantsList();
0040 end
0041 
0042 % imfinfo()
0043 
0044 if strcmp(filename(end-3:end), '.tif')
0045     tempImage = imread(filename);
0046 else % it is a folder
0047     filename = fixDir(filename);
0048     images = dir([filename,'*c1*.tif']);
0049     if isempty (images)
0050         disp('no images found in the directory with c1.tif.Select an image');
0051         [lastPhaseImage,filename , ~] = uigetfile('*.tif', 'Pick an image file');
0052         if lastPhaseImage == 0
0053             return;
0054         end
0055     else
0056         lastPhaseImage = images(end).name;
0057     end
0058     tempImage = imread([filename,lastPhaseImage]);  
0059 end
0060 
0061 phase = intCropImage (tempImage);  
0062 
0063 
0064 numFlags = numel(resFlags);
0065 numCols = 3;
0066 numRows = ceil(numFlags / numCols);
0067 
0068 for i = 1:numFlags
0069     res = resFlags{i};
0070     disp(['Segmenting with ', res]);
0071     CONST = loadConstants(res, 0);
0072     CONST.parallel.verbose = 0;
0073     dataname = 'test';
0074     data.SegFile {i} = CONST.seg.segFun( phase, CONST, '', dataname, []);
0075     data.res{i} = res;
0076 end
0077 figure(5);
0078 close(5);
0079 figure(5);
0080 clf;
0081 ha = tight_subplot(numRows,numCols,[.05 .02],[.05],[.05]);
0082 for i = 1:numFlags
0083     axes(ha(i));
0084     showSegDataPhase(data.SegFile{i});
0085     title( data.res{i})
0086 end
0087 
0088 
0089 end
0090 
0091 function im = intCropImage (im)
0092 figure;
0093 imshow(ag(im))
0094 disp('Pick the first corner of the crop region.')
0095 ss = size(im);
0096 corner1 = ginput (1);
0097 
0098 hold on; plot (corner1(1) * ones (1,ss(1)),1:ss(1),'r');
0099 hold on; plot (1:ss(2),corner1(2) * ones (1,ss(2)),'r');
0100 disp('Pick the second corner of the crop region.')
0101 corner2 = ginput (1);
0102 x = floor(sort([corner1(1),corner2(1)]));
0103 y = floor(sort([corner1(2),corner2(2)]));
0104 
0105 if x(1)<1
0106     x(1) = 1;
0107 elseif x(2)>ss(2)
0108     x(2) = ss(2);
0109 end
0110 
0111 if y(1)<1
0112     y(1) = 1;
0113 elseif y(2)>ss(1)
0114     y(2) = ss(1);
0115 end
0116 
0117 yy = y(1):y(2);
0118 xx = x(1):x(2);
0119 
0120 clf;
0121 imshow(im(yy,xx,:));
0122 im  = im(yy,xx,:);
0123 end
0124

Generated on Thu 19-Jan-2017 13:55:21 by m2html © 2005