[Scipy-svn] r3917 - in trunk/scipy/ndimage: . src/segment tests

scipy-svn@scip... scipy-svn@scip...
Mon Feb 11 19:25:40 CST 2008


Author: chris.burns
Date: 2008-02-11 19:25:33 -0600 (Mon, 11 Feb 2008)
New Revision: 3917

Added:
   trunk/scipy/ndimage/tests/slice112.raw
   trunk/scipy/ndimage/tests/test_segment.py
Removed:
   trunk/scipy/ndimage/src/segment/objectdata.py
   trunk/scipy/ndimage/src/segment/tests/
Modified:
   trunk/scipy/ndimage/segmenter.py
   trunk/scipy/ndimage/setup.py
Log:
Reorg tests for segment module.

Modified: trunk/scipy/ndimage/segmenter.py
===================================================================
--- trunk/scipy/ndimage/segmenter.py	2008-02-11 23:32:11 UTC (rev 3916)
+++ trunk/scipy/ndimage/segmenter.py	2008-02-12 01:25:33 UTC (rev 3917)
@@ -2,13 +2,32 @@
 import numpy as N
 import scipy.ndimage._segment as S
 
-# make sure this is local to use as default
-inputname = 'slice112.raw'
+# WARNING: _objstruct data structure mirrors a corresponding data structure
+# in ndImage_Segmenter_structs.h that is built into the _segment.so library.
+# These structs must match!  
+_objstruct = N.dtype([('L', 'i'),
+                    ('R', 'i'),
+                    ('T', 'i'),
+                    ('B', 'i'),
+                    ('Label', 'i'),
+                    ('Area', 'i'),
+                    ('cX', 'f'),
+                    ('cY', 'f'),
+                    ('curveClose', 'i'),
+                    ('cXB', 'f'),
+                    ('cYB', 'f'),
+                    ('bLength', 'f'),
+                    ('minRadius', 'f'),
+                    ('maxRadius', 'f'),
+                    ('aveRadius', 'f'),
+                    ('ratio', 'f'),
+                    ('compactness', 'f'),
+                    ('voxelMean', 'f'),
+                    ('voxelVar', 'f'),
+                    ('TEM', 'f', 20)]
+                   )
 
-import os
-filename = os.path.join(os.path.split(__file__)[0],inputname)
 
-
 def shen_castan(image, IIRFilter=0.8, scLow=0.3, window=7, lowThreshold=220+2048,
                 highThreshold=600+2048, dust=16):
     """
@@ -35,7 +54,7 @@
     labeledEdges, numberObjects = S.shen_castan_edges(scLow, IIRFilter, window, 
                                                       lowThreshold, highThreshold, image)
     # allocated struct array for edge object measures. for now just the rect bounding box
-    ROIList = N.zeros(numberObjects, dtype=S.objstruct)
+    ROIList = N.zeros(numberObjects, dtype=_objstruct)
     # return the bounding box for each connected edge
     S.get_object_stats(labeledEdges, ROIList)
     return labeledEdges, ROIList[ROIList['Area']>dust]
@@ -69,7 +88,7 @@
     labeledEdges, numberObjects = S.sobel_edges(sLow, tMode, lowThreshold, 
                                                 highThreshold, BPHigh, apearture, image)
     # allocated struct array for edge object measures. for now just the rect bounding box
-    ROIList = N.zeros(numberObjects, dtype=S.objstruct)
+    ROIList = N.zeros(numberObjects, dtype=_objstruct)
     # return the bounding box for each connected edge
     S.get_object_stats(labeledEdges, ROIList)
     # thin (medial axis transform) of the sobel edges as the sobel produces a 'band edge'
@@ -108,7 +127,7 @@
     labeledEdges, numberObjects = S.canny_edges(cSigma, cLow, cHigh, tMode, lowThreshold, highThreshold, 
                                                BPHigh, apearture, image)
     # allocated struct array for edge object measures. for now just the rect bounding box
-    ROIList = N.zeros(numberObjects, dtype=S.objstruct)
+    ROIList = N.zeros(numberObjects, dtype=_objstruct)
     # return the bounding box for each connected edge
     S.get_object_stats(labeledEdges, ROIList)
     return labeledEdges, ROIList[ROIList['Area']>dust]
@@ -185,7 +204,7 @@
     S.texture_measures(rawImage, labeledEdges, ROIList)
     return 
 
-def segment_regions():
+def segment_regions(filename):
     """
         sourceImage, labeledMask, ROIList = segment_regions()
 
