Skip to content

Commit

Permalink
Added implementation for image resizing in CONST file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Wiggins committed Jun 26, 2018
1 parent b1c2c32 commit 8a3e47d
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 25 deletions.
2 changes: 1 addition & 1 deletion batch/trackOptiResize.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
image_name = contents(i).name;
image_folder = contents(i).folder;
disp(image_name);
im = imread([image_folder,'/',image_name]);
im = intImRead([image_folder,'/',image_name]);
out_name = [targetd, image_name];
imwrite(imresize(im,scale), out_name, 'TIFF');
end
Expand Down
4 changes: 2 additions & 2 deletions batch/trackOptiSkipMerge.m
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function intSkipPar(i,dirname_xy,nameInfo,nt,nc,nz,skip,num_c,num_z)
for k = 2:num_z
nameInfo_tmp.npos(4,1) = nz(k);
name = MakeFileName(nameInfo_tmp);
phase = min(phase, double(imread( [dirname_xy,'phase',filesep,name] )));
phase = min(phase, double(intImRead( [dirname_xy,'phase',filesep,name] )));
end

% Loads the reference _err file for the image already segmented
Expand Down Expand Up @@ -174,7 +174,7 @@ function intSkipPar(i,dirname_xy,nameInfo,nt,nc,nz,skip,num_c,num_z)
nameInfo_tmp.npos(2,1) = nc(k);
nameInfo_tmp.npos(4,1) = 1;
name = MakeFileName( nameInfo_tmp );
fluorImage = imread( [dirname_xy,'fluor',num2str(nc(k)-1),filesep,name]);
fluorImage = intImRead( [dirname_xy,'fluor',num2str(nc(k)-1),filesep,name]);
data.(['fluor',num2str(nc(k)-1)]) = fluorImage;

imRange(:,k) = intRange( fluorImage(:) );
Expand Down
4 changes: 2 additions & 2 deletions batch/tryDifferentConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
% imfinfo()

if strcmp(filename(end-3:end), '.tif')
tempImage = imread(filename);
tempImage = intImRead(filename);
else % it is a folder
filename = fixDir(filename);
images = dir([filename,'*c1*.tif']);
Expand All @@ -55,7 +55,7 @@
else
lastPhaseImage = images(end).name;
end
tempImage = imread([filename,lastPhaseImage]);
tempImage = intImRead([filename,lastPhaseImage]);
end

phase = intCropImage (tempImage);
Expand Down
4 changes: 2 additions & 2 deletions dev-lab/trackOptiZMerge.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function trackOptiZMerge( dirname, targetname, CONST, dz )

%% Load up first images and get the size

im = imread( [dirname,contents(1).name] );
im = intImRead( [dirname,contents(1).name] );

if numel(size(im)) > 2
im = im(:,:,2);
Expand Down Expand Up @@ -162,7 +162,7 @@ function intDoTimeStep( it, data, nnxy )
nameInfo_in.npos(:,1) = [it; ic; nnxy; iz];
in_name = [data.dirname, MakeFileName(nameInfo_in)];

tmp = imread( in_name );
tmp = intImRead( in_name );

if numel(size(tmp)) > 2
tmp = tmp(:,:,2);
Expand Down
13 changes: 8 additions & 5 deletions segmentation/doSeg.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,17 @@
nameInfo_tmp.npos(4,1) = 1; % z value
name = MakeFileName(nameInfo_tmp);
namePhase = [dirname_xy,'phase',filesep,name];
phase = intImRead( namePhase );

phase = intImLoader( namePhase, CONST );
if num_z > 1 % if there are z frames
phaseCat = zeros( [size(phase), num_z], 'uint16' );
phaseCat(:,:,1) = phase;

for iz = 2:num_z
nameInfo_tmp.npos(4,1) = iz;
name = MakeFileName(nameInfo_tmp);
phaseCat(:,:,iz) = intImRead( [dirname_xy,'phase',filesep,name] );
phaseCat(:,:,iz) = intImLoader( ...
[dirname_xy,'phase',filesep,name], CONST );
end
phase = mean( phaseCat, 3);
end
Expand Down Expand Up @@ -110,7 +111,8 @@
nameInfo_tmp.npos(2,1) = nc(k);
nameInfo_tmp.npos(4,1) = 1;
name = MakeFileName( nameInfo_tmp );
fluor_tmp = intImRead( [dirname_xy,'fluor',num2str(nc(k)-1),filesep,name] );
fluor_tmp = intImLoader( [dirname_xy,...
'fluor',num2str(nc(k)-1),filesep,name], CONST );
data.(['fluor',num2str(nc(k)-1)])=fluor_tmp;

imRange(:,k) = intRange( fluor_tmp(:) );
Expand All @@ -124,4 +126,5 @@
disp([dataname, ' already exists.']);
end

end
end

16 changes: 16 additions & 0 deletions segmentation/intImLoader.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function im = intImLoader( imname, CONST )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here

tmp_im = intImRead( imname );

if isfield( CONST.superSeggerOpti, 'rescale' ) && ...
CONST.superSeggerOpti.rescale ~= 1
im = imresize( tmp_im, CONST.superSeggerOpti.rescale );
else
im = tmp_im;
end


end

4 changes: 2 additions & 2 deletions trainingConstants/modifyConstValuesGUI.m
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ function image_folder_ClickedCallback(hObject, eventdata, handles)
[imageName,directoryName , ~] = uigetfile('*.tif', 'Pick an image file');
if imageName~=0
handles.directory.String = [directoryName,filesep,imageName];
settings_mod.phaseImage = imread(handles.directory.String);
settings_mod.phaseImage = intImRead(handles.directory.String);
axes(handles.viewport_modify);
imshow(settings_mod.phaseImage,[]);
end
Expand Down Expand Up @@ -517,7 +517,7 @@ function run_Callback(hObject, eventdata, handles)
if numel(imageName)<3 || ~strcmp(imageName(end-3:end), '.tif')
image_folder_ClickedCallback([],[],handles);
end
phaseIm = imread(handles.directory.String);
phaseIm = intImRead(handles.directory.String);

set(gcf,'Pointer','watch');
settings_mod.data = superSeggerOpti(phaseIm,[],0,CONST);
Expand Down
6 changes: 3 additions & 3 deletions trainingConstants/trainingGui.m
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ function loadData(frameNumber)
settings_train.currentData = load([settings_train.loadDirectory,settings_train.loadFiles(frameNumber).name]);
end
else
settings_train.currentData = imread([settings_train.imageDirectory,settings_train.loadFiles(frameNumber).name]);
settings_train.currentData = intImRead([settings_train.imageDirectory,settings_train.loadFiles(frameNumber).name]);
end
settings_train.currentIsBad = strfind(settings_train.loadFiles(frameNumber).name, '_mod.mat');

Expand Down Expand Up @@ -865,7 +865,7 @@ function makeData_Callback(hObject, eventdata, handles)
cropY = ceil(handles.viewport_train.YLim(1):handles.viewport_train.YLim(2) - 1);

for i = 1:settings_train.frameSkip:maxFrames
tempImage = imread([settings_train.imageDirectory,settings_train.loadFiles(i).name]);
tempImage = intImRead([settings_train.imageDirectory,settings_train.loadFiles(i).name]);
saveName = [newDir, filesep, settings_train.loadFiles(i).name];
imwrite( tempImage(cropY, cropX), saveName, 'TIFF' );
end
Expand Down Expand Up @@ -977,7 +977,7 @@ function save_cut_Callback(hObject, eventdata, handles)
i = settings_train.frameNumber;
filename =[ settings_train.imageDirectory,filesep,settings_train.loadFiles(i).name];

tempImage = imread([filename]);
tempImage = intImRead([filename]);
saveName = [filename];
imwrite( tempImage(cropY, cropX), saveName, 'TIFF' );

Expand Down
2 changes: 1 addition & 1 deletion viz/fixFlags.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@

% modifies the transparency of the phase/mask - use as double from 0 - 1
if ~isfield(FLAGS, 'level');
FLAGS.level = 0.8*ones([1,10]);
FLAGS.level = 0.5*ones([1,10]);
end

% modifies the transparency of the phase/mask - use as double from 0 - 1
Expand Down
16 changes: 9 additions & 7 deletions viz/superSeggerViewerGui.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
gui_mainfcn(gui_State, varargin{:});
end

function disable_all_panels (hObject,handles)
function disable_all_panels (~,handles)
set(findall(handles.gate_options_text, '-property', 'enable'), 'enable', 'off')
set(findall(handles.output_options_text, '-property', 'enable'), 'enable', 'off')
set(findall(handles.display_options_text, '-property', 'enable'), 'enable', 'off')
Expand Down Expand Up @@ -131,6 +131,9 @@ function initImage(hObject, handles) % Not updated
handles.num_errs = 0;
handles.canUseErr = 0;

axes(handles.axes1);
axis tight
cla;

if (nargin<1 || isempty(handles.image_directory.String))
handles.image_directory.String = pwd;
Expand All @@ -147,8 +150,7 @@ function initImage(hObject, handles) % Not updated

file_filter = '';
CONST = [];
axis tight
cla;


dirname = fixDir(dirname);
dirname0 = dirname;
Expand Down Expand Up @@ -238,21 +240,21 @@ function initImage(hObject, handles) % Not updated
handles.cell_poles.Value = FLAGS.p_flag;
handles.legend_box.Value = FLAGS.legend;
handles.outline_cells.Value = FLAGS.Outline_flag;
handles.foci_box.Value = FLAGS.s_flag;
handles.scores_foci.Value = FLAGS.scores_flag;

if FLAGS.f_flag
handles.foci_box.Value = FLAGS.s_flag(FLAGS.f_flag);
handles.scores_foci.Value = FLAGS.scores_flag;
handles.filt.Value = FLAGS.filt(FLAGS.f_flag);
handles.phase_flag.Value = FLAGS.phase_flag(FLAGS.f_flag);
else
handles.filt.Value = 0;
end

handles.region_outlines.Value = FLAGS.P_flag;
handles.region_scores.Value = FLAGS.regionScores;
handles.use_seg_files.Value = FLAGS.useSegs;
handles.show_daughters.Value = FLAGS.showDaughters;
handles.show_mothers.Value = FLAGS.showMothers;
handles.show_linking.Value = FLAGS.showLinks;
handles.phase_flag.Value = FLAGS.phase_flag;
handles.phase_level_txt.String = num2str(FLAGS.phase_level);
handles.composite.Value = FLAGS.composite;
if exist('nn','var');
Expand Down

0 comments on commit 8a3e47d

Please sign in to comment.