carlosriverat commited on
Commit
08cc004
·
verified ·
1 Parent(s): 81ecec1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -67,11 +67,11 @@ def compare_images(image1, image2, blur_value, technique, threshold_value, metho
67
  cv2.drawContours(mask, filtered_contours, -1, (255, 255, 255), thickness=cv2.FILLED)
68
  highlighted = cv2.bitwise_and(image2, mask)
69
 
70
- diff_colored = np.zeros_like(image1, dtype=np.uint8)
71
- diff_colored[:, :, 0] = 0
72
- diff_colored[:, :, 1] = 0
73
- diff_colored[:, :, 2] = thresh
74
- overlayed = cv2.addWeighted(image1, 0.7, diff_colored, 0.6, 0)
75
 
76
  blended_with_object = cv2.addWeighted(image1, 0.4, image2, 0.6, 0)
77
  blended_without_object = cv2.bitwise_and(image1, image1, mask=255 - thresh)
@@ -88,7 +88,7 @@ with gr.Blocks() as demo:
88
  img1 = gr.Image(type="numpy", label="Image Without Object")
89
  img2 = gr.Image(type="numpy", label="Image With Object")
90
 
91
- blur_slider = gr.Slider(minimum=1, maximum=15, step=2, value=5, label="Gaussian Blur")
92
  technique_dropdown = gr.Dropdown(["Adaptive Threshold", "Otsu's Threshold", "Simple Binary"], label="Thresholding Technique", value="Adaptive Threshold", interactive=True)
93
  threshold_slider = gr.Slider(minimum=0, maximum=255, step=1, value=50, label="Threshold Value", visible=False)
94
  method_dropdown = gr.Dropdown(["SSIM", "Background Subtraction", "Optical Flow", "Feature Matching"], label="Comparison Method", value="SSIM", interactive=True)
@@ -106,4 +106,4 @@ with gr.Blocks() as demo:
106
  btn = gr.Button("Process")
107
  btn.click(compare_images, inputs=[img1, img2, blur_slider, technique_dropdown, threshold_slider, method_dropdown], outputs=[output1, output2, output3, output4])
108
 
109
- demo.launch()
 
67
  cv2.drawContours(mask, filtered_contours, -1, (255, 255, 255), thickness=cv2.FILLED)
68
  highlighted = cv2.bitwise_and(image2, mask)
69
 
70
+ diff_colored = cv2.absdiff(image1, image2)
71
+ diff_colored[:, :, 0] = 0 # Remove blue
72
+ diff_colored[:, :, 1] = 0 # Remove green
73
+
74
+ overlayed = cv2.addWeighted(image1, 0.6, diff_colored, 0.6, 0)
75
 
76
  blended_with_object = cv2.addWeighted(image1, 0.4, image2, 0.6, 0)
77
  blended_without_object = cv2.bitwise_and(image1, image1, mask=255 - thresh)
 
88
  img1 = gr.Image(type="numpy", label="Image Without Object")
89
  img2 = gr.Image(type="numpy", label="Image With Object")
90
 
91
+ blur_slider = gr.Slider(minimum=1, maximum=15, step=1, value=5, label="Gaussian Blur")
92
  technique_dropdown = gr.Dropdown(["Adaptive Threshold", "Otsu's Threshold", "Simple Binary"], label="Thresholding Technique", value="Adaptive Threshold", interactive=True)
93
  threshold_slider = gr.Slider(minimum=0, maximum=255, step=1, value=50, label="Threshold Value", visible=False)
94
  method_dropdown = gr.Dropdown(["SSIM", "Background Subtraction", "Optical Flow", "Feature Matching"], label="Comparison Method", value="SSIM", interactive=True)
 
106
  btn = gr.Button("Process")
107
  btn.click(compare_images, inputs=[img1, img2, blur_slider, technique_dropdown, threshold_slider, method_dropdown], outputs=[output1, output2, output3, output4])
108
 
109
+ demo.launch()