Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce "frame-of-reference" #123

Merged

Conversation

ptahmose
Copy link
Contributor

@ptahmose ptahmose commented Dec 9, 2024

Description

Introduce concept of "different frames-of-reference" to ISubBlockRepository and accessors. The idea is that the coordinates used with the accessors can be given in different coordinate systems. In addition, the concept of a "default coordinate system" (see with the reader-/readerwriter-object) is introduced.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • locally
  • unit-tests are provided

Checklist:

  • I followed the Contributing Guidelines.
  • I did a self-review.
  • I commented my code, particularly in hard-to-understand areas.
  • I updated the documentation.
  • I updated the version of libCZI following Versioning of libCZI depending on the type of change
    • Bug fix -> PATCH
    • New feature -> MINOR
    • Breaking change -> MAJOR
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

ptahmose and others added 12 commits December 4, 2024 01:57
Added a new documentation file `coordinate_systems.markdown` to the
Doxyfile's INPUT section. Introduced a "Coordinate Systems" section
in the new file with a header and placeholder description for CZI and
libCZI coordinate systems. Also, added a new diagram in
`coordinate_systems.drawio` named "Page-1" that includes graphical
elements representing a coordinate system with labeled axes.
Rephrased a sentence in `coordinate_systems.markdown` for clarity. Updated comments in `libCZI.h` to clarify bounding boxes and coordinate systems. Enhanced `libCZI_Compositor.h` comments to specify ROI and positions in the 'raw-subblock-coordinate-system'. Removed summary tags and redundant information to streamline documentation. These changes provide clearer and more precise descriptions of coordinate systems and bounding boxes in libCZI.
Updated CMakeLists.txt to change project version from 0.62.6 to 0.62.7.
Added a new entry in version-history.markdown for version 0.62.7, documenting a "documentation update" linked to pull request ZEISS#122.
Updated SubBlockStatistics and libCZI_Compositor.h for consistent documentation. Modified CSingleChannelTileAccessor::Get to use IntRectAndFrameOfReference. Added ConvertToFrameOfReference method in Utils. Improved comments and formatting in libCZI_Utilities.cpp. Updated SingleChannelTileAccessorHandler to use interface pointer.
Added TransformPoint to CCZIReader for point transformations.
Updated CZIReader.h to declare TransformPoint method.
Modified CSingleChannelTileAccessor::Get to use TransformRectangle.
Added TransformRectangle to ISubBlockRepository in libCZI.h.
Introduced IntPoint and IntPointAndFrameOfReference structures.
Removed ConvertToFrameOfReference function from libCZI_Utilities.
Minor formatting changes in libCZI.h and libCZI_Utilities.h.
Improved code design, readability, and maintainability.
Updated TransformPoint method to return libCZI::IntPointAndFrameOfReference instead of libCZI::IntPoint. This change is reflected across various classes and interfaces, including CCZIReader, CziReaderWriter, and libCZI::ISubBlockRepository.

Added a new member variable default_frame_of_reference to CCZIReader and libCZI::Options to handle cases where the frame of reference is set to Default. Updated TransformRectangle method to handle the new return type of TransformPoint. Implemented changes in test_TileAccessorCoverageOptimization.cpp to reflect the new return type.
Copy link

codecov bot commented Dec 9, 2024

Codecov Report

Attention: Patch coverage is 70.90909% with 32 lines in your changes missing coverage. Please review.

Project coverage is 65.87%. Comparing base (ae43e1b) to head (826e36c).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
Src/libCZI/CziReaderWriter.cpp 48.64% 19 Missing ⚠️
...c/libCZI/SingleChannelPyramidLevelTileAccessor.cpp 50.00% 3 Missing ⚠️
Src/libCZI/SingleChannelScalingTileAccessor.cpp 50.00% 3 Missing ⚠️
Src/libCZI/CZIReader.cpp 92.85% 2 Missing ⚠️
Src/libCZI/SingleChannelTileAccessor.cpp 60.00% 2 Missing ⚠️
Src/libCZI/libCZI_Utilities.cpp 0.00% 2 Missing ⚠️
Src/libCZI/libCZI_ReadWrite.h 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #123      +/-   ##
==========================================
+ Coverage   65.49%   65.87%   +0.38%     
==========================================
  Files          86       86              
  Lines       10906    10990      +84     
