Mercurial > hg > orthanc-wsi
changeset 408:bdc8449b00cb
BREAKING: swapping ImagedVolumeWidth and ImagedVolumeHeight
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Wed, 05 Nov 2025 19:03:33 +0100 |
| parents | 5cc4b10fa1d8 |
| children | f4483be2364e |
| files | Applications/Dicomizer.cpp Framework/ImagedVolumeParameters.cpp Framework/Inputs/DicomPyramidInstance.cpp Framework/Inputs/HierarchicalTiff.cpp Framework/Inputs/OpenSlidePyramid.cpp Framework/Outputs/DicomPyramidWriter.cpp NEWS ViewerPlugin/viewer.js |
| diffstat | 8 files changed, 33 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/Applications/Dicomizer.cpp Wed Nov 05 16:17:21 2025 +0100 +++ b/Applications/Dicomizer.cpp Wed Nov 05 19:03:33 2025 +0100 @@ -1359,12 +1359,11 @@ volume.SetWidth(15); } - // In the lines below, remember to switch X/Y when going from physical to pixel coordinates! if (volume.HasWidth() && volume.HasHeight()) { - float pixelSpacingX = volume.GetWidth() / static_cast<float>(source->GetLevelHeight(0)); - float pixelSpacingY = volume.GetHeight() / static_cast<float>(source->GetLevelWidth(0)); + const float pixelSpacingX = volume.GetWidth() / static_cast<float>(source->GetLevelWidth(0)); + const float pixelSpacingY = volume.GetHeight() / static_cast<float>(source->GetLevelHeight(0)); if (!OrthancWSI::ImageToolbox::IsNear(pixelSpacingX, pixelSpacingY)) { LOG(WARNING) << "Your pixel spacing is different along the X and Y axes (" @@ -1375,14 +1374,14 @@ else if (volume.HasWidth()) { assert(!volume.HasHeight()); - volume.SetHeight(volume.GetWidth() / static_cast<float>(source->GetLevelHeight(0)) * - static_cast<float>(source->GetLevelWidth(0))); + volume.SetHeight(volume.GetWidth() / static_cast<float>(source->GetLevelWidth(0)) * + static_cast<float>(source->GetLevelHeight(0))); } else if (volume.HasHeight()) { assert(!volume.HasWidth()); - volume.SetWidth(volume.GetHeight() / static_cast<float>(source->GetLevelWidth(0)) * - static_cast<float>(source->GetLevelHeight(0))); + volume.SetWidth(volume.GetHeight() / static_cast<float>(source->GetLevelHeight(0)) * + static_cast<float>(source->GetLevelWidth(0))); } else {
--- a/Framework/ImagedVolumeParameters.cpp Wed Nov 05 16:17:21 2025 +0100 +++ b/Framework/ImagedVolumeParameters.cpp Wed Nov 05 19:03:33 2025 +0100 @@ -126,8 +126,11 @@ throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } - // WARNING: The physical X/Y axes are switched wrt. the image X/Y - physicalX = offsetX_ - GetHeight() * static_cast<float>(imageX) / static_cast<float>(totalWidth); - physicalY = offsetY_ - GetWidth() * static_cast<float>(imageY) / static_cast<float>(totalHeight); + /** + * WARNING: The physical X/Y axes are switched wrt. the image X/Y + * (cf. GetImageOrientationSlide()). + **/ + physicalX = offsetX_ - GetHeight() * static_cast<float>(imageY) / static_cast<float>(totalHeight); + physicalY = offsetY_ - GetWidth() * static_cast<float>(imageX) / static_cast<float>(totalWidth); } }
--- a/Framework/Inputs/DicomPyramidInstance.cpp Wed Nov 05 16:17:21 2025 +0100 +++ b/Framework/Inputs/DicomPyramidInstance.cpp Wed Nov 05 19:03:33 2025 +0100 @@ -301,6 +301,11 @@ hasImagedVolumeSize_ = ( reader.GetDoubleValue(imagedVolumeWidth_, Orthanc::DicomPath(DICOM_TAG_IMAGED_VOLUME_WIDTH)) && reader.GetDoubleValue(imagedVolumeHeight_, Orthanc::DicomPath(DICOM_TAG_IMAGED_VOLUME_HEIGHT))); + + if (hasImagedVolumeSize_) + { + // TODO - SWAP WIDTH/HEIGHT FOR OLD VERSIONS OF ORTHANC + } }
--- a/Framework/Inputs/HierarchicalTiff.cpp Wed Nov 05 16:17:21 2025 +0100 +++ b/Framework/Inputs/HierarchicalTiff.cpp Wed Nov 05 19:03:33 2025 +0100 @@ -306,9 +306,8 @@ if (key == MPP && Orthanc::SerializationToolbox::ParseDouble(mpp, value)) { - // In the lines below, remember to switch X/Y when going from physical to pixel coordinates! - double thisHeight = static_cast<double>(levels_[i].width_) * mpp / 1000.0; - double thisWidth = static_cast<double>(levels_[i].height_) * mpp / 1000.0; + double thisWidth = static_cast<double>(levels_[i].width_) * mpp / 1000.0; + double thisHeight = static_cast<double>(levels_[i].height_) * mpp / 1000.0; if (!found) {
--- a/Framework/Inputs/OpenSlidePyramid.cpp Wed Nov 05 16:17:21 2025 +0100 +++ b/Framework/Inputs/OpenSlidePyramid.cpp Wed Nov 05 19:03:33 2025 +0100 @@ -150,9 +150,8 @@ image_.LookupProperty(s, "openslide.mpp-y") && Orthanc::SerializationToolbox::ParseDouble(mppy, s)) { - // In the 2 lines below, remember to switch X/Y when going from physical to pixel coordinates! - width = mppy / 1000.0 * static_cast<double>(image_.GetLevelHeight(0)); - height = mppx / 1000.0 * static_cast<double>(image_.GetLevelWidth(0)); + width = mppx / 1000.0 * static_cast<double>(image_.GetLevelWidth(0)); + height = mppy / 1000.0 * static_cast<double>(image_.GetLevelHeight(0)); return true; } else
--- a/Framework/Outputs/DicomPyramidWriter.cpp Wed Nov 05 16:17:21 2025 +0100 +++ b/Framework/Outputs/DicomPyramidWriter.cpp Wed Nov 05 19:03:33 2025 +0100 @@ -151,9 +151,8 @@ // Fix issue 139: The PixelSpacing information changes at each level // https://bitbucket.org/sjodogne/orthanc/issues/139/orthancwsidicomizer-pixelspacing - // In the 2 lines below, remember to switch X/Y when going from physical to pixel coordinates! - float spacingX = volume_.GetWidth() / static_cast<float>(level.height_); - float spacingY = volume_.GetHeight() / static_cast<float>(level.width_); + float spacingX = volume_.GetWidth() / static_cast<float>(level.width_); + float spacingY = volume_.GetHeight() / static_cast<float>(level.height_); std::string spacing = (boost::lexical_cast<std::string>(spacingX) + '\\' + boost::lexical_cast<std::string>(spacingY));
--- a/NEWS Wed Nov 05 16:17:21 2025 +0100 +++ b/NEWS Wed Nov 05 19:03:33 2025 +0100 @@ -4,6 +4,9 @@ * OrthancWSIDicomizer: - Placeholder tags are now automatically inserted when the "--dataset" option provides incomplete data, ensuring the generated DICOM instances remain valid + - The version of the DICOM-izer is available in DICOM tag "SoftwareVersions" + - ImagedVolumeWidth and ImagedVolumeHeight are swapped with respect to releases <= 3.2: + https://discourse.orthanc-server.org/t/5912 * Viewer plugin: - Added rotation button in the viewer - The viewer displays a label if the "description" GET parameter is provided
--- a/ViewerPlugin/viewer.js Wed Nov 05 16:17:21 2025 +0100 +++ b/ViewerPlugin/viewer.js Wed Nov 05 19:03:33 2025 +0100 @@ -34,8 +34,13 @@ var imagedVolumeHeight = pyramid['ImagedVolumeHeight']; if (imagedVolumeWidth !== undefined && imagedVolumeHeight !== undefined) { - metersPerUnit = parseFloat(imagedVolumeWidth) / (1000.0 * parseFloat(height)); - //metersPerUnit = parseFloat(imagedVolumeHeight) / (1000.0 * parseFloat(width)); + var metersPerUnitX = parseFloat(imagedVolumeWidth) / (1000.0 * parseFloat(width)); + var metersPerUnitY = parseFloat(imagedVolumeHeight) / (1000.0 * parseFloat(height)); + if (Math.abs(metersPerUnitX - metersPerUnitY) <= 0.000000001) { + metersPerUnit = metersPerUnitX; + } else { + console.error('Inconsistency in the imaged volume size, not showing the scale'); + } } // Maps always need a projection, but Zoomify layers are not geo-referenced, and
