wangjin2000 commited on
Commit
9feb793
·
verified ·
1 Parent(s): 8a0a2dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -166,18 +166,15 @@ def read_and_preprocess_dicom(file_path: str):
166
  pixel_array = ((pixel_array - np.min(pixel_array)) / (np.max(pixel_array) - np.min(pixel_array)) * 255).astype(
167
  np.uint8)
168
  image_pil = Image.fromarray(pixel_array)
 
 
169
 
170
- # asarray() class is used to convert
171
- # PIL images into NumPy arrays
172
- numpydata = np.asarray(image_pil)
173
- #convert to cv2 format
174
- numpydata = numpydata.reshape((numpydata.shape[0], numpydata.shape[1], 3))
175
- print("In preprocess dicom:", numpydata.shape)
176
  #image = np.array(numpydata)[::-1].copy()
177
  image = np.array(numpydata)[:,:,::-1].copy()
178
 
179
  # shape
180
- print("In preprocess dicom-image.shape:",image.shape)
181
 
182
  # Collect metadata in dictionary format and convert to DataFrame
183
  metadata_dict = {elem.name: str(elem.value) for elem in dicom_data.iterall() if elem.name != 'Pixel Data'}
 
166
  pixel_array = ((pixel_array - np.min(pixel_array)) / (np.max(pixel_array) - np.min(pixel_array)) * 255).astype(
167
  np.uint8)
168
  image_pil = Image.fromarray(pixel_array)
169
+
170
+ image = image_pil.convert('RGB')
171
 
172
+ print("In preprocess dicom:", image.shape)
 
 
 
 
 
173
  #image = np.array(numpydata)[::-1].copy()
174
  image = np.array(numpydata)[:,:,::-1].copy()
175
 
176
  # shape
177
+ print("In preprocess dicom-image.shape2:",image.shape)
178
 
179
  # Collect metadata in dictionary format and convert to DataFrame
180
  metadata_dict = {elem.name: str(elem.value) for elem in dicom_data.iterall() if elem.name != 'Pixel Data'}