From 01439f65fa04f64caae9e568d2c75b56fe74e47f Mon Sep 17 00:00:00 2001
From: Peter Reischig <peter.reischig@esrf.fr>
Date: Tue, 18 Sep 2012 14:33:31 +0000
Subject: [PATCH] Bug fix to bounding box problem to avoid grains shift in the
 grain map. By Nicola.

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@772 4c865b51-4357-4376-afb4-474e03ccb993
---
 4_grains/GtThreshold.m            | 2 +-
 zUtil_TomoUtils/GtGrainsManager.m | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/4_grains/GtThreshold.m b/4_grains/GtThreshold.m
index 6049719f..65517f76 100644
--- a/4_grains/GtThreshold.m
+++ b/4_grains/GtThreshold.m
@@ -162,7 +162,7 @@ classdef GtThreshold < handle
             segvol = obj.segmentVol(volume, threshold, do_morpho, mess, center);
         end
 
-        function thresholdSingleGrainInFile(obj, phaseID, grainID, threshold, center)
+        function grain = thresholdSingleGrainInFile(obj, phaseID, grainID, threshold, center)
         % GTTHRESHOLD/THRESHOLDSINGLEGRAININFILE
 
             fprintf('Segmenting Grain %d, from phase %d.. ', grainID, phaseID);
diff --git a/zUtil_TomoUtils/GtGrainsManager.m b/zUtil_TomoUtils/GtGrainsManager.m
index 12b9aaf5..34e8c867 100644
--- a/zUtil_TomoUtils/GtGrainsManager.m
+++ b/zUtil_TomoUtils/GtGrainsManager.m
@@ -229,10 +229,11 @@ classdef GtGrainsManager < GtVolView
             obj.sample.phases{phaseID}.setThreshold(grainID, threshold);
             segmenter = GtThreshold();
             if (exist('center', 'var'))
-                segmenter.thresholdSingleGrainInFile(phaseID, grainID, threshold, center);
+                grain = segmenter.thresholdSingleGrainInFile(phaseID, grainID, threshold, center);
             else
-                segmenter.thresholdSingleGrainInFile(phaseID, grainID, threshold);
+                grain = segmenter.thresholdSingleGrainInFile(phaseID, grainID, threshold);
             end
+            obj.sample.phases{phaseID}.setBoundingBox(grainID, grain.segbb);
         end
     end
 
-- 
GitLab