These are chat archives for openseadragon/openseadragon

21st
Jun 2016
foobarable
@foobarable
Jun 21 2016 08:05
@sickrandir could I see your solution for adding new buttons? I'm using collection mode and want to implement a 'next' and 'previous' button for it so it seems i need to add a custom control as well @iangilman
Toke Eskildsen
@tokee
Jun 21 2016 10:37
I am creating an on-the-fly recursive mosaic generator, akin to https://xkcd.com/1416/ but with greyscale scanned images as sources. This works fine up to a virtual image size of 300*10⁹ x 500*10⁹ pixels (with deepest level being 39), but if I go higher than that, the browser (Firefox as well as Chrome) freezes at full zoom. I guess it is because of overflow or rounding errors.
I would like to hear if there are any tricks to achieve "infinite" zoom (with panning) or just "extremely large zoom"; something in the order of 10⁵⁰ x 10⁵⁰ pixels virtual size would work well for all but the most stalwart zoomers.
VoidVolker
@VoidVolker
Jun 21 2016 10:55
@tokee 2*10^10 - is limit for signed int at x32 arch(2 147 483 647), and 9*10^19 for signed int on x64 (9 223 372 036 854 775 807), you need simulate it or use big math modules
Toke Eskildsen
@tokee
Jun 21 2016 10:59
@VoidVolker I thought all JavaScript numbers were 64 bit doubles? http://www.w3schools.com/js/js_numbers.asp But I readily admit that I don't know much about either JavaScript or the internals of OpenSeadragon.
VoidVolker
@VoidVolker
Jun 21 2016 10:59
I context of OSD, I think it can be achieved via few instances of OSD viewer: split zoom levels for blocks to maximum image size up to 10^9 and for each block use new instance
@tokee it depends on browser arch
@tokee check Number.MAX_SAFE_INTEGER
Toke Eskildsen
@tokee
Jun 21 2016 11:03
I follow the concept of "resetting" OSD when it reaches a certain level. I could keep a stack of previous "level packs" to allow for zoom-back, but I think it would be a problem to support panning from edge to edge at deep levels.
foobarable
@foobarable
Jun 21 2016 11:04
@tokee it looks like randal also resets its viewer at some point
Toke Eskildsen
@tokee
Jun 21 2016 11:05
@foobarable Do you know what happens when it does? Is it still possible to zoom back out?
foobarable
@foobarable
Jun 21 2016 11:06
zooms again
Toke Eskildsen
@tokee
Jun 21 2016 11:06
Sorry, I should do that myself.
foobarable
@foobarable
Jun 21 2016 11:07
hehe
actually, i may be wrong
it felt like the last time
Toke Eskildsen
@tokee
Jun 21 2016 11:26
Found this: http://chromakode.com/post/notes-on-xkcd-pixels which is a great blog post on the problem. It handles the problem of overflow by coordinates being relative to the previous level in the stack, instead of being absolute to the full virtual image. That seems a lot like your suggestion with OSD viewer switching, @VoidVolker.
VoidVolker
@VoidVolker
Jun 21 2016 11:37
@tokee yes, correct, I suggest exactly same, and your idea with resetting OSD is better, which can be achieved with adding one more level it image links (level/z/y/x)
Toke Eskildsen
@tokee
Jun 21 2016 11:40
Seems like the only way ahead for me is hard work getting such a stack-based system to line up. Thanks for the help.
VoidVolker
@VoidVolker
Jun 21 2016 12:15
@tokee basically, it is very simple
VoidVolker
@VoidVolker
Jun 21 2016 13:01
you need just create one variable with second zoom level
Toke Eskildsen
@tokee
Jun 21 2016 13:03
And coordinates within the current zoom level. But yes, the theory is easy enough. Based on the past weeks experience, easy theory will not stop me from having to spend a lot of time getting the different levels and coordinates to align properly.
VoidVolker
@VoidVolker
Jun 21 2016 13:15
something like this you need:

class ZoomStack
    class StackItem
        constructor: (@level, @x, @y) ->

    constructor: () ->
        @stack = []
        @add = (x, y) =>
            item = new StackItem @stack.length, x or 0, y or 0
            @stack.push item 
            return item