==========================================
+ Hits         7143     7240      +97     
+ Misses       3763     3750      -13     
Flag Coverage Δ
windows-latest 65.87% <70.90%> (+0.38%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

- Initialize `default_frame_of_reference` to `CZIFrameOfReference::Invalid` in `CCZIReader` constructor.
- Update `CCZIReader::Open` to use a switch statement for `options->default_frame_of_reference`.
- Modify `ISubBlockRepository::TransformRectangle` to return `IntRectAndFrameOfReference`.
- Update `CSingleChannelTileAccessor::Get` to use the `rectangle` member of `IntRectAndFrameOfReference`.
- Add `test_frame_of_reference_transform.cpp` with tests for point and rectangle transformations.
- Include new test file in `libCZI_UnitTests` target in `CMakeLists.txt`.
@ptahmose ptahmose added the cla Contributor License Agreement sent to Admin label Dec 9, 2024
Refactored `CCZIReader::TransformPoint` for robust frame-of-reference transformations. Updated `AccessorType` enum in `libCZI_Compositor.h` to use `std::uint8_t`. Corrected typo in `backGroundColor` comment. Added `Check2x2Gray8Bitmap` function and new tests in `test_frame_of_reference_transform.cpp` for point transformations and tile composite verification.
Implemented TransformPoint in CCziReaderWriter for frame-of-reference transformations. Added GetDefaultFrameOfReference method and updated ICziReaderWriterInfo interface. Fixed formatting issues and improved type safety. Added test case for TransformPoint. Updated documentation and constructor initialization. Handled unsupported transformations with exceptions.
Updated the comment to reflect the correct bounding-box (0, -1, 1, 1) and transformation result (0, -1) after removing subblocks. Adjusted the test assertion for the y-coordinate of the transformed point to expect -1 instead of 0.
Modified the constructor in SingleChannelTileAccessor.cpp to make
roi_raw_sub_block_cs a const IntRect, ensuring immutability.
Removed a commented-out Get method declaration in
SingleChannelTileAccessor.h for improved readability.
Updated method signatures in SingleChannelTileAccessor.cpp and .h to use IntPointAndFrameOfReference instead of separate xPos and yPos parameters. Adjusted libCZI_Compositor.h to reflect these changes and added inline methods for backward compatibility. Updated ISingleChannelTileAccessor destructor to use override keyword for modern C++ standards adherence.
Added a space after the period in the comment describing the Z-order behavior when `sortByM` is false. This change enhances readability and consistency of the comments in the codebase.
- Updated `Get` methods in `CSingleChannelScalingTileAccessor` and `libCZI::ISingleChannelScalingTileAccessor` to use `IntRectAndFrameOfReference` instead of `IntRect`.
- Added overloads to handle `IntRect` by converting to `IntRectAndFrameOfReference`.
- Modified `InternalCalcSize` to use the transformed rectangle in the raw sub-block coordinate system.
- Corrected typo in `Options` struct documentation ("back ground color" to "background color").
- Updated `SingleChannelScalingTileAccessorHandler` in `test_TileAccessorCoverageOptimization.cpp` to use a shared pointer to `ISingleChannelScalingTileAccessor`.
- Added documentation to `libCZI::ISingleChannelScalingTileAccessor` interface for new `Get` methods and their parameters.
Updated SingleChannelPyramidLevelTileAccessor to use IntRectAndFrameOfReference and IntPointAndFrameOfReference for coordinates, ensuring explicit frame of reference handling. Transformed input coordinates to RawSubBlockCoordinateSystem in Get methods for consistency. Updated InternalGet method accordingly. Modified libCZI_Compositor.h to reflect new method signatures and retained old methods with internal transformations. Improved clarity and correctness of coordinate handling.
Updated ROI calculation to use boundingBoxLayer0Only instead of boundingBox for relative coordinates in execute.cpp and executeBase.cpp. Applied consistent changes across multiple sections. Added spaces after commas in ROI initialization for better readability.
Updated CMakeLists.txt to change project version from 0.62.7 to 0.63.0.
Added a new entry in version-history.markdown for version 0.63.0, documenting the introduction of "frames-of-reference". The entry for version 0.62.7 remains unchanged.
@ptahmose ptahmose requested a review from a team December 11, 2024 06:55
@ptahmose ptahmose marked this pull request as ready for review December 11, 2024 06:55
m-aXimilian
m-aXimilian previously approved these changes Dec 12, 2024
Copy link
Contributor

@m-aXimilian m-aXimilian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All my "findings" are nitpicky. Feel free to ignore them.
Looks good to me!

Src/CZICmd/execute.cpp Outdated Show resolved Hide resolved
Src/libCZI/CZIReader.cpp Show resolved Hide resolved
Src/libCZI/libCZI_Pixels.h Show resolved Hide resolved
Src/libCZI/CZIReader.cpp Outdated Show resolved Hide resolved
Src/libCZI/libCZI_Compositor.h Show resolved Hide resolved
Src/libCZI/libCZI_ReadWrite.h Outdated Show resolved Hide resolved
m-aXimilian
m-aXimilian previously approved these changes Dec 12, 2024
Src/libCZI/CZIReader.cpp Outdated Show resolved Hide resolved
Src/libCZI/CZIReader.cpp Outdated Show resolved Hide resolved
Simplified the return statements in two conditional blocks by removing the explicit type `libCZI::IntPointAndFrameOfReference` and using the brace-enclosed initializer list directly. This change makes the code more concise and leverages the compiler's ability to deduce the return type.
@ptahmose ptahmose merged commit 1127eb0 into ZEISS:main Dec 13, 2024
15 checks passed
@ptahmose ptahmose deleted the jbl/improve_czi-pixel-coordinate-system-usage branch December 16, 2024 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla Contributor License Agreement sent to Admin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants