Skip to content

Get pixel witdth and hight #192

Answered by smistad
Peregalli asked this question in Q&A
Nov 1, 2023 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

Hi

If that information is stored in your TIFF you can get that information with the getSpacing() method.

For an extracted patch at level, x, y with a specific width and height:

access = imagePyramid.getAccess(fast.ACCESS_READ)
image = access.getPatchAsImage(level, x, y, width, height)
spacing_x = image.getSpacing()[0,0]
spacing_y = image.getSpacing()[1,0]

This corresponds to the spacing for the given level of the patch.

You can also get the spacing for level 0 directly from the image pyramid:

spacing_x = imagePyramid.getSpacing()[0,0]
spacing_y = imagePyramid.getSpacing()[1,0]

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Peregalli
Comment options

@andreped
Comment options

@smistad
Comment options

Answer selected by Peregalli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants