Skip to main content

Geospatial Raster Processing Library

Overview

This library provides geospatial image processing utilities for enhancing and analyzing raster datasets. It aims to provide essential functionalities for image histogram manipulation, allowing users to input multi-band images and apply various operations to enhance image contrast and distribution. It includes the following modules:

  1. Histogram Stretching: A module to enhance the contrast of raster images by applying percentile-based stretching.
  2. Histogram Matching: A module to adjust the pixel intensity distribution of a raster image to match a reference histogram.
  3. Histogram Equalization: A module to improve the contrast of raster images by redistributing pixel intensity values using histogram equalization.

These tools are designed for geospatial applications, enabling preprocessing steps commonly used in remote sensing and GIS workflows.


Features

Histogram Stretching

  • Enhances the contrast of images by clipping and rescaling pixel intensity values between specified lower and upper percentiles.
  • Outputs a visually improved raster image with stretched pixel values.
  • Supports multi-band raster datasets.

Histogram Matching

  • Adjusts the histogram of an input image to match the histogram of a reference image.
  • Useful for normalizing image datasets for analysis or visualization.
  • Compatible with single-band and multi-band raster datasets.

Histogram Equalization

  • Improves image contrast by redistributing pixel intensity values across the entire intensity range.
  • Automatically balances the intensity distribution to enhance image details.
  • Supports single-band raster datasets.

Installation

pip install histogram-manipulation

Usage

There are some examples in test folder

Histogram Stretching

from histogram_manipulation import HistogramStretching

# Initialize the class with input and output paths
stretching = HistogramStretching(input_path="input.tif", output_path="stretched_output.tif")

# Apply contrast stretching
stretching.contrast_stretch(lower_percentile=2, upper_percentile=98)

# Save the stretched image
stretching.save_stretched_image()

# Plot original vs. stretched images in RGB channel 
stretching.plot_rgb()
# Plot original vs. stretched images in single channel
stretching.plot_singleband()

# Plot the Histograms
stretching.plot_histograms()

Histogram Matching

from histogram_manipulation import HistogramMatcher

# Initialize the class with input and reference images
matcher = HistogramMatcher(reference_path="reference.tif", secondary_path="second.tif")

# Apply histogram matching
matcher.match_histograms()

# Save the matched image
matcher.save_matched_image()

# Plot the bands of secondary, reference, and matched images
matcher.plot_bands(matcher.secondary, "Secondary")
matcher.plot_bands(matcher.reference, "Reference")

with rio.open(matcher.matched_path) as matched_src:
    matched_data = matched_src.read()
matcher.plot_bands(matched_data, "Matched")

matcher.plot_histograms()

Histogram Equalization

from histogram_manipulation.equalization import HistogramEqualization

# Initialize the class with the input path
equalizer = HistogramEqualization(image_path="input.tif")

# Apply histogram equalization
equalizer.equalize()

# Save the equalized image
equalizer.save_equalized_image(output_path="equalized_output.tif")

# Display the original and equalized images side by side
equalizer.display_images()

# Plot histograms of the original and equalized images
equalizer.plot_histograms()

Metadata

Release files for histogram-manipulation 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for histogram-manipulation 1.1.1
File Size Uploaded
histogram_manipulation-1.1.1.tar.gz 12.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for histogram-manipulation 1.1.1
File Interpreter ABI Platform
histogram_manipulation-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 23.9 kB

Release files / histogram_manipulation-1.1.1.tar.gz

Download URL histogram_manipulation-1.1.1.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e11746156ec5ca91f8933b9d6c181606f475aa3b6b19e7aef59a0087590e9606
BLAKE2b-256 checksum
How to use checksums
2452fe7fda7d5c10e618463e84799c06da2f089c6a14b4fa83e03bc5478839ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

Release files / histogram_manipulation-1.1.1-py3-none-any.whl

Download URL histogram_manipulation-1.1.1-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
948056ed5e3b34834f277532658246f02bdb3823ef1c8520d084266c5cd08aa7
BLAKE2b-256 checksum
How to use checksums
d2671fdd15878a50a522ebfaa88325a28c4e5f21087adb2357c938923bdef411
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page