HeshamAI commited on
Commit
2f676a0
·
verified ·
1 Parent(s): 09b3669

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -31,9 +31,6 @@ class DicomAnalyzer:
31
  rescale_intercept = getattr(dicom_data, 'RescaleIntercept', 0)
32
  image = (image * rescale_slope) + rescale_intercept
33
 
34
- # Store original image for analysis
35
- original_image = image.copy()
36
-
37
  # Normalize for display
38
  image_display = cv2.normalize(image, None, 0, 255, cv2.NORM_MINMAX).astype(np.uint8)
39
 
@@ -41,7 +38,7 @@ class DicomAnalyzer:
41
  if len(image_display.shape) == 2:
42
  image_display = cv2.cvtColor(image_display, cv2.COLOR_GRAY2BGR)
43
 
44
- return original_image, image_display, dicom_data
45
  except Exception as e:
46
  print(f"Error loading DICOM file: {str(e)}")
47
  return None, None, None
@@ -190,10 +187,9 @@ class DicomAnalyzer:
190
  def update_zoom(self, zoom_factor):
191
  self.zoom_factor = zoom_factor
192
  if self.current_image1 is not None:
193
- height, width = self.current_image1.shape
194
  resized = cv2.resize(self.image_display1, None, fx=self.zoom_factor, fy=self.zoom_factor, interpolation=cv2.INTER_LINEAR)
195
- self.offset_x = (resized.shape[1] - width * self.zoom_factor) // 2
196
- self.offset_y = (resized.shape[0] - height * self.zoom_factor) // 2
197
  return resized
198
  return self.image_display1
199
 
 
31
  rescale_intercept = getattr(dicom_data, 'RescaleIntercept', 0)
32
  image = (image * rescale_slope) + rescale_intercept
33
 
 
 
 
34
  # Normalize for display
35
  image_display = cv2.normalize(image, None, 0, 255, cv2.NORM_MINMAX).astype(np.uint8)
36
 
 
38
  if len(image_display.shape) == 2:
39
  image_display = cv2.cvtColor(image_display, cv2.COLOR_GRAY2BGR)
40
 
41
+ return image, image_display, dicom_data
42
  except Exception as e:
43
  print(f"Error loading DICOM file: {str(e)}")
44
  return None, None, None
 
187
  def update_zoom(self, zoom_factor):
188
  self.zoom_factor = zoom_factor
189
  if self.current_image1 is not None:
 
190
  resized = cv2.resize(self.image_display1, None, fx=self.zoom_factor, fy=self.zoom_factor, interpolation=cv2.INTER_LINEAR)
191
+ self.offset_x = (resized.shape[1] - self.image_display1.shape[1]) // 2
192
+ self.offset_y = (resized.shape[0] - self.image_display1.shape[0]) // 2
193
  return resized
194
  return self.image_display1
195