@@ -223,7 +242,7 @@
     get_texture_measures(sourceImage, labeledMask, ROIList)
     return sourceImage, labeledMask, ROIList
 
-def grow_regions():
+def grow_regions(filename):
     """
         regionMask, numberRegions = region_grow()
         Inputs - No Input

Modified: trunk/scipy/ndimage/setup.py
===================================================================
--- trunk/scipy/ndimage/setup.py	2008-02-11 23:32:11 UTC (rev 3916)
+++ trunk/scipy/ndimage/setup.py	2008-02-12 01:25:33 UTC (rev 3917)
@@ -20,7 +20,6 @@
                          depends = ['src/segment/ndImage_Segmenter_structs.h']
     )
 
-    #config.add_subpackage('segment')
     config.add_data_dir('tests')
     config.add_subpackage('register')
 

Deleted: trunk/scipy/ndimage/src/segment/objectdata.py
===================================================================
--- trunk/scipy/ndimage/src/segment/objectdata.py	2008-02-11 23:32:11 UTC (rev 3916)
+++ trunk/scipy/ndimage/src/segment/objectdata.py	2008-02-12 01:25:33 UTC (rev 3917)
@@ -1,25 +0,0 @@
-
-import numpy as N
-
-objstruct =N.dtype([('L', 'i'),
-                    ('R', 'i'),
-                    ('T', 'i'),
-                    ('B', 'i'),
-                    ('Label', 'i'),
-                    ('Area', 'i'),
-                    ('cX', 'f'),
-                    ('cY', 'f'),
-                    ('curveClose', 'i'),
-                    ('cXB', 'f'),
-                    ('cYB', 'f'),
-                    ('bLength', 'f'),
-                    ('minRadius', 'f'),
-                    ('maxRadius', 'f'),
-                    ('aveRadius', 'f'),
-                    ('ratio', 'f'),
-                    ('compactness', 'f'),
-                    ('voxelMean', 'f'),
-                    ('voxelVar', 'f'),
-                    ('TEM', 'f', 20)]
-                   )
-

Copied: trunk/scipy/ndimage/tests/slice112.raw (from rev 3916, trunk/scipy/ndimage/src/segment/tests/slice112.raw)

Copied: trunk/scipy/ndimage/tests/test_segment.py (from rev 3916, trunk/scipy/ndimage/src/segment/tests/test_segment.py)
===================================================================
--- trunk/scipy/ndimage/src/segment/tests/test_segment.py	2008-02-11 23:32:11 UTC (rev 3916)
+++ trunk/scipy/ndimage/tests/test_segment.py	2008-02-12 01:25:33 UTC (rev 3917)
@@ -0,0 +1,29 @@
+
+from scipy.testing import *
+from scipy.ndimage.segmenter import *
+
+inputname = 'slice112.raw'
+
+from os.path import join, dirname
+filename = join(dirname(__file__), inputname)
+
+class TestSegment(TestCase):
+    def test1(self):
+        image = get_slice(filename)
+        sourceImage = image.copy()
+        edges, objects = sobel(image)
+        get_shape_mask(edges, objects)
+        get_voxel_measures(sourceImage, edges, objects)
+        get_texture_measures(sourceImage, edges, objects)
+
+    def test2(self):
+        sourceImage, labeledMask, ROIList = segment_regions(filename)
+
+    def test3(self):
+        regionMask, numberRegions = grow_regions(filename)
+        regionMask.max()
+        #save_slice(regionMask, 'regionMask.raw')
+
+    
+if __name__ == "__main__":
+    inittest.main()



More information about the Scipy-svn mailing list