Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -61,10 +61,12 @@ class DicomAnalyzer:
|
|
| 61 |
self.pan_y = 0
|
| 62 |
self.max_pan_x = 0
|
| 63 |
self.max_pan_y = 0
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
|
|
|
|
|
|
| 68 |
print("DicomAnalyzer initialized...")
|
| 69 |
|
| 70 |
def save_results(self):
|
|
@@ -233,7 +235,7 @@ class DicomAnalyzer:
|
|
| 233 |
lineType=cv2.LINE_AA
|
| 234 |
)
|
| 235 |
|
| 236 |
-
# Draw 8 small
|
| 237 |
num_points = 8
|
| 238 |
for i in range(num_points):
|
| 239 |
angle = 2 * np.pi * i / num_points
|
|
@@ -295,7 +297,7 @@ class DicomAnalyzer:
|
|
| 295 |
|
| 296 |
dx = X - x
|
| 297 |
dy = Y - y
|
| 298 |
-
dist_squared = dx
|
| 299 |
|
| 300 |
mask = np.zeros((height, width), dtype=bool)
|
| 301 |
mask[dist_squared <= r_squared] = True
|
|
@@ -615,8 +617,17 @@ class DicomAnalyzer:
|
|
| 615 |
def create_interface():
|
| 616 |
print("Creating interface...")
|
| 617 |
analyzer = DicomAnalyzer()
|
| 618 |
-
|
| 619 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 620 |
gr.Markdown("# DICOM Image Analyzer")
|
| 621 |
|
| 622 |
with gr.Row():
|
|
@@ -643,7 +654,6 @@ def create_interface():
|
|
| 643 |
elem_id="image_display"
|
| 644 |
)
|
| 645 |
|
| 646 |
-
# Removed the "Add Blank Row" button
|
| 647 |
with gr.Row():
|
| 648 |
zero_btn = gr.Button("Add Zero Row")
|
| 649 |
zero2_btn = gr.Button("Add Two Zero Rows")
|
|
@@ -723,7 +733,6 @@ def create_interface():
|
|
| 723 |
outputs=image_display
|
| 724 |
)
|
| 725 |
|
| 726 |
-
# Removed blank_btn
|
| 727 |
zero_btn.click(
|
| 728 |
fn=analyzer.add_zero_row,
|
| 729 |
inputs=image_display,
|
|
|
|
| 61 |
self.pan_y = 0
|
| 62 |
self.max_pan_x = 0
|
| 63 |
self.max_pan_y = 0
|
| 64 |
+
|
| 65 |
+
# Main circle color remains yellow (BGR):
|
| 66 |
+
self.CIRCLE_COLOR = (0, 255, 255)
|
| 67 |
+
# Small circles inside the main circle will be white (BGR):
|
| 68 |
+
self.SMALL_CIRCLES_COLOR = (255, 255, 255)
|
| 69 |
+
|
| 70 |
print("DicomAnalyzer initialized...")
|
| 71 |
|
| 72 |
def save_results(self):
|
|
|
|
| 235 |
lineType=cv2.LINE_AA
|
| 236 |
)
|
| 237 |
|
| 238 |
+
# Draw 8 small white circles around
|
| 239 |
num_points = 8
|
| 240 |
for i in range(num_points):
|
| 241 |
angle = 2 * np.pi * i / num_points
|
|
|
|
| 297 |
|
| 298 |
dx = X - x
|
| 299 |
dy = Y - y
|
| 300 |
+
dist_squared = dx*dx + dy*dy
|
| 301 |
|
| 302 |
mask = np.zeros((height, width), dtype=bool)
|
| 303 |
mask[dist_squared <= r_squared] = True
|
|
|
|
| 617 |
def create_interface():
|
| 618 |
print("Creating interface...")
|
| 619 |
analyzer = DicomAnalyzer()
|
| 620 |
+
|
| 621 |
+
# We define custom CSS to set the cursor for #image_display to the red icon.
|
| 622 |
+
# The direct link from icons8 is used below.
|
| 623 |
+
custom_css = """
|
| 624 |
+
#image_display {
|
| 625 |
+
outline: none;
|
| 626 |
+
cursor: url("https://img.icons8.com/?size=100&id=11202&format=png&color=FA5252"), auto !important;
|
| 627 |
+
}
|
| 628 |
+
"""
|
| 629 |
+
|
| 630 |
+
with gr.Blocks(css=custom_css) as interface:
|
| 631 |
gr.Markdown("# DICOM Image Analyzer")
|
| 632 |
|
| 633 |
with gr.Row():
|
|
|
|
| 654 |
elem_id="image_display"
|
| 655 |
)
|
| 656 |
|
|
|
|
| 657 |
with gr.Row():
|
| 658 |
zero_btn = gr.Button("Add Zero Row")
|
| 659 |
zero2_btn = gr.Button("Add Two Zero Rows")
|
|
|
|
| 733 |
outputs=image_display
|
| 734 |
)
|
| 735 |
|
|
|
|
| 736 |
zero_btn.click(
|
| 737 |
fn=analyzer.add_zero_row,
|
| 738 |
inputs=image_display,
|