Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -70,42 +70,46 @@ class DicomAnalyzer:
|
|
| 70 |
print(f"Error analyzing point: {str(e)}")
|
| 71 |
return None
|
| 72 |
|
| 73 |
-
def draw_circle(self, image, x, y):
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
(int(mark_x), int(mark_y)),
|
| 81 |
-
int(self.circle_diameter / 2),
|
| 82 |
-
(0, 255, 255), 2, # Yellow outer ring
|
| 83 |
-
lineType=cv2.LINE_AA)
|
| 84 |
-
cv2.circle(image_copy,
|
| 85 |
-
(int(mark_x), int(mark_y)),
|
| 86 |
-
int(self.circle_diameter / 2) - 2,
|
| 87 |
-
(255, 255, 255), 1, # White inner ring
|
| 88 |
-
lineType=cv2.LINE_AA)
|
| 89 |
-
|
| 90 |
-
# Draw the new mark
|
| 91 |
cv2.circle(image_copy,
|
| 92 |
-
(int(
|
| 93 |
int(self.circle_diameter / 2),
|
| 94 |
-
(
|
| 95 |
lineType=cv2.LINE_AA)
|
| 96 |
-
cv2.circle(image_copy,
|
| 97 |
-
(int(
|
| 98 |
-
int(self.circle_diameter / 2) -
|
| 99 |
-
(255, 255, 255), 1, # White inner ring
|
| 100 |
lineType=cv2.LINE_AA)
|
| 101 |
|
| 102 |
-
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
|
| 110 |
def process_image(self, file):
|
| 111 |
image, image_display, dicom_data = self.load_dicom(file)
|
|
|
|
| 70 |
print(f"Error analyzing point: {str(e)}")
|
| 71 |
return None
|
| 72 |
|
| 73 |
+
def draw_circle(self, image, x, y, is_image1=True):
|
| 74 |
+
try:
|
| 75 |
+
image_copy = image.copy()
|
| 76 |
+
|
| 77 |
+
# Draw all previous marks
|
| 78 |
+
marks = self.marks1 if is_image1 else self.marks2
|
| 79 |
+
for mark_x, mark_y in marks:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
cv2.circle(image_copy,
|
| 81 |
+
(int(mark_x), int(mark_y)),
|
| 82 |
int(self.circle_diameter / 2),
|
| 83 |
+
(255, 255, 0), 1, # Yellow outer ring (thin)
|
| 84 |
lineType=cv2.LINE_AA)
|
| 85 |
+
cv2.circle(image_copy,
|
| 86 |
+
(int(mark_x), int(mark_y)),
|
| 87 |
+
int(self.circle_diameter / 2) - 1, # Slightly smaller radius
|
| 88 |
+
(255, 255, 255), 1, # White inner ring (thin)
|
| 89 |
lineType=cv2.LINE_AA)
|
| 90 |
|
| 91 |
+
# Draw the new mark
|
| 92 |
+
cv2.circle(image_copy,
|
| 93 |
+
(int(x), int(y)),
|
| 94 |
+
int(self.circle_diameter / 2),
|
| 95 |
+
(255, 255, 0), 1, # Yellow outer ring (thin)
|
| 96 |
+
lineType=cv2.LINE_AA)
|
| 97 |
+
cv2.circle(image_copy,
|
| 98 |
+
(int(x), int(y)),
|
| 99 |
+
int(self.circle_diameter / 2) - 1,
|
| 100 |
+
(255, 255, 255), 1, # White inner ring (thin)
|
| 101 |
+
lineType=cv2.LINE_AA)
|
| 102 |
+
|
| 103 |
+
# Store the new mark
|
| 104 |
+
if is_image1:
|
| 105 |
+
self.marks1.append((x, y))
|
| 106 |
+
else:
|
| 107 |
+
self.marks2.append((x, y))
|
| 108 |
|
| 109 |
+
return image_copy
|
| 110 |
+
except Exception as e:
|
| 111 |
+
print(f"Error drawing circle: {str(e)}")
|
| 112 |
+
return image
|
| 113 |
|
| 114 |
def process_image(self, file):
|
| 115 |
image, image_display, dicom_data = self.load_dicom(file)
|