-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[help] Get level shape #1546
Comments
I think you can do this with a combination of the large_image/large_image/tilesource/base.py Line 1615 in 2ac5834
The lead developer is away on leave but can respond when he returns. |
@cooperlab using |
I understand. Given the size and resolution of the native level, convertRegionScale can translate the "region" of the whole slide to other resolutions which would give you the corresponding size. large_image provides more flexibility in reading at off-level magnifications but it does complicate things a bit. I just wanted to provide a hint until @manthey can reply in case you need a quick solution. |
@cooperlab , very appreciated. Could you provide me with some example code? I can’t figure out how to implement it. |
I have attempted the following solution to address the problem at hand. I am awaiting a response from @manthey to determine if there is a more robust solution available. def _correct_level(self, level: int):
max_level = self.slide.levels - 1
# Large Image levels are in the opposite order of OpenSlide levels
return max_level - level
def get_image_shape(self, level: int = 0):
level = self._correct_level(level)
# get magnification for level
mag = self.slide.getMagnificationForLevel(level)
metadata = self.slide.metadata
left, top, right, bottom = self.slide._getRegionBounds(
metadata, desiredMagnification=mag)
regionWidth = right - left
regionHeight = bottom - top
if mag.get('scale') in (1.0, None):
maxWidth, maxHeight = regionWidth, regionHeight
else:
maxWidth = regionWidth / cast(float, mag['scale'])
maxHeight = regionHeight / cast(float, mag['scale'])
outWidth, outHeight, calcScale = large_image.tilesource.utilities._calculateWidthHeight(
maxWidth, maxHeight, regionWidth, regionHeight)
return outHeight, outWidth I adapted the code provided here: |
@alevangel you can also use the result of |
I'm having trouble obtaining the shape of the image level for each level. In OpenSlide, there is the parameter
slide.level_dimensions[level]
, but I haven't found anything similar in this library. How can I accomplish that?The text was updated successfully, but these errors were encountered: