tomography / XRFtomo

a repository for xray fluorescence data processing
Other
3 stars 6 forks source link

need to look into the function of "center of mass" for alignment #49

Open sichendart opened 4 years ago

sichendart commented 4 years ago

the results could be very different by clicking "center of mass" multiple times

decarlof commented 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]))
FabricioSMarin commented 4 years ago

@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.