HeshamAI commited on
Commit
457e977
·
verified ·
1 Parent(s): dfaadc5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -71,6 +71,8 @@ class DicomAnalyzer:
71
  )
72
  if len(normalized.shape) == 2:
73
  normalized = cv2.cvtColor(normalized, cv2.COLOR_GRAY2RGB)
 
 
74
  return normalized
75
  except Exception as e:
76
  print(f"Error normalizing image: {str(e)}")
@@ -176,6 +178,9 @@ class DicomAnalyzer:
176
  zoomed = cv2.resize(self.original_display, (new_width, new_height),
177
  interpolation=cv2.INTER_CUBIC)
178
 
 
 
 
179
  # Draw marks with ImageJ-like yellow circle
180
  for x, y, diameter in self.marks:
181
  # Calculate zoomed coordinates correctly
@@ -184,10 +189,10 @@ class DicomAnalyzer:
184
  zoomed_diameter = int(diameter * self.zoom_factor)
185
 
186
  # Draw main circle - Pure yellow
187
- cv2.circle(zoomed,
188
  (zoomed_x, zoomed_y),
189
  zoomed_diameter // 2,
190
- (0, 255, 255), # BGR: Pure yellow
191
  1, # Thin line
192
  lineType=cv2.LINE_AA)
193
 
@@ -197,13 +202,16 @@ class DicomAnalyzer:
197
  angle = 2 * np.pi * i / num_points
198
  point_x = int(zoomed_x + (zoomed_diameter/2) * np.cos(angle))
199
  point_y = int(zoomed_y + (zoomed_diameter/2) * np.sin(angle))
200
- cv2.circle(zoomed,
201
  (point_x, point_y),
202
  1,
203
- (0, 255, 255), # BGR: Pure yellow
204
  -1,
205
  lineType=cv2.LINE_AA)
206
 
 
 
 
207
  # Extract visible portion considering pan
208
  visible_height = min(height, new_height)
209
  visible_width = min(width, new_width)
 
71
  )
72
  if len(normalized.shape) == 2:
73
  normalized = cv2.cvtColor(normalized, cv2.COLOR_GRAY2RGB)
74
+ else:
75
+ normalized = cv2.cvtColor(normalized, cv2.COLOR_BGR2RGB)
76
  return normalized
77
  except Exception as e:
78
  print(f"Error normalizing image: {str(e)}")
 
178
  zoomed = cv2.resize(self.original_display, (new_width, new_height),
179
  interpolation=cv2.INTER_CUBIC)
180
 
181
+ # Convert to BGR for drawing
182
+ zoomed_bgr = cv2.cvtColor(zoomed, cv2.COLOR_RGB2BGR)
183
+
184
  # Draw marks with ImageJ-like yellow circle
185
  for x, y, diameter in self.marks:
186
  # Calculate zoomed coordinates correctly
 
189
  zoomed_diameter = int(diameter * self.zoom_factor)
190
 
191
  # Draw main circle - Pure yellow
192
+ cv2.circle(zoomed_bgr,
193
  (zoomed_x, zoomed_y),
194
  zoomed_diameter // 2,
195
+ (255, 255, 0), # BGR: Pure yellow
196
  1, # Thin line
197
  lineType=cv2.LINE_AA)
198
 
 
202
  angle = 2 * np.pi * i / num_points
203
  point_x = int(zoomed_x + (zoomed_diameter/2) * np.cos(angle))
204
  point_y = int(zoomed_y + (zoomed_diameter/2) * np.sin(angle))
205
+ cv2.circle(zoomed_bgr,
206
  (point_x, point_y),
207
  1,
208
+ (255, 255, 0), # BGR: Pure yellow
209
  -1,
210
  lineType=cv2.LINE_AA)
211
 
212
+ # Convert back to RGB for display
213
+ zoomed = cv2.cvtColor(zoomed_bgr, cv2.COLOR_BGR2RGB)
214
+
215
  # Extract visible portion considering pan
216
  visible_height = min(height, new_height)
217
  visible_width = min(width, new_width)