def make_workspace(self, image, mask=None): '''Make a workspace for testing ApplyThreshold''' module = A.ApplyThreshold() module.image_name.value = INPUT_IMAGE_NAME module.thresholded_image_name.value = OUTPUT_IMAGE_NAME pipeline = cpp.Pipeline() object_set = cpo.ObjectSet() image_set_list = cpi.ImageSetList() image_set = image_set_list.get_image_set(0) workspace = cpw.Workspace(pipeline, module, image_set, object_set, cpmeas.Measurements(), image_set_list) image_set.add( INPUT_IMAGE_NAME, cpi.Image(image) if mask is None else cpi.Image(image, mask)) return workspace, module
def test_04_07_threshold_from_measurement(self): '''Test a binary threshold from previous measurements''' np.random.seed(0) image = np.random.uniform(size=(20, 20)) workspace, module = self.make_workspace(image) module.binary.value = A.BINARY module.threshold_method.value = T.TM_MANUAL module.manual_threshold.value = .5 module.run(workspace) module2 = A.ApplyThreshold() module2.image_name.value = OUTPUT_IMAGE_NAME module2.thresholded_image_name.value = OUTPUT_IMAGE_NAME + 'new' module2.binary.value = A.BINARY module2.threshold_scope.value = T.TM_MEASUREMENT module2.thresholding_measurement.value = 'Threshold_FinalThreshold_' + OUTPUT_IMAGE_NAME module2.run(workspace)