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

Rescale dicom image incorrectly when intensity can be negative #1227

Closed
jenny-hm-lee opened this issue Dec 7, 2023 · 3 comments
Closed

Rescale dicom image incorrectly when intensity can be negative #1227

jenny-hm-lee opened this issue Dec 7, 2023 · 3 comments
Labels
bug Something isn't working dicom image-anonymization

Comments

@jenny-hm-lee
Copy link
Contributor

Describe the bug
When redactoring an dicom image in dicom_image_radactor_engine.py, the image intensity are rescaled using the function _rescale_dcm_pixel_array(). This function rescales the gray scale to be 0 to 255; however the rescale formula (below) assumes the smallest intensity value of the image array is 0, which is not usually not the case for medical CT images. CT image have negative intensity value.

image_2d_scaled = ( np.maximum(image_2d_float, 0) / image_2d_float.max() ) * 255.0

Instead, a more robust formula would be

image_2d_scaled = ( (image_2d_float.max() - image_2d_float) / (image_2d_float.max() - image_2d_float.min()) ) * 255.0

As a consequence of this bug, the scaled image filtered out some text which were in negative intensity, and the text were not detected downstream.

@omri374
Copy link
Contributor

omri374 commented Dec 8, 2023

Thank you, would you be interested in creating a pull request?

@omri374 omri374 added bug Something isn't working image-anonymization dicom labels Dec 8, 2023
@jenny-hm-lee
Copy link
Contributor Author

Yes. What do I need for a successful PR?

@omri374
Copy link
Contributor

omri374 commented Dec 10, 2023

This covers our contribution guidelines: https://github.com/microsoft/presidio/blob/main/CONTRIBUTING.md

jenny-hm-lee added a commit to jenny-hm-lee/presidio that referenced this issue Dec 14, 2023
@jenny-hm-lee jenny-hm-lee mentioned this issue Dec 14, 2023
5 tasks
omri374 pushed a commit that referenced this issue Dec 26, 2023
@omri374 omri374 closed this as completed Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dicom image-anonymization
Projects
None yet
Development

No branches or pull requests

2 participants