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

The segmentation results are not satisfactory. #400

Open
Li-999-qw opened this issue Dec 10, 2024 · 1 comment
Open

The segmentation results are not satisfactory. #400

Li-999-qw opened this issue Dec 10, 2024 · 1 comment

Comments

@Li-999-qw
Copy link

Hello, I am using NIFTI format CT data for segmentation, but the segmentation results don't seem to be satisfactory. The data was converted from JPG format images using 3D Slicer. I am not sure if this is the reason for the poor segmentation results. Could you please provide some guidance?
1733807905189

@ignaciobartol
Copy link

Hello @Li-999-qw, if your original data was in the format of JPG files definetely there could be some problems. Something very important when applying these models is the dynamic range of the images, in this case the author of this repo asks for the images to be in their original dynamic range in HU values (roughly air in the lungs should be -900 HU).

See issue #334 for the original comment.

If you want to recover those values from the JPEG images you can try to do so, but usually JPEG images have a depth of 8bit in B&W format (meaning you can only represent 256 numbers) and NiFTI/DICOM images dynamic range can have between 4,096 and 65,536 shades of gray (i.e. values that can be represented in each pixel). So definetely you will loose some information in the process.

To convert to NifTi from JPEG one option could be:

import numpy as np
import cv2
import nibabel as nib

# Replace image.jpeg with the name of your file and rescale to 16-bit range
jpeg_img = cv2.imread('image.jpeg', cv2.IMREAD_GRAYSCALE)

rescaled_img = (jpeg_img / 255.0 * 65535).astype(np.uint16)

# Save as NIfTI assuming the orientation is right
nifti_img = nib.Nifti1Image(rescaled_img, affine=np.eye(4))
nib.save(nifti_img, 'output.nii')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants