Openslide Python viewer for desktop applications.

MrAr0s . mrar0sgr at gmail.com
Wed Feb 14 09:28:40 EST 2018


Thank you very much for the quick reply.

Eventually i'm going to start developing on a WSI desktop viewer. For the
time being, i have decided to proceed with the browser viewer.
I'm trying to extend the deepzoom_multiserver code, by giving it the
ability to add images on the same viewer. To do that, i have changed the
code of the slide(path) function

@app.route('<path:path>')
def slide(path)
       slide = _get_slide(path)
       slide_url = url_for('dzi', path=path)
       return render_template('slide-fullpage.html', slide_url=slide_url,
slide_filename=slide.filename, slide_mpp=slide.mpp, overlay_url=slide_url)

So, i basically added a variable, overlay_url, whose value is the original
opened image, to the html code. My slide-fullpage.html file looks like this:

<!doctype html>
<meta charset="utf-8">
<title>{{ slide_filename }}</title>

<style type="text/css">
html {
    overflow: hidden;
}
body {
    margin: 0;
    padding: 0;
}
div#view {
    position: absolute;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: black;
    color: white;
}
</style>

<div id="view"></div>

<script type="text/javascript" src="{{ url_for('static',
filename='jquery.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static',
filename='openseadragon.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static',
filename='openseadragon-scalebar.js') }}"></script>
<script type="text/javascript">
$(document).ready(function() {
    var viewer = new OpenSeadragon({
        id: "view",
        tileSources: "{{ slide_url }}",
        prefixUrl: "{{ url_for('static', filename='images/') }}",
        showNavigator: true,
        showRotationControl: true,
        animationTime: 0.5,
        blendTime: 0.1,
        constrainDuringPan: true,
        maxZoomPixelRatio: 2,
        minZoomLevel: 1,
        visibilityRatio: 1,
        zoomPerScroll: 2,
        timeout: 120000,
    });
    viewer.addHandler("open", function() {
        // To improve load times, ignore the lowest-resolution Deep Zoom
        // levels.  This is a hack: we can't configure the minLevel via
        // OpenSeadragon configuration options when the viewer is created
        // from DZI XML.
        viewer.source.minLevel = 8;
    });
viewer.addTiledImage({
tileSource: '{{overlay_url}}',
x: 0,
y: 0,
width: 10
})
    var mpp = parseFloat("{{ slide_mpp }}");
    viewer.scalebar({
        pixelsPerMeter: mpp ? (1e6 / mpp) : 0,
        xOffset: 10,
        yOffset: 10,
        barThickness: 3,
        color: '#555555',
        fontColor: '#333333',
        backgroundColor: 'rgba(255, 255, 255, 0.5)',
    });
});
</script>

But the newly added image isn't added to the viewer. I also tried
viewer.addSimpleImage, but that didn't work too. Do you have any
suggestions?

Thanks in Advance.

2018-02-10 23:05 GMT+02:00 Benjamin Gilbert <bgilbert at cs.cmu.edu>:

> On Fri, Feb 09, 2018 at 09:11:22PM +0200, MrAr0s . wrote:
> > Is there any way of viewing the images on a Python GUI using the already
> > existing code, just like in Java?  And if not, do you have any guidelines
> > to get me closer to doing so?
>
> There isn't.  While Java has its own GUI toolkit, Python does not, so
> OpenSlide Python doesn't have built-in support.  You could write a GUI in
> Python, though, using Python bindings to a toolkit such as Gtk+, Qt, or
> wxWidgets.
>
> --Benjamin Gilbert
> _______________________________________________
> openslide-users mailing list
> openslide-users at lists.andrew.cmu.edu
> https://lists.andrew.cmu.edu/mailman/listinfo/openslide-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.andrew.cmu.edu/pipermail/openslide-users/attachments/20180214/9e92e08d/attachment.html>


More information about the openslide-users mailing list