Iterative Thresholding method for Image Segmentation

This repository contains Python code that implements an iterative thresholding method for image segmentation. The method aims to separate regions of interest in an image based on pixel intensities. It iteratively calculates and refines threshold values to achieve accurate segmentation.

How It Works

The segmentation process consists of the following steps:

  1. First Time Threshold Calculation: The initial threshold is computed using the mean intensities of corner pixels. This helps in distinguishing between background and foreground regions.

  2. Second Threshold Calculation: A new threshold value is calculated based on the means of pixel intensities in segmented regions. This step aims to improve the accuracy of the threshold.

  3. Iterative Refinement: The second threshold is iteratively refined to converge towards a stable value. The iteration process enhances the segmentation by adjusting the threshold based on the calculated means.

  4. Segmentation and Display: Finally, the refined threshold is applied to the image, and the segmented result is displayed using a grayscale colormap. Segmented regions are separated based on pixel intensity values.

Usage

To use this code for image segmentation:

  1. Make sure you have the necessary libraries installed: numpy and matplotlib.

  2. Replace image in the code with the grayscale image you want to segment.

  3. Run the provided functions in the order they appear in the code.

  4. The final segmented result will be displayed using the the_iterative_methode function.