Coder Social home page Coder Social logo

Comments (7)

One-sixth avatar One-sixth commented on August 18, 2024 2

Hey everyone,

It does make sense to support this.

The implementation would be limited to these few lines:

https://github.com/bayer-science-for-a-better-life/tiffslide/blob/56b5bbda36a2792a93b3eabd30c590f004835b41/tiffslide/tiffslide.py#L358-L408

TODOs:

This is a pretty well defined PR. Anyone up for tackling it? 😃

Cheers, Andreas

I am working on it.
A PR will open later.

from tiffslide.

BenjaminIsaac0111 avatar BenjaminIsaac0111 commented on August 18, 2024 1

Amazing, just saw this!

Thanks for the implementation! @ap-- @One-sixth

Wilson

from tiffslide.

ap-- avatar ap-- commented on August 18, 2024

Hey there,

Thanks for the bug report! ❤️
I'm a bit hesitant to implement this, but openslide definitely allows you to pad in all directions 🤔 ...

import numpy as np
import openslide

def _is_padding(im):
    return np.all(np.array(im) == 0)

slide = openslide.open_slide("some.svs")
slide.level_dimensions
>>> ((63743, 36055), (15935, 9013), (3983, 2253))

# oob positive
_is_padding(slide.read_region((1_000_000, 1_000_0000), 0, (10, 10)))
>>> True

# oob negative
_is_padding(slide.read_region((-1_000_000, -1_000_0000), 0, (10, 10)))
>>> True

# oob higher level than available
_is_padding(slide.read_region((0, 0), 1000, (10, 10)))
>>> True

# oob negative level
_is_padding(slide.read_region((0, 0), -1000, (10, 10)))
>>> True

# empty reads
slide.read_region((0, 0), 0, (0, 0))  # tile width and/or height can be 0
>>> <PIL.Image.Image image mode=RGBA size=0x0 at 0x7F926D19E220>

I think I'd like to default to not allow this (because I think it's a potential source of unwanted bugs). But we could offer a keyword argument and in addition some global setting to be able to allow the exact behavior above. Maybe even allowing to set the padding value.

This should also ship with more compatibility tests for openslide as mentioned in #1.

Would you like to contribute to implementing this functionality in a PR?
I could provide some feedback, or sketch out an initial draft.

Cheers,
Andreas 😃

from tiffslide.

One-sixth avatar One-sixth commented on August 18, 2024

@ap--
I had this problem recently too.
We need to keep the same padding method as openslide.
The coordinate system I use here uses negative numbers and functions that allow to exceed boundaries.

This makes it easy to slice the slide without running into annoying border issues.
In practice, we always do padding to keep the model input size.
Resize will causes abnormal image aspect ratio.

from tiffslide.

ap-- avatar ap-- commented on August 18, 2024

Hey everyone,

It does make sense to support this.

The implementation would be limited to these few lines:
https://github.com/bayer-science-for-a-better-life/tiffslide/blob/56b5bbda36a2792a93b3eabd30c590f004835b41/tiffslide/tiffslide.py#L358-L408

TODOs:

This is a pretty well defined PR. Anyone up for tackling it? 😃

Cheers,
Andreas

from tiffslide.

One-sixth avatar One-sixth commented on August 18, 2024

@ap--
How do you think about filling with any color? Let the parameter padding = (0, 0, 0) .

from tiffslide.

ap-- avatar ap-- commented on August 18, 2024

Let's start with padding with 0 only.
We'll think about user provided padding values in a separate issue.

Thank you so much for contributing!

from tiffslide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.