changeset 289:5f783bf882fe

add warning about anisotropic pixel spacing
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 13 Jul 2023 12:49:50 +0200
parents a1efc5c39615
children 995dbab2e3dd
files Applications/Dicomizer.cpp ViewerPlugin/openseadragon.html
diffstat 2 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Dicomizer.cpp	Wed Jul 12 23:37:38 2023 +0200
+++ b/Applications/Dicomizer.cpp	Thu Jul 13 12:49:50 2023 +0200
@@ -644,9 +644,9 @@
   boost::program_options::options_description volumeOptions("Description of the imaged volume");
   volumeOptions.add_options()
     (OPTION_IMAGED_WIDTH, boost::program_options::value<float>(),
-     "Width of the specimen (in mm), defaults to 15mm if missing")
+     "Width of the specimen (in mm), in the coordinate system of the glass slide, defaults to 15mm if missing")
     (OPTION_IMAGED_HEIGHT, boost::program_options::value<float>(),
-     "Height of the specimen (in mm), defaults to 15mm if missing")
+     "Height of the specimen (in mm), in the coordinate system of the glass slide, defaults to 15mm if missing")
     (OPTION_IMAGED_DEPTH, boost::program_options::value<float>()->default_value(1),
      "Depth of the specimen (in mm)")
     (OPTION_OFFSET_X, boost::program_options::value<float>()->default_value(20), 
@@ -1127,6 +1127,16 @@
         throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
       }
 
+      // In the 2 lines below, remember to switch X/Y when going from physical to pixel coordinates!
+      float pixelSpacingX = volume.GetWidth() / static_cast<float>(source->GetLevelHeight(0));
+      float pixelSpacingY = volume.GetHeight() / static_cast<float>(source->GetLevelWidth(0));
+      if (std::abs(pixelSpacingX - pixelSpacingY) >= 100.0f * std::numeric_limits<float>::epsilon())
+      {
+        LOG(WARNING) << "Your pixel spacing is different along the X and Y axes, make sure that "
+                     << "you have not inversed the --" << OPTION_IMAGED_WIDTH << " and the --"
+                     << OPTION_IMAGED_HEIGHT << " options: " << pixelSpacingX << " vs. " << pixelSpacingY;
+      }
+
       LOG(WARNING) << "Compression of the individual source tiles: " << OrthancWSI::EnumerationToString(sourceCompression);
       
       // Create the shared DICOM tags
--- a/ViewerPlugin/openseadragon.html	Wed Jul 12 23:37:38 2023 +0200
+++ b/ViewerPlugin/openseadragon.html	Thu Jul 13 12:49:50 2023 +0200
@@ -21,7 +21,7 @@
       var params = new URL(document.location).searchParams;
       OpenSeadragon({
       id:                 'osd',
-      prefixUrl:          'https://unpkg.com/openseadragon@4.1.0/build/openseadragon/images/',
+      prefixUrl:          'https://unpkg.com/openseadragon@4.0.0/build/openseadragon/images/',
       preserveViewport:   true,
       visibilityRatio:    1,
       sequenceMode:       true,