Open sichendart opened 4 years ago
For beamline auto alignment I am using regionprops.
My code is something like this:
from skimage.measure import regionprops
def center_of_mass(image):
threshold_value = filters.threshold_otsu(image)
log.info(" *** threshold_value: %f" % (threshold_value))
labeled_foreground = (image < threshold_value).astype(int)
properties = regionprops(labeled_foreground, image)
return properties[0].weighted_centroid
cmass = center_of_mass(image)
log.info(' *** center of mass: [%f, %f]' % (cmass[0], cmass[1]))
@decarlof The example code I came across is similar to this one, but they have a greater-than sign instead of a less -than sign. Either way it works well. I added this and a pop-up menu to select between weighted and non-weighted COM options as well as shifting in x only or x and y.
the results could be very different by clicking "center of mass" multiple times