def is_boxlike(array): """Whether the binary object's dimensions are symmetric, i.e. box-like""" ymin, ymax, xmin, xmax = get_bounding_box(array) y = abs(ymax - ymin) x = abs(xmax - xmin) if x > max(y * 1.05, y+3) or x < min(y * 0.95, y-3): return False return True
def _find_field_centroid(self): """Find the centroid of the radiation field based on a 50% height threshold. Returns ------- p The CAX point location. edges The bounding box of the field, plus a small margin. """ min = np.percentile(self.array, 5) max = self.array.max() threshold_img = self.as_binary((max - min)/2 + min) [*edges] = get_bounding_box(threshold_img) edges[0] -= 10 edges[1] += 10 edges[2] -= 10 edges[3] += 10 coords = ndimage.measurements.center_of_mass(threshold_img) p = Point(x=coords[-1], y=coords[0]) return p, edges