Binarization and Vanishing Points Detection

Project information

Binarization and Vanishing Points

Binarization Program

Introduction

Image binarization separates objects or regions of interest from the background by finding an optimal threshold.

Key Features

  • Loss Function: The get_loss function calculates a loss function, considering histogram values, bin values, and threshold. \[ L = \sum_{i=0}^{T} {{num}}_{i} \cdot {{dist\_u\_thresh}}_{i} + \sum_{i=T+1}^{255} {{num}}_{i} \cdot {{dist\_o\_thresh}}_{i} \]
  • Finding the Best Threshold: The get_best_thresh function finds the best threshold value for binarization in either 'Auto' or 'Manual' mode.
  • Applying Threshold: The apply_thresh function generates a binary image with values of 0 or 255.

For a detailed description of the algorithm, please refer to the Report.

Command Line

Use the following command line arguments:

  • -i or --img_path: Input image path.
  • -t or --tuning_method: Choose 'Auto' or 'Manual' tuning.
  • -u or --under_tuning: Set tuning value for pixels under the threshold (only for 'Manual' tuning).
  • -o or --over_tuning: Set tuning value for pixels over the threshold (only for 'Manual' tuning).
  • -s or --storing_path: Output image path.
  • -show_all: Set to 'False' only for serial script execution of multiple images.

Graphic User Interface (GUI)

To use the GUI, run:

                  python binarization_GUI.py
              

Examples

This is an example of the program's output:

                  python binarization.py -i 27img.jpg -t Auto -s 27img_bin.jpg -show_all True
              
Lake Binary Image

Vanishing Point and Lines Detection Program

This program is designed to detect vanishing points and vanishing lines within images. It's implemented in Python and organized into multiple scripts, each dedicated to a specific aspect of the task.

Key Features

The program's functionality is divided into four main stages:

  1. Preprocessing: Converts the input image to grayscale and reduces noise to enhance clarity and reduce artifacts.
  2. Edge Detection: Identifies significant transitions in intensity within the image using the Canny edge detector.
  3. Lines Detection: Detects straight line segments within the image using the probabilistic Hough transform.
  4. Vanishing Point Detection: Identifies the vanishing point and vanishing lines within the image using the RANSAC algorithm.

Command Line Usage

The program accepts several command line arguments, allowing you to customize its behavior for different images or use cases. You can choose between 'Auto' and 'Manual' tuning for edge detection and specify other parameters.

Use the following command line arguments:

  • -h or --help: show the help message and exit.
  • -p or --path: Specify the path to the input image or a folder containing images for batch processing.
  • -t or --tuning_method: Choose the tuning method, either 'Auto' or 'Manual.'
  • -l or --lowThreshold: Set the low threshold for the Canny edge detector (only for 'Manual' tuning).
  • -r or --highThreshold: Set the high threshold for the Canny edge detector (only for 'Manual' tuning).
  • -a or --theta: Set the theta value for the Hough transform (only for 'Manual' tuning).
  • -d or --threshold: Set the threshold value for the Hough transform (only for 'Manual' tuning).
  • -m or --minLineLength: Set the minimum line length for the Hough transform (only for 'Manual' tuning).
  • -g or --maxLineGap: Set the maximum line gap for the Hough transform (only for 'Manual' tuning).
  • -s or --storingPath: Specify the path to store the output image + name.
                  python vanishingPointDetection.py -p [input_path] -t Auto -s [output_path]
              

Example

                  python3 vanishingPointDetection.py -p ../Images/vanishing_points/van_points8.jpeg -t Auto -s ../Images/examples/van_points8.jpeg
              
Result of the vanishing point detection on the image van_points8.jpg

Additional details

Further information about the implementation and results of this project can be found in the Report.