Skip to content
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

PatchGenerator - Whole Slide image - Get position of the patch (x,y) #209

Open
LouisStefanuto opened this issue Aug 6, 2024 · 4 comments

Comments

@LouisStefanuto
Copy link

LouisStefanuto commented Aug 6, 2024

Is your feature request related to a problem? Please describe.
No pb. Just looking for a feature.
I am generating patches from a TIFF image.

Describe the solution you'd like
I would like to be able to get the pixel position of the patch, let's say the (x,y) of the top left pixel
Ideally it would be something like:

for patch in fast.DataStream(patchGenerator):
  x, y = patch.x, patch.y

Do you have an idea of how it can/should be implemented?
Currently I have access to the path number

for i, patch in enumerate(fast.DataStream(patchGenerator)):

I could compute the position using the stride, tile size and padding, but I am hoping it is already implemented somewhere.

Are you willing to contribute to the implementation of this feature
N/A

@LouisStefanuto LouisStefanuto changed the title PatchGenerator - Position of the patch PatchGenerator - Position of the patch (x,y) Aug 6, 2024
@LouisStefanuto LouisStefanuto changed the title PatchGenerator - Position of the patch (x,y) PatchGenerator - Get position of the patch (x,y) Aug 6, 2024
@LouisStefanuto LouisStefanuto changed the title PatchGenerator - Get position of the patch (x,y) PatchGenerator - Whole Slide image - Get position of the patch (x,y) Aug 6, 2024
@smistad
Copy link
Owner

smistad commented Aug 6, 2024

Hi, this is possible to extract, but I agree it should be more accessible and documented.

Here is how you can do it today (ref https://github.com/smistad/FAST/pull/206/files) :

patch_width, patch_height = int(patch.getFrameData("patch-width")), int(patch.getFrameData("patch-height"))
patch_overlap_x, patch_overlap_y = int(patch.getFrameData("patch-overlap-x")), int(patch.getFrameData("patch-overlap-y"))
x_pos = int(patch.getFrameData("patchid-x")) * (patch_width - patch_overlap_x * 2) + patch_overlap_x 
y_pos = int(patch.getFrameData("patchid-y")) * (patch_height - patch_overlap_y * 2) + patch_overlap_y

@LouisStefanuto
Copy link
Author

  1. Thanks for answering so fast
  2. Thanks a lot, it works perfectly
  3. Wonderful library, I love it 😍

@LouisStefanuto
Copy link
Author

Before closing the issue, I don't see it in the doc. Is it coming in the next release ?

@smistad
Copy link
Owner

smistad commented Aug 6, 2024

Just leave the issue open so I can remember to make a single property of this instead of needing to calculate it.

I just haven't updated the documentation yet.

Thanks for your feedback 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants