0

I have larger sizes (more than 10GB) of microscope slides (ndpi, svs, tiff) images. To display that existing project member using the open layer 3 versions. While loading some images are converted into small multiple tiles(tileUrlFunction 40 API calls happening) and loading quickly, but the same type and size of images are not converted into small tiles(tileUrlFunction calling 1 time of the API images).

      var projection = new ol.proj.Projection({
      code: 'meters',
      units: 'm',
      getPointResolution: function (resolution) {
        return resolution * params.umperpixel[0];
      }
    });

    var extent = [params.left[0], -(params.totYpix[0] + params.bottom[0]), params.totXpix[0] + params.right[0], params.top[0]];

    var tilegrid = new ol.tilegrid.WMTS({
      matrixIds: resolutions,
      origins: origins,
      sizes: matrixSizes,
      tileSizes: sizes,
      resolutions: resolutions
    });

    var zoomTilegrid = new ol.tilegrid.WMTS({
      matrixIds: [resolutions[resolutions.length - 1]],
      origins: [origins[origins.length - 1]],
      sizes: [matrixSizes[matrixSizes.length - 1]],
      tileSizes: [sizes[sizes.length - 1]],
      resolutions: [resolutions[resolutions.length - 1]]
    });

    slide.source = new ol.source.TileImage({
      crossOrigin: 'anonymous',
      wrapX: false,
      projection: projection,
      tileGrid: tilegrid,
      tileUrlFunction: function (tileCoord) {
        return fetchTiles(slide, tileCoord, params);
      }
    });
    slide.zoomSource = new ol.source.TileImage({
      crossOrigin: 'anonymous',
      wrapX: false,
      projection: projection,
      tileGrid: zoomTilegrid,
      tileUrlFunction: function (tileCoord) {
        return fetchTiles(slide, tileCoord, params, true);
      }
    });
    function fetchTiles(slide, tileCoord, params, forZoom) {
      if (tileCoord !== null) {
        var res = angular.copy(slide.map.getView().getResolution());
        var key = params.resolutions.indexOf(res),
          x = tileCoord[1],
          y = -tileCoord[2] - 1,
          level = forZoom ?
            params[params.format[key] + 'level'].slice(-1) :
            params[params.format[key] + 'level'][key];
        return getTileUrl() + 'fetchimage.cgi?' + serializeData({
          'PATH': (params.prefix[key] === 'ndpi' ||
            params.prefix[key] === 'svs' ||
            params.prefix[key] === 'webslide') ?
            path :
            path + '.' + params.prefix[key],
          'SLIDEFORMAT': params.format[key],
          'X': x,
          'Y': y,
          'IMAGEFORMAT': params.type[key],
          'LEVEL': level
        });
      }

tileCoord array values which pass the combination of X and Y is below, for all fetchimage.cgi Level is 4,

1-1 (Level-4)
2-1
3-1
4-1
5-1
6-1
7-1
8-1
9-1
10-1
11-1
12-1
13-1

1-2 (Level-4)
2-2
3-2
4-2
5-2
6-2
8-2
7-2
9-2
10-2
11-2
12-2
13-2

1-3 (Level-4)
2-3
3-3
4-3
5-3
6-3
7-3
8-3
9-3
10-3
11-3
12-3
13-3

Ex. http://testdomain/fetchimage.cgi?PATH=fullfilename.ndpi&SLIDEFORMAT=ndpi&X=13&Y=1&IMAGEFORMAT=jpg&LEVEL=4

Am not sure how to consider all the slide images as small tiles.

R.G.Krish
  • 487
  • 5
  • 22
  • you have defined `zoomTilegrid` with only one resolution - the one which needs the greatest number of tiles – Mike Jul 26 '23 at 08:51
  • @Mike Problem is some of the slides are considering and its converting as multiple tiles under tileUrlFunction. – R.G.Krish Jul 26 '23 at 09:33
  • @Mike, resolutions is an array and it contains [16,4,1]. For tilegrid, it comes full array value, and zoomTilegrid it coming 4. – R.G.Krish Jul 26 '23 at 09:50
  • `resolutions: [resolutions[resolutions.length - 1]]` will give you `[1]` not `[4]` – Mike Jul 26 '23 at 11:04
  • It's 1. Just now confirmed mike – R.G.Krish Jul 26 '23 at 11:17
  • @Mike, For tileUrlFunction params tile coordinate, is coming only 0,0. That's why it's calling one time I guess, Bcoz I have 2 slides, slide 1 tile coordinate value is for X=0 and Y=0, But slide 2 tile coordinate is 1-1..13-1, 1-2...13-2, 1-3...13-3 totally 41 tile API calls happening. The 2nd slide getting converted as a small tile and merging and loading quickly – R.G.Krish Jul 26 '23 at 11:26
  • If zoom level 0 in the main grid has one tile zoom level 2 would have 256, and the single zoom level 0 in the other grid would also have 256. Your `fetchTiles` function would need to handle the grids being different. – Mike Jul 26 '23 at 11:40
  • @Mike, I have added fetchTiles functionalities and the value passing through tileCoord from tileUrlFunction – R.G.Krish Jul 26 '23 at 14:52
  • @Mike Any idea? – R.G.Krish Jul 28 '23 at 08:42

0 Answers0