cornerstonejs / cornerstoneTools

A framework for tools built on top of Cornerstone.
https://tools.cornerstonejs.org/
MIT License
579 stars 456 forks source link

Scale Overlay Tool does not paint correctly when image is rotated on images with not square pixels #411

Open adellalibera opened 6 years ago

adellalibera commented 6 years ago

Prerequisites

Description

Scale Overlay Tool does not paint correctly when image is rotated on images with not square pixels.

Steps to Reproduce

  1. Display an image with PixelSpacing != 1\1 (e.g. 2\1) You can use attached revision of scaleOverlayTool example with http-server utility scaleOverlayTool2.zip
  2. Rotate image by ±90, ±270 degrees
  3. Scale bars are not drawn as expected

Expected behavior: Scale Overlay Tool paint routines shall take into account current viewport spatial transformations. On function onImageRendered(e) imageAttributes.verticalMinorTick and imageAttributed.horizontalMinorTick shall be calculated using context transformation matrix of viewport.

Actual behavior: [What actually happened] Scale Overlay Tool draw bars taking into account rowPixelSpacing, colPixelSpacing and scale of an untransformed image.

swederik commented 6 years ago

Thanks for the report! I just checked and you're definitely right, it doesn't do anything on rotate...

dannyrb commented 6 years ago

@swederik, do you have an example image you can provide? Is the issue here only that the scale does not update?

How should a tool like this function for turns that are not in 90 degree increments?

adellalibera commented 6 years ago

Example image is included with scaleOverlayTool2.zip in raw format into exampleImageLoader.js file. image108Base64 It doesn't show good because I modified only pixel-spacing without change pixel-data but is enough to show error.

Free angle rotation in not included, but it could be simple to add like (see imageTools/rotate.js)

dannyrb commented 6 years ago

This could be related to #579