Skip to content

OlyMarco/MATLAB_Image_Processing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MATLAB Image Processing Toolkit

Screenshot

MATLAB License Bilibili YouTube

Project Overview

A comprehensive image processing toolkit developed with MATLAB GUIDE, integrating classical algorithms with real-time visualization capabilities. Features modular architecture and a complete workflow from basic geometric transformations to advanced image analysis. Suitable for digital image processing education, algorithm verification, and rapid prototyping.

Key Features

Real-Time Visualization System

  • Dual-view comparison: Original image and processed result displayed side by side
  • Pixel waveform analysis: Real-time display of RGB/grayscale pixel waveforms for the first row
  • Histogram statistics: Dynamic updates of image grayscale/color distribution
  • Intelligent type detection: Automatic recognition of color/grayscale images with corresponding visualization mode switching

Technical Implementation Highlights

  • MATLAB GUIDE-based graphical user interface
  • Event-driven callback function architecture
  • handles struct for state management
  • Modular function design (gUpdate22/gUpdate23)
  • Supported formats: JPG, PNG, BMP, JPEG

Functional Modules

1. Geometric Transformations

Function Implementation Parameter Control
Horizontal/Vertical Mirroring fliplr() / flipud() Button trigger
Image Translation imtranslate() with cumulative offset Dual sliders for real-time control
Image Rotation imrotate() with bilinear interpolation Slider 0-360 degrees
Image Scaling imresize() with nearest-neighbor + imcrop() Slider ratio control

Technical Details:

  • Translation uses incremental vector V = [delta_h, delta_v] for cumulative transformations
  • Rotation and scaling operate on the original image to avoid cumulative error
  • Scaling automatically crops to the original size for display consistency

2. Image Filtering

Spatial Domain Filters

% Mean filter - 3x3 average kernel
h = fspecial('average');

% Gaussian filter - 8x8 window, sigma=1.7
h = fspecial('gaussian', [8 8], 1.7);

% Median filter - per-channel processing for RGB
r = medfilt2(img(:,:,1));
g = medfilt2(img(:,:,2));
b = medfilt2(img(:,:,3));

Application Scenarios:

  • Mean filtering: Fast denoising, suitable for Gaussian noise
  • Median filtering: Edge-preserving denoising, suitable for salt-and-pepper noise
  • Gaussian filtering: Image smoothing, preserves more detail

3. Edge Detection

Five classical edge detection operators are implemented:

Operator Principle Characteristics
Sobel 3x3 gradient operator Good noise resistance, suitable for real-time processing
Roberts 2x2 cross difference Simple computation, precise localization
Prewitt 3x3 smoothed gradient Good smoothing effect
LoG Laplacian of Gaussian Second derivative, sensitive to noise
Canny Multi-stage optimization Highest precision, industry standard

Implementation Details:

  • Color images are automatically converted to grayscale (rgb2gray)
  • Uses MATLAB's built-in optimized edge() function
  • Edge detection results are binary images

4. Image Enhancement

Contrast Enhancement

% Brightness enhancement - expands dark details
imadjust(img, [0, 0.9], [0, 1]);

% Brightness reduction - expands bright details
imadjust(img, [0.1, 1], [0, 1]);

Histogram Equalization

  • Global contrast-adaptive enhancement based on histeq()
  • Automatic redistribution of gray levels to improve image visibility
  • Suitable for low-contrast and underexposed images

5. Image Operations

Weighted Addition

alpha = 0.5;
result = imadd(alpha * img1, alpha * img2);
  • Weight coefficient alpha = 0.5 for equal-weight blending
  • Automatic size matching (imresize)

Blend Fusion

result = imfuse(img1, img2, 'blend');
  • Uses MATLAB's imfuse advanced fusion algorithm
  • Supports multiple fusion modes

6. Image Segmentation

Threshold Segmentation - Binarization based on global threshold

binary = rgb2gray(img) > threshold;
  • Real-time threshold adjustment via slider (0-255)
  • Automatic conversion to grayscale before segmentation
  • Suitable for scenarios with simple background and high contrast

System Architecture

GUI Component Layout

+--------------------------------------------------------+
|  [Open] [Save] [Reset] [Exit]                           |
+------------------+--------------------------------------+
|                  |  Control Panel                        |
|   Original       |  +- Geometric Transform             |
|   Image          |  +- Filtering                        |
|   (g11)          |  +- Edge Detection                   |
|                  |  +- Enhancement                      |
+------------------+  +- Segmentation                     |
|   Processed      |                                      |
|   Image          |  Sliders:                           |
|   (g12)          |  - H/V Translation                   |
|                  |  - Rotation (0-360 degrees)          |
+------------------+  - Resize (0.1-2.0x)                 |
|  Waveform        |  - Threshold (0-255)                 |
|  (g21, g22)      |                                      |
+------------------+                                      |
|  Histogram       |                                      |
|  (g23)           |                                      |
+------------------+--------------------------------------+

