コード例 #1
0
    def make_workspace_ijv(self):
        module = C.ConvertToImage()
        shape = (14, 16)
        r = np.random.RandomState()
        r.seed(0)
        i = r.randint(0, shape[0], size=np.prod(shape))
        j = r.randint(0, shape[1], size=np.prod(shape))
        v = r.randint(1, 8, size=np.prod(shape))
        order = np.lexsort((i, j, v))
        ijv = np.column_stack((i, j, v))
        ijv = ijv[order, :]
        same = np.all(ijv[:-1, :] == ijv[1:, :], 1)
        ijv = ijv[~same, :]

        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)
        objects = cpo.Objects()
        objects.set_ijv(ijv, shape)
        object_set.add_objects(objects, OBJECTS_NAME)
        self.assertGreater(len(objects.get_labels()), 1)
        module.image_name.value = IMAGE_NAME
        module.object_name.value = OBJECTS_NAME
        return (workspace, module, ijv)
コード例 #2
0
 def make_workspace(self):
     module = C.ConvertToImage()
     labels = np.reshape(np.arange(256), (16, 16))
     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)
     objects = cpo.Objects()
     objects.segmented = labels
     object_set.add_objects(objects, OBJECTS_NAME)
     module.image_name.value = IMAGE_NAME
     module.object_name.value = OBJECTS_NAME
     return (workspace, module)