This is a Python project that demonstrates the application of notch filtering in image processing. Notch filters are used to selectively remove specific frequency components from an image's Fourier spectrum. In this project, we apply a notch filter to a given image and visualize the different processing steps.
- Python 3.x
- Required packages:
PIL
,numpy
,scipy
,matplotlib
You can install the required packages using the following command:
pip install pillow numpy scipy matplotlib
-
Clone the repository or download the
main.py
file. -
Place the input image
image24.tif
in the same directory as themain.py
file. -
Run the
main.py
script using the following command:
python main.py
The main.py
script performs the following steps:
- Imports necessary libraries and modules.
- Defines a custom notch filter function to remove specific frequency components from an image's Fourier spectrum.
- Loads the input image (
image24.tif
) and converts it to grayscale. - Applies a median filter to the noisy image to reduce noise.
- Performs Fast Fourier Transform (FFT) on the original image and shifts zero frequency components to the center.
- Manually defines notch centers (replace with actual coordinates) and generates a notch filter.
- Applies the notch filter to the FFT image by element-wise multiplication.
- Performs inverse FFT to obtain the filtered image.
- Creates and saves various plots for visualization, including the original image, median-filtered image, notch-filtered image, Fourier spectrum, notch filter, and result of multiplication.
The script generates a series of plots to visualize the image processing steps. The plots include:
- Original noisy image
- Median-filtered image
- Notch-filtered image
- Fourier spectrum of the original image
- Notch filter used
- Result of multiplication of FFT image and notch filter
- Replace the
notch_centers
with actual coordinates that correspond to the frequencies you want to remove using the notch filter. - The
notch_filter
function can be further customized based on your specific requirements.
Contributions to this project are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.