wangjin2000 commited on
Commit
97e57b1
·
verified ·
1 Parent(s): 875a842

Update app.py

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