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

Support tile overlap for DZI #2

Open
iangilman opened this issue Jul 28, 2015 · 9 comments
Open

Support tile overlap for DZI #2

iangilman opened this issue Jul 28, 2015 · 9 comments

Comments

@iangilman
Copy link
Contributor

Specified in pixels. Default should be 1. Default tileSize should be 254.

Overlap is added to the size of a tile. So, a middle tile (with neighbors on all sides) with a tileSize of 254 and an overlap of 1 would have an actual size of 256 (254 + 1 for each side). A tile on the edge (with only 1 neighbor) would have an actual size of 255 (254 + the one neighbor side).

Each overlap row or column is basically taken from the side of the neighboring tile. It's like you sliced all the tiles up without overlap, but then just added rows and columns of pixels from each neighboring tile.

@avandecreme
Copy link

Shouldn't the default be 256 instead of 254?
I am not sure what other tools are doing actually.
In OSD example-images we have:
-duomo: TileSize="254" Overlap="1"
-highsmith: Overlap="2" TileSize="256"
-pnp/pan/6a32400/6a32487: Overlap="2" TileSize="512"
-pnp/ppmsca/*/: Overlap="2" TileSize="256"

So definitely some inconsistency.

@iangilman
Copy link
Contributor Author

Well, I actually don't know to what extent it matters these days, but general graphics programming wisdom is you try to keep your tiles at or under powers of 2. So a 256 tile size would be perfect if you had no overlap. With overlap, however, it makes the tiles bigger, so a middle tile with TileSize="256" and Overlap="1" would have a width of 258, just 2 pixels over the power of 2 (and therefore theoretically less efficient for the GPU). That's why I suggest 254/1, which would produce a max actual tile size of 256.

Does that make sense? And yes, perhaps we should figure out if it really matters and come up with some official recommendations we can post somewhere, because obviously the data out there is pretty random.

@avandecreme
Copy link

Thanks for the clarification.

@VoidVolker
Copy link
Owner

Yes, but now I can't add overlap, because imagemagick have very specific options for it and overlapping can be done only with perfect size images (power of zoom for each image side). IM can do overlap only for number of tiles for each side. It mean, if image not perfect size - tile size can't be controled. Also, official DZI format support only square images. But, OSD support any size ^_^

@VoidVolker
Copy link
Owner

http://www.imagemagick.org/Usage/crop/#crop_spaced - here is imagemagick overlap options manual.

@iangilman
Copy link
Contributor Author

Actually, you can use ImageMagick to pull any arbitrary portion of an image out. You just do the math for what portion you need and then tell it to grab that part. For instance, if you want to grab a 200x200 pixel square starting at 100px down from the top and 100px in from the left, use:

convert input.jpg -crop 200x200+100+100 output.jpg

With this technique you can support overlap.

@VoidVolker
Copy link
Owner

Yes, I know this — I read documentation. I have very strange result — few small tiles with many numbers names.

@iangilman
Copy link
Contributor Author

Should just be a matter of sorting out your logic. I think right now you're having it tile automatically, right? With this technique you would have to do the math for each tile.

@jcupitt
Copy link

jcupitt commented Mar 15, 2018

Hello, libvips recently and painfully revised overlap handling to match the DZI spec. The issue here has the discussion:

https://github.com/jcupitt/libvips/issues/795

There are a lot of useful links (and some nice posts from the original dzi developers) describing the details of tile layout. It might be helpful.

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

4 participants