and, in code, when you will get the top/bottom of current zoom, if default zoom is 0:
z = new ZoomStack
z.add currentX, currentY
Toke Eskildsen
@tokee
Jun 21 2016 13:19
Seems reasonable, thanks. So 1 stack item per level, instead of 1 stack item per a number of levels? Seems like that would simplify the logic.
VoidVolker
@VoidVolker
Jun 21 2016 13:24
if your zoom isn't 0 by default, then you need to initialize stack with all zoom levels with default coords (0;0) or with middle zoom
Toke Eskildsen
@tokee
Jun 21 2016 13:25
Good point. I think it starts at 8.
VoidVolker
@VoidVolker
Jun 21 2016 13:36
example 2:
class ZoomStack
    class StackItem
        constructor: (@level, @x=0, @y=0) ->

    level: -> @stack[@l]

    constructor: (@l, @count) -> 
        @l = @l or 0    # l - current zoom level
        @stack = ( new StackItem(i, 0, 0) for i in [0..@count] )
        @add = (x, y) =>
            item = new StackItem @stack.length, x, y
            @stack.push item 
            return item
Toke Eskildsen
@tokee
Jun 21 2016 13:40
x & y will have to be the OSD coordinates, not the tile indexes, to avoid a jumpy reset at level switch?
VoidVolker
@VoidVolker
Jun 21 2016 13:41
yeah, I think
Toke Eskildsen
@tokee
Jun 21 2016 13:48
I will try if I can fit the stacks into my current code. You have been most helpful, @VoidVolker, thanks.
VoidVolker
@VoidVolker
Jun 21 2016 13:54
@tokee np ) feel free to ask more questions, if you don't use coffee-script - I can translate it for you to js
or use coffee web site, it have online translator
Toke Eskildsen
@tokee
Jun 21 2016 13:57
I found the very nice converter at http://js2.coffee/, thanks. It is a lot more elegant in coffee script, I must say.
VoidVolker
@VoidVolker
Jun 21 2016 14:21
@tokee yeah, coffe awesome, try it )
Ian Gilman
@iangilman
Jun 21 2016 16:26
@tokee @VoidVolker Great discussion! I agree with the strategy. BTW, here's an infinite zoom thing I did with OSD: http://iangilman.com/openseadragon/chrisjordan/ There's no user control and no panning, so it doesn't really solve your problems, but it does deal with having to reset.
Ian Gilman
@iangilman
Jun 21 2016 17:13
OSD 2.2.1 is released, with a fix for a crash on iOS: https://github.com/openseadragon/openseadragon/releases/tag/v2.2.1
VoidVolker
@VoidVolker
Jun 21 2016 17:30
@iangilman is horizontal infinite scroll fixed?
Ian Gilman
@iangilman
Jun 21 2016 17:30
Fixed as in what?
VoidVolker
@VoidVolker
Jun 21 2016 17:34
as I remember, long time ago there was bug: when you scroll horizontally - it accumulates calculation error and OSD render new tiles with lag and we can see background
Ian Gilman
@iangilman
Jun 21 2016 17:35
Gotcha, no, that still hasn't been fixed.
Here's the issue: openseadragon/openseadragon#555 Looks like @avandecreme has already tracked down the source of the problem, we just need someone to turn it into a solution!
sickrandir
@sickrandir
Jun 21 2016 17:42
@foobarable yes basically I just add the controls to the html and then I add them to the OSD viewer doing something like: viewer.addControl('id1', {'anchor': OpenSeadragon.ControlAnchor.TOP_RIGHT });
@foobarable that's it
VoidVolker
@VoidVolker
Jun 21 2016 17:43
@iangilman can't undersatand where exactly problem, can you help? I can try to fix it
Ian Gilman
@iangilman
Jun 21 2016 17:45
@VoidVolker Let's see if @avandecreme can help explain it; if not, I'll look into it with you.
VoidVolker
@VoidVolker
Jun 21 2016 17:46
loooks like he is offline
Ian Gilman
@iangilman
Jun 21 2016 17:47
Yeah, I mean let's see if he chimes in in the next day or so.
He's the one that found the issue, so he'll understand it better.
Toke Eskildsen
@tokee
Jun 21 2016 17:50
@iangilman Very nice infinity-zoomer. That is close to what I am building, although mine just does simple color-matching (greyscale intensity really) to map equally sized rectangular parts. I am happy to see that the switch over can be done without noticeable stutter.
Ian Gilman
@iangilman
Jun 21 2016 17:52
Thanks! I look forward to seeing yours in action!
@VoidVolker I've updated the ticket as well; he'll get notified. Thank you for looking into the issue!
Antoine Vandecreme
@avandecreme
Jun 21 2016 19:00
@VoidVolker I updated the link to the source code in the issue. Let me know what part I should clarify.