Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,6 +31,9 @@ class DicomAnalyzer:
|
|
| 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,7 +41,7 @@ class DicomAnalyzer:
|
|
| 38 |
if len(image_display.shape) == 2:
|
| 39 |
image_display = cv2.cvtColor(image_display, cv2.COLOR_GRAY2BGR)
|
| 40 |
|
| 41 |
-
return
|
| 42 |
except Exception as e:
|
| 43 |
print(f"Error loading DICOM file: {str(e)}")
|
| 44 |
return None, None, None
|
|
@@ -187,9 +190,10 @@ class DicomAnalyzer:
|
|
| 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.
|
| 192 |
-
self.offset_y = (resized.shape[0] - self.
|
| 193 |
return resized
|
| 194 |
return self.image_display1
|
| 195 |
|
|
@@ -299,4 +303,4 @@ def create_interface():
|
|
| 299 |
|
| 300 |
if __name__ == "__main__":
|
| 301 |
interface = create_interface()
|
| 302 |
-
interface.launch()
|
|
|
|
| 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 |
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 |
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 |
|
|
|
|
| 303 |
|
| 304 |
if __name__ == "__main__":
|
| 305 |
interface = create_interface()
|
| 306 |
+
interface.launch()
|