in ez_wsi_dicomweb/slide_level_map.py [0:0]
def get_frame_number_by_point(self, x: int, y: int) -> int:
"""Gets the frame number corresponding to the input coordinate.
Args:
x: The x coordinate at the level the instance belongs to.
y: The y coordinate at the level the instance belongs to.
Returns:
The frame number that contains the input coordinate.
Raises:
CoordinateOutofImageDimensionsError if the input coordinate is out of the
range.
"""
if x < 0 or y < 0 or x >= self.width or y >= self.height:
raise ez_wsi_errors.CoordinateOutofImageDimensionsError(
f'The input coordinate {x, y} is out of the range: '
f'{0, 0, self.width - 1, self.height - 1}'
)
frame_x = int(x / self.frame_width)
frame_y = int(y / self.frame_height)
frames_per_row = int(math.ceil(float(self.width) / float(self.frame_width)))
return frame_y * frames_per_row + frame_x + 1