cornerstonejs / cornerstone

JavaScript library to display interactive medical images including but not limited to DICOM
https://docs.cornerstonejs.org/
MIT License
2.04k stars 598 forks source link

Feature request: Add width scale and height scale attributes in viewport response #534

Open deerawan opened 3 years ago

deerawan commented 3 years ago

Problem

Currently for getViewport method, we only return scale field.

cornerstone.getViewport(element);

Response

{
  "scale": 0.5,
  "translation": { "x": 0, "y": 0 },
  "voi": { "windowWidth": 256, "windowCenter": 127 },
  "pixelReplication": false,
  "rotation": 0,
  "hflip": false,
  "vflip": false,
  "labelmap": false,
  "displayedArea": {
    "tlhc": { "x": 1, "y": 1 },
    "brhc": { "x": 512, "y": 44 },
    "rowPixelSpacing": 2.887,
    "columnPixelSpacing": 0.488281,
    "presentationSizeMode": "NONE"
  }
}

We can't really rely on scale value for non-square image scenario since we could split the value into widthScale and heightScale with different value (reference), it might be a good idea to return them as well in the response.

Solution

Option 1

Add widthScale and heightScale in the response. Or maybe put them inside displayedArea field.

{
  "scale": 0.5,
  "widthScale": 0.5,
  "heightScale": 0.5,
   ....
  }
}

Option 2 (break changes)

Remove scale and add widthScale and heightScale in the response.

{
  "widthScale": 0.5,
  "heightScale": 0.5,
  ...
}