π§ Objective Detect and highlight differences between before and after images of the same scene by drawing bounding boxes around changed regions.
π Folder Structure
arduino
Copy
Edit
.
βββ task_2_code.py β Python script to run the detection
βββ task_2_output/ β Folder containing input and output images
β βββ 1.jpg β Input "before" image
β βββ 13.jpg β Output: "after" image with bounding boxes
β βββ 2.jpg
β βββ 23.jpg
β βββ ...
π How to Run
pip install -r requirements.txtBefore image: X.jpg After image: X~2.jpg
python task_2_code.pyThe script will generate: X~3.jpg: Annotated image showing the changes It will also ensure X.jpg is retained in the folder
π§ͺ How It Works Converts both images to grayscale and applies Gaussian blur.
Computes differences using: cv2.absdiff (raw pixel difference) SSIM (structural difference)
Combines both masks and applies morphological operations to reduce noise.
Detects contours and draws bounding boxes using smart filtering: Area threshold Aspect ratio Solidity Pixel change ratio inside each box
π¦ Dependencies See requirements.txt: opencv-python numpy scikit-image