Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
np.max(new_objects.segmented))
cpmi.add_object_location_measurements(measurements,
self.new_primary_objects_name.value,
new_objects.segmented)
for parent_objects, parent_name, child_objects, child_name in (
(objects, self.primary_objects.value,
new_objects, self.new_primary_objects_name.value),
(new_objects, self.new_primary_objects_name.value,
objects_out, objname)):
children_per_parent, parents_of_children = \
parent_objects.relate_children(child_objects)
measurements.add_measurement(parent_name,
cpmi.FF_CHILDREN_COUNT%child_name,
children_per_parent)
measurements.add_measurement(child_name,
cpmi.FF_PARENT%parent_name,
parents_of_children)
def get_measurement_columns(self, pipeline):
'''Return information to use when creating database columns'''
orig_image_name = self.object_name.value
filtered_image_name = self.filtered_objects.value
columns = I.get_object_measurement_columns(filtered_image_name)
columns += [(orig_image_name,
I.FF_CHILDREN_COUNT % filtered_image_name,
cpmeas.COLTYPE_INTEGER),
(filtered_image_name,
I.FF_PARENT % orig_image_name,
cpmeas.COLTYPE_INTEGER)]
return columns
# Write out the objects
#
workspace.object_set.add_objects(tertiary_objects,
self.subregion_objects_name.value)
#
# Write out the measurements
#
m = workspace.measurements
#
# The parent/child associations
#
for parent_objects_name, parents_of, child_count\
in ((self.primary_objects_name, primary_parents,child_count_of_primary),
(self.secondary_objects_name, secondary_parents, child_count_of_secondary)):
m.add_measurement(self.subregion_objects_name.value,
cpmi.FF_PARENT%(parent_objects_name.value),
parents_of)
m.add_measurement(parent_objects_name.value,
cpmi.FF_CHILDREN_COUNT%(self.subregion_objects_name.value),
child_count)
object_count = np.max(tertiary_labels)
#
# The object count
#
cpmi.add_object_count_measurements(workspace.measurements,
self.subregion_objects_name.value,
object_count)
#
# The object locations
#
cpmi.add_object_location_measurements(workspace.measurements,
self.subregion_objects_name.value,
else:
parent_objects = np.arange(1, nobjects+1)
#
# Add the objects
#
remaining_objects = cpo.Objects()
remaining_objects.segmented = labels
remaining_objects.unedited_segmented = original_objects.unedited_segmented
workspace.object_set.add_objects(remaining_objects,
remaining_object_name)
#
# Add measurements
#
m = workspace.measurements
m.add_measurement(remaining_object_name,
I.FF_PARENT % object_name,
parent_objects)
if np.max(original_objects.segmented) == 0:
child_count = np.array([],int)
else:
child_count = fix(scind.sum(labels, original_objects.segmented,
np.arange(1, nobjects+1)))
child_count = (child_count > 0).astype(int)
m.add_measurement(object_name,
I.FF_CHILDREN_COUNT % remaining_object_name,
child_count)
if self.retain_or_renumber == R_RETAIN:
remaining_object_count = nobjects
else:
remaining_object_count = len(unique_labels)
I.add_object_count_measurements(m, remaining_object_name,
remaining_object_count)