State Management Mechanism

handles.img   % Current processed image
handles.i     % Original image backup
handles.h     % Cumulative horizontal translation
handles.v     % Cumulative vertical translation
handles.file  % File path

Visualization Update Flow

User Operation -> Callback Function -> Image Processing -> Update Display
                                                         +-- Update g12 (processed image)
                                                         +-- Detect image type
                                                         +-- Call gUpdate22/23
                                                         |   +-- Update waveform (g22)
                                                         |   +-- Update histogram (g23)
                                                         +-- Save state (guidata)

Algorithm Performance

Operation Time Complexity Space Complexity Notes
Geometric Transformations O(n) O(n) n = total pixels
Mean/Gaussian Filtering O(n x k^2) O(k^2) k = kernel size
Median Filtering O(n x k^2 x log k) O(k^2) Sorting overhead
Edge Detection O(n) O(n) Optimized implementation
Histogram Equalization O(n + L) O(L) L = number of gray levels
Threshold Segmentation O(n) O(n) Fastest segmentation method

System Requirements

Required Environment

  • MATLAB: R2018b or higher
  • Toolbox: Image Processing Toolbox
  • Operating System: Windows / macOS / Linux

Recommended Configuration

  • Memory: 4GB RAM or more
  • Processor: Intel i5 or equivalent
  • Display: 1920x1080 or higher resolution

Quick Start

Installation Steps

  1. Clone the repository
git clone https://github.com/OlyMarco/MATLAB_Image_Processing.git
cd MATLAB_Image_Processing
  1. Launch MATLAB

    • Open MATLAB
    • Navigate to the project directory
  2. Run the program

cd Image_Processing
Image_Processing

Usage Workflow

  1. Load image: Click the Open button to select an image file
  2. Apply processing: Choose the desired image processing function
  3. Adjust parameters: Use sliders to adjust parameters in real time
  4. View results: Compare original and processed images, view waveforms and histograms
  5. Save image: Click the Save button to export the processed result
  6. Reset: Click the Reset button to restore the original image

Project Structure

MATLAB_Image_Processing/
├── LICENSE                      # MIT open source license
├── README.md                    # Project documentation
├── Image_Processing/
│   ├── Image_Processing.m       # Main program (869 lines)
│   │   ├── GUI initialization
│   │   ├── Callback functions (30+)
│   │   ├── Visualization update functions
│   │   └── Utility functions
│   └── Image_Processing.fig     # GUIDE interface design file
└── images/
    └── main.png                 # Application screenshot

Technical Highlights

Design Patterns

  • MVC Architecture: View (fig) + Controller (callbacks) + Model (handles)
  • Event-driven: Based on MATLAB's callback mechanism
  • State pattern: UI state management using Enable/Visible properties

Code Quality

  • Modular: Independent callback functions for each feature
  • Reusable: Encapsulated visualization update functions
  • Robust: Type detection and error warnings
  • Maintainable: Clear code structure and comments

User Experience

  • Progressive enablement: Processing features disabled until an image is loaded
  • Immediate feedback: All operations update the display in real time
  • Progress indication: Progress bar displayed when loading images
  • Friendly prompts: Warning dialogs for invalid operations

Future Work

Planned Features

  • Batch processing mode
  • Undo/Redo stack
  • Additional segmentation algorithms (Otsu, K-means, Watershed)
  • Morphological operations (erosion, dilation, opening, closing)
  • Frequency domain filtering (FFT, spectrum analysis)
  • Custom convolution kernel editor
  • Image quality assessment metrics (PSNR, SSIM)
  • Export processing workflow as script

Optimization Directions

  • Multi-threaded acceleration for large image processing
  • More refined parameter adjustment (input box + slider)
  • Support for additional image formats (TIFF, RAW)
  • Operation history panel

References

  • Gonzalez, R. C., & Woods, R. E. (2018). Digital Image Processing (4th ed.)
  • MATLAB Image Processing Toolbox Documentation
  • Canny, J. (1986). "A Computational Approach to Edge Detection"

Acknowledgments

Sincere thanks to all researchers and engineers who have contributed to the field of digital image processing.

About

MATLAB Image Processing Toolkit with 30+ features: transforms, filtering, edge detection, enhancement + a real-time user-friendly visualization.

Resources

License

Stars

Watchers

Forks

Contributors

Languages