HeshamAI commited on
Commit
95bfe52
·
verified ·
1 Parent(s): cb43e84

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -42
app.py CHANGED
@@ -81,52 +81,47 @@ class DicomAnalyzer:
81
  print(f"Error analyzing point: {str(e)}")
82
  return None
83
 
84
- def draw_circle(self, image, x, y, is_image1=True):
85
- try:
86
- image_copy = image.copy()
87
-
88
- # Draw all previous marks
89
- marks = self.marks1 if is_image1 else self.marks2
90
- for mark_x, mark_y in marks:
91
- cv2.circle(image_copy,
92
- (int(mark_x), int(mark_y)),
93
- int(self.circle_diameter/2),
94
- (0, 255, 255),
95
- 1,
96
- lineType=cv2.LINE_AA)
97
-
98
- # Draw new mark
99
  cv2.circle(image_copy,
100
- (int(x), int(y)),
101
- int(self.circle_diameter/2),
102
- (0, 255, 255),
103
- 1,
 
 
 
 
104
  lineType=cv2.LINE_AA)
105
-
106
- # Store new mark
107
- if is_image1:
108
- self.marks1.append((x, y))
109
- else:
110
- self.marks2.append((x, y))
111
-
112
- return image_copy
113
- except Exception as e:
114
- print(f"Error drawing circle: {str(e)}")
115
- return image
116
 
117
- def process_image1(self, file):
118
- image, image_display, dicom_data = self.load_dicom(file)
119
- self.current_image1 = image
120
- self.image_display1 = image_display
121
- self.dicom_data1 = dicom_data
122
- return image_display
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
 
124
- def process_image2(self, file):
125
- image, image_display, dicom_data = self.load_dicom(file)
126
- self.current_image2 = image
127
- self.image_display2 = image_display
128
- self.dicom_data2 = dicom_data
129
- return image_display
130
 
131
  def handle_click1(self, evt: gr.SelectData):
132
  if self.current_image1 is None:
 
81
  print(f"Error analyzing point: {str(e)}")
82
  return None
83
 
84
+ def draw_circle(self, image, x, y, is_image1=True):
85
+ try:
86
+ image_copy = image.copy()
87
+
88
+ # Draw all previous marks
89
+ marks = self.marks1 if is_image1 else self.marks2
90
+ for mark_x, mark_y in marks:
 
 
 
 
 
 
 
 
91
  cv2.circle(image_copy,
92
+ (int(mark_x), int(mark_y)),
93
+ int(self.circle_diameter / 2),
94
+ (0, 255, 255), 2, # Yellow outer ring
95
+ lineType=cv2.LINE_AA)
96
+ cv2.circle(image_copy,
97
+ (int(mark_x), int(mark_y)),
98
+ int(self.circle_diameter / 2) - 2,
99
+ (255, 255, 255), 1, # White inner ring
100
  lineType=cv2.LINE_AA)
 
 
 
 
 
 
 
 
 
 
 
101
 
102
+ # Draw the new mark
103
+ cv2.circle(image_copy,
104
+ (int(x), int(y)),
105
+ int(self.circle_diameter / 2),
106
+ (0, 255, 255), 2, # Yellow outer ring
107
+ lineType=cv2.LINE_AA)
108
+ cv2.circle(image_copy,
109
+ (int(x), int(y)),
110
+ int(self.circle_diameter / 2) - 2,
111
+ (255, 255, 255), 1, # White inner ring
112
+ lineType=cv2.LINE_AA)
113
+
114
+ # Store the new mark
115
+ if is_image1:
116
+ self.marks1.append((x, y))
117
+ else:
118
+ self.marks2.append((x, y))
119
+
120
+ return image_copy
121
+ except Exception as e:
122
+ print(f"Error drawing circle: {str(e)}")
123
+ return image
124
 
 
 
 
 
 
 
125
 
126
  def handle_click1(self, evt: gr.SelectData):
127
  if self.current_image1 is None: