Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

C++ implementation of an image processing task previously done using OpenCV Python wrappers.

License

Notifications You must be signed in to change notification settings

kaanklcrsln/feature-extractor

Repository files navigation

Laplacian Filter with Python Wrapper

Screenshot 2026-02-02 at 01 03 01

A C++ implementation of the Laplacian edge detection filter compiled as a shared library and wrapped with Python ctypes for easy integration.

Project Structure

.
├── laplacian.cpp           # C source with Laplacian filter implementation
├── liblaplacian.dylib      # Compiled shared library (macOS)
├── laplacian_wrapper.py    # Python wrapper using ctypes
└── image-ex.jpg            # Example image for testing

How It Works

  1. C++ Core (laplacian.cpp)

    • Implements the Laplacian kernel: 3x3 convolution matrix
    • Processes grayscale image data as flat array
    • Returns filtered image with edge detection applied
    • Compiled as shared library for cross-language usage
  2. Python Wrapper (laplacian_wrapper.py)

    • Loads the compiled C++ library using ctypes
    • Converts PIL images to numpy arrays
    • Calls C++ filter function with image data
    • Returns results as numpy arrays for matplotlib visualization
  3. Data Flow

    Image File (JPG) → PIL Load → Grayscale Convert → NumPy Array
    → C++ Filter via ctypes → Filtered NumPy Array → Matplotlib Display
    

Requirements

  • Python 3.6+
  • NumPy
  • Pillow
  • Matplotlib

Usage

from laplacian_wrapper import laplacian, show

# Get filtered image
original, filtered = laplacian('image-ex.jpg')

# Display side by side
show('image-ex.jpg')

Compilation

g++ -shared -fPIC -o liblaplacian.dylib laplacian.cpp -std=c++11

About

C++ implementation of an image processing task previously done using OpenCV Python wrappers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published