Skip to content

Commit

Permalink
correct thresholding
Browse files Browse the repository at this point in the history
I changed thresholding to be >= instead of >, bc otherwise, pixels of value 0 get automatically excluded no matter the threshold
  • Loading branch information
emiglietta committed Feb 22, 2025
1 parent f5b4ba1 commit c9eb315
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions active_plugins/measurerwcperobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,13 @@ def run_image_pair_objects(

#combined_thresh_perObj is an boolean array representing all the pixels in a single object
# It is True in any pixel where BOTH first_pixels_perObj and second_pixels_perObj are above their respective threshold
combined_thresh_perObj = (first_pixels_perObj > tff_perObj[label-1]) & (second_pixels_perObj > tss_perObj[label-1])
# I needed to add 'above or equal' bc otherwise, 0 value pixels automatically get excluded no matter the threshold
combined_thresh_perObj = (first_pixels_perObj >= tff_perObj[label-1]) & (second_pixels_perObj >= tss_perObj[label-1])

# Count the number of above-threshold pixels remaining in the object, and get relative value vs the size of the object
#store values in arrays (remember label starts at 1 and array index at 0)
above_thresh_pixels_perObj[label-1] = numpy.count_nonzero(combined_thresh_perObj)
relative_above_thresh_pixels_perObj[label-1] = above_thresh_pixels_perObj[label-1] / numpy.count_nonzero(first_pixels_perObj)
relative_above_thresh_pixels_perObj[label-1] = above_thresh_pixels_perObj[label-1] / len(first_pixels_perObj)

# sum of the above-threshold (for both channels) pixel intensities per object
tot_fi_thr_perObj = scipy.ndimage.sum(
Expand Down

0 comments on commit c9eb315

Please sign in to comment.