{"id":34607527,"url":"https://github.com/exprays/satelite_change_detection","last_synced_at":"2026-05-08T03:03:38.727Z","repository":{"id":329138212,"uuid":"1118293965","full_name":"exprays/satelite_change_detection","owner":"exprays","description":"🛰️ Satellite change detection with CV \u0026 deep learning. Multiple methods, comprehensive metrics (Kappa, F1), Google Colab ready.","archived":false,"fork":false,"pushed_at":"2026-01-10T17:49:37.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-11T05:22:11.650Z","etag":null,"topics":["change-detection","colab","python","pytorch","satellite-imagery","siamese-network"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/exprays.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-17T14:41:16.000Z","updated_at":"2026-01-10T17:49:41.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/exprays/satelite_change_detection","commit_stats":null,"previous_names":["exprays/satelite_change_detection"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/exprays/satelite_change_detection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exprays%2Fsatelite_change_detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exprays%2Fsatelite_change_detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exprays%2Fsatelite_change_detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exprays%2Fsatelite_change_detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/exprays","download_url":"https://codeload.github.com/exprays/satelite_change_detection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exprays%2Fsatelite_change_detection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32764771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T02:36:36.067Z","status":"ssl_error","status_checked_at":"2026-05-08T02:36:07.210Z","response_time":54,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["change-detection","colab","python","pytorch","satellite-imagery","siamese-network"],"created_at":"2025-12-24T13:59:32.153Z","updated_at":"2026-05-08T03:03:38.722Z","avatar_url":"https://github.com/exprays.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Satellite Change Detection Project\n\nA comprehensive satellite imagery change detection system that identifies differences between before and after images using multiple computer vision and deep learning techniques.\n\n![Python](https://img.shields.io/badge/python-3.8+-blue.svg)\n![TensorFlow](https://img.shields.io/badge/TensorFlow-2.x-orange.svg)\n![License](https://img.shields.io/badge/license-MIT-green.svg)\n\n## 🌟 Features\n\n- **Multiple Detection Methods**:\n\n  - Image Differencing\n  - Adaptive Thresholding\n  - Change Vector Analysis (CVA)\n  - Deep Learning (Siamese Network)\n\n- **Comprehensive Visualization**:\n\n  - Side-by-side before/after comparisons\n  - Heatmaps and difference maps\n  - Color-coded change overlays\n  - Statistical analysis\n\n- **Advanced Metrics**:\n\n  - Kappa Coefficient (Cohen's Kappa)\n  - F1 Score\n  - Precision \u0026 Recall\n  - Overall Accuracy\n  - False Positive/Negative Rates\n  - Confusion Matrix\n\n- **Google Colab Compatible**: Run directly in your browser with GPU support\n\n- **Export Capabilities**: Save results as PNG images and detailed statistics\n\n## 📋 Table of Contents\n\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Usage](#usage)\n- [Methods Explained](#methods-explained)\n- [Custom Data](#custom-data)\n- [Requirements](#requirements)\n- [Project Structure](#project-structure)\n- [Examples](#examples)\n- [Contributing](#contributing)\n- [License](#license)\n\n## 🚀 Installation\n\n### Option 1: Google Colab (Recommended)\n\n1. Open the notebook in Google Colab:\n\n   - Upload `satellite_change_detection.ipynb` to Google Colab\n   - Or use: `File \u003e Upload notebook`\n\n2. Run the first cell to install all dependencies automatically\n\n3. Mount Google Drive (optional) to save results\n\n### Option 2: Local Installation\n\n```bash\n# Clone or download this repository\ngit clone \u003cyour-repo-url\u003e\ncd satellite-change-detection\n\n# Create a virtual environment (recommended)\npython -m venv venv\n\n# Activate virtual environment\n# On Windows:\nvenv\\Scripts\\activate\n# On Linux/Mac:\nsource venv/bin/activate\n\n# Install required packages\npip install -r requirements.txt\n\n# Launch Jupyter Notebook\njupyter notebook satellite_change_detection.ipynb\n```\n\n## 📦 Requirements\n\nCreate a `requirements.txt` file with:\n\n```txt\nnumpy\u003e=1.19.0\nmatplotlib\u003e=3.3.0\nopencv-python\u003e=4.5.0\nscikit-image\u003e=0.18.0\npillow\u003e=8.0.0\ntensorflow\u003e=2.8.0\ntorch\u003e=1.10.0\ntorchvision\u003e=0.11.0\nrasterio\u003e=1.2.0\ngeopandas\u003e=0.10.0\njupyter\u003e=1.0.0\n```\n\nInstall all at once:\n\n```bash\npip install -r requirements.txt\n```\n\n## ⚡ Quick Start\n\n### Using Sample Data (Demo)\n\nThe notebook includes built-in sample satellite images for immediate testing:\n\n```python\n# Simply run all cells in order\n# Sample images are automatically generated in Section 4\n```\n\n### Using Your Own Satellite Images\n\n```python\nimport cv2\n\n# Load your satellite images\nbefore_img = cv2.imread('path/to/before_image.png')\nafter_img = cv2.imread('path/to/after_image.png')\n\n# For GeoTIFF files\nimport rasterio\nwith rasterio.open('satellite_image.tif') as src:\n    image = src.read([1, 2, 3])  # Read RGB bands\n    image = np.transpose(image, (1, 2, 0))  # Rearrange to (H, W, C)\n    image = image.astype(np.uint8)\n```\n\n## 📖 Usage\n\n### Basic Workflow\n\n1. **Install Dependencies** (Section 1)\n2. **Import Libraries** (Section 2)\n3. **Mount Google Drive** (Section 3) - Optional\n4. **Load Images** (Section 4)\n5. **Run Detection Methods** (Sections 7-11)\n6. **View Results** (Section 12)\n7. **Export Results** (Section 14)\n\n### Running in Google Colab\n\n```python\n# 1. Upload the notebook to Colab\n# 2. Run cells sequentially using Shift+Enter\n# 3. Results will be saved to Google Drive if mounted\n```\n\n### Running Locally\n\n```bash\n# Start Jupyter Notebook\njupyter notebook\n\n# Open satellite_change_detection.ipynb\n# Run cells sequentially\n# Results saved to ./satellite_data/results/\n```\n\n## 🔬 Methods Explained\n\n### 1. Image Differencing\n\n- Simple pixel-wise subtraction between images\n- Fast and computationally efficient\n- Works well for significant changes\n- **Best for**: Quick analysis, large structural changes\n\n### 2. Thresholding\n\n- Converts difference map to binary change mask\n- Adjustable threshold values\n- Morphological operations to reduce noise\n- **Best for**: Clear change detection with minimal false positives\n\n### 3. Change Vector Analysis (CVA)\n\n- Analyzes spectral change magnitude and direction\n- Considers all color channels simultaneously\n- Percentile-based thresholding\n- **Best for**: Multi-spectral satellite data, subtle changes\n\n### 4. Deep Learning (Siamese Network)\n\n- CNN-based feature extraction\n- Learns complex change patterns\n- Requires training data for best results\n- **Best for**: Complex scenes, semantic change detection\n\n## 🗂️ Custom Data\n\n### Supported Formats\n\n- **Standard Images**: PNG, JPG, JPEG, BMP\n- **Geospatial**: GeoTIFF, TIF (via rasterio)\n- **Multi-spectral**: Any format with multiple bands\n\n### Image Requirements\n\n- Before and after images should be:\n  - Same geographic area\n  - Similar resolution\n  - Co-registered (aligned)\n  - Same size (or will be resized automatically)\n\n### Loading GeoTIFF Files\n\n```python\nimport rasterio\nimport numpy as np\n\ndef load_geotiff(filepath, bands=[1, 2, 3]):\n    \"\"\"Load GeoTIFF file with specific bands\"\"\"\n    with rasterio.open(filepath) as src:\n        image = src.read(bands)\n        image = np.transpose(image, (1, 2, 0))\n        # Normalize if needed\n        image = ((image - image.min()) / (image.max() - image.min()) * 255).astype(np.uint8)\n    return image\n\nbefore_img = load_geotiff('before.tif', bands=[4, 3, 2])  # NIR, Red, Green\nafter_img = load_geotiff('after.tif', bands=[4, 3, 2])\n```\n\n## 📁 Project Structure\n\n```\nsatellite-change-detection/\n├── satellite_change_detection.ipynb  # Main notebook\n├── README.md                         # This file\n├── requirements.txt                  # Python dependencies\n├── satellite_data/                   # Working directory (created automatically)\n│   └── results/                      # Output directory\n│       ├── before_image.png\n│       ├── after_image.png\n│       ├── difference_map.png\n│       ├── threshold_change_mask.png\n│       ├── cva_change_mask.png\n│       ├── dl_change_mask.png\n│       ├── threshold_overlay.png\n│       ├── cva_overlay.png\n│       ├── dl_overlay.png\n│       └── change_statistics.txt\n└── sample_images/                    # Your input images (optional)\n    ├── before.tif\n    └── after.tif\n```\n\n## 📊 Output Files\n\nAfter running the notebook, you'll get:\n\n- **Change Masks**: Binary images showing detected changes\n- **Overlay Images**: Changes highlighted on original images\n- **Statistics File**: Detailed metrics including:\n  - Basic statistics (area, percentage, regions)\n  - Kappa Coefficient for agreement assessment\n  - F1 Score for overall performance\n  - Precision and Recall metrics\n  - Confusion matrix (TP, TN, FP, FN)\n  - False Positive/Negative rates\n- **Difference Maps**: Heatmaps showing change intensity\n\n## 🎯 Examples\n\n### Urban Development Detection\n\n```python\n# Useful for detecting new buildings, roads, infrastructure\n# Use CVA or Deep Learning methods for best results\n```\n\n### Deforestation Monitoring\n\n```python\n# Track forest loss over time\n# Threshold method works well for vegetation changes\n```\n\n### Disaster Assessment\n\n```python\n# Flood extent, fire damage, earthquake impact\n# Image differencing provides quick initial assessment\n```\n\n## 🔧 Customization\n\n### Adjust Threshold Values\n\n```python\n# In Section 8, modify threshold parameter\nchange_mask = threshold_changes(diff_image, threshold=25)  # Lower = more sensitive\n```\n\n### Change CVA Sensitivity\n\n```python\n# In Section 9, adjust percentile\nmagnitude, direction, cva_mask = change_vector_analysis(\n    before_proc, after_proc,\n    threshold_percentile=85  # Lower = more changes detected\n)\n```\n\n### Train Deep Learning Model\n\n```python\n# Prepare your labeled training data\nX_train_before = np.array([...])  # Shape: (N, H, W, 3)\nX_train_after = np.array([...])   # Shape: (N, H, W, 3)\ny_train = np.array([...])         # Shape: (N, H, W, 1) - binary masks\n\n# Train the model\nhistory = model.fit(\n    [X_train_before, X_train_after],\n    y_train,\n    epochs=50,\n    batch_size=8,\n    validation_split=0.2,\n    callbacks=[\n        tf.keras.callbacks.EarlyStopping(patience=5),\n        tf.keras.callbacks.ModelCheckpoint('best_model.h5')\n    ]\n)\n```\n\n## 🐛 Troubleshooting\n\n### Common Issues\n\n**1. Memory Error with Large Images**\n\n```python\n# Resize images before processing\ntarget_size = (512, 512)\nbefore_proc, after_proc, before_norm, after_norm = preprocess_images(\n    before_img, after_img, target_size=target_size\n)\n```\n\n**2. Images Not Aligned**\n\n```python\n# Use image registration (requires additional setup)\nimport cv2\n# Detect features and align images\n# Or use specialized tools like GDAL for geospatial data\n```\n\n**3. TensorFlow/GPU Issues in Colab**\n\n```python\n# Check GPU availability\nimport tensorflow as tf\nprint(\"GPU Available:\", tf.config.list_physical_devices('GPU'))\n\n# Use CPU if needed\nimport os\nos.environ['CUDA_VISIBLE_DEVICES'] = '-1'\n```\n\n## 💡 Tips for Best Results\n\n1. **Image Quality**: Use high-resolution, clear images\n2. **Alignment**: Ensure before/after images are properly co-registered\n3. **Same Conditions**: Similar lighting, season, and atmospheric conditions\n4. **Preprocessing**: Apply atmospheric correction if available\n5. **Multiple Methods**: Compare results from different techniques\n6. **Ground Truth**: Validate with known changes when possible\n\n## 🤝 Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n## 🙏 Acknowledgments\n\n- OpenCV for image processing capabilities\n- TensorFlow team for deep learning framework\n- Rasterio for geospatial data handling\n- Google Colab for free GPU access\n\n## 📧 Contact\n\nFor questions or suggestions, please open an issue on GitHub.\n\n## 🔗 Useful Resources\n\n- [Rasterio Documentation](https://rasterio.readthedocs.io/)\n- [OpenCV Change Detection Tutorial](https://docs.opencv.org/)\n- [TensorFlow Keras Guide](https://www.tensorflow.org/guide/keras)\n- [Google Earth Engine](https://earthengine.google.com/) - For downloading satellite data\n\n---\n\n**Happy Change Detection! 🛰️🔍**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexprays%2Fsatelite_change_detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexprays%2Fsatelite_change_detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexprays%2Fsatelite_change_detection/lists"}