Skip to content

Using PIL and collections to perform image analysis, extracting most common HEXCODE values for grid cells of choice

License

Notifications You must be signed in to change notification settings

hydroboom/Geophysics-Survey-Image-Processing-image-file-to-HEXCODEs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Geophysics-Survey-Image-Processing-image-file-to-HEXCODEs

🔍 About This Project

This project automates the process of extracting resistivity data from terrameter reading images, where the raw numerical data is unavailable. Instead of manually identifying colours and entering resistivity values into GIS, this script:

  • Overlays a grid on the image and extracts the most frequent color per cell.
  • Converts colors to HEX values for further processing.
  • Outputs structured data (CSV & Excel heatmap) for analysis.
  • Prepares for GIS integration, where HEX colors will be replaced with resistivity values and georeferenced.

The uploaded files are inclusive of the input image file as sample along with the python script written in Jupyter Notebook.

This is the first step in streamlining geophysical data analysis, ultimately generating depth-based resistivity rasters in GIS.


🛠 Modules Used & Their Purpose

This project relies on some specialized Python modules:

  1. openpyxl

    • Used for creating an Excel-based heatmap of the extracted resistivity values.
    • The PatternFill function applies colours to Excel cells based on HEX values.
  2. Pillow (PIL)

    • Used for image processing and colour extraction.
    • Loads the terrameter image and converts it to RGB format for analysis.
  3. collections.Counter

    • Helps find the most frequent colour in each grid cell.
    • Ensures that the extracted colour represents the dominant resistivity reading.

These modules allow us to efficiently process images, extract meaningful data, and visualize results.


🚀 How It Works

  1. 📥 Input: An image of terrameter readings (from slides, reports, etc.).
  2. 🖼 Processing:
    • Divides the image into a structured grid.
    • Identifies the most common color in each grid cell.
    • Converts colors to HEX format.
  3. 📊 Output:
    • A CSV file mapping Grid_X, Grid_Z, and HEX colors.
    • A color-coded Excel heatmap for visualization.
  4. 🌍 Next Steps:
    • Replace HEX colors with resistivity values using a reference chart.
    • Georeference the extracted data in GIS for spatial analysis.

📖 References & Learning More


🔎 Keywords & Tags

#geophysics #resistivity #GIS #PythonImageProcessing #imageanalysis #imaging #depthvisualization #heatmap #terrameter #automateddataextraction #openpyxl #colourextraction #imagetocells #soilresistivity #excel #Pillow #geospatialanalysis #subsurfaceimaging #subsurface #earthresistivity #RGB #coloranalysis


🤝 Contributions & Feedback

This project is a work in progress! Feel free to contribute, suggest improvements, or fork the repo. 🚀