-
Notifications
You must be signed in to change notification settings - Fork 289
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
fix(color): Fix RGB inconsistencies #829
Merged
sedghi
merged 12 commits into
cornerstonejs:main
from
RadicalImaging:fix/RGBinconsistencies
May 28, 2024
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0084489
Fix RGB inconsistencies
rodrigobasilio2022 0409f4a
Add color space conversion check
rodrigobasilio2022 d4739ff
Merge branch 'main' of https://github.com/rodrigobasilio2022/cornerst…
rodrigobasilio2022 7810290
refactor(comments) : refactor comments in code
rodrigobasilio2022 02b2117
refactor(code): change requirements YBR_FULL_422
rodrigobasilio2022 b6c8838
Merge branch 'main' of https://github.com/rodrigobasilio2022/cornerst…
rodrigobasilio2022 f133ace
fix(color): fix bug in color example
rodrigobasilio2022 c252514
fix bug in image loader example
rodrigobasilio2022 274c609
Refactoring function
rodrigobasilio2022 30304fb
Merge branch 'main' of github.com:cornerstonejs/cornerstone3D into pr…
sedghi a60d973
fix: correct typo in color space conversion function
sedghi bf9a8c2
refactor: Refactor color space conversion functions
sedghi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/dicomImageLoader/src/imageLoader/isColorConversionRequired.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* This function checks color space conversion data requirements before | ||
* applying them. This function was created to solve problems like the one | ||
* discussed in here https://discourse.orthanc-server.org/t/orthanc-convert-ybr-to-rgb-but-does-not-change-metadata/3533/17 | ||
* In this case, Orthanc server converts the pixel data from YBR to RGB, but maintain | ||
* the photometricInterpretation dicom tag in YBR | ||
* @param imageFrame | ||
* @param RGBA | ||
* @returns | ||
*/ | ||
export default function isColorConversionRequired(imageFrame, RGBA) { | ||
if (imageFrame === undefined) { | ||
return false; | ||
} | ||
const { rows, columns, photometricInterpretation, pixelDataLength } = | ||
imageFrame; | ||
|
||
if (photometricInterpretation.endsWith('420')) { | ||
return ( | ||
pixelDataLength !== | ||
(3 * Math.ceil(columns / 2) + Math.floor(columns / 2)) * rows | ||
); | ||
} else if (photometricInterpretation.endsWith('422')) { | ||
return ( | ||
pixelDataLength !== | ||
(3 * Math.ceil(columns / 2) + Math.floor(columns / 2)) * | ||
Math.ceil(rows / 2) + | ||
Math.floor(rows / 2) * columns | ||
); | ||
} else { | ||
return photometricInterpretation !== 'RGB'; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment here that the length is divisible by 2 because for 4 pixels (a 2x2 array), there are 4 y and 2 b and 2 r values, so 4+2+2 / 4 = 2 bytes per pixel