This repository contains MATLAB scripts and instructions for simulating and measuring turbidity in images using Fourier Transform and Gaussian filtering techniques. The process involves creating image patterns, applying Gaussian filters to simulate turbidity, and analyzing the effect of turbidity on the frequency domain of the images.
The process is divided into three main parts:
-
Simulation of Patterns and Turbidity:
- Pattern Creation: Create calibration patterns using chessboard images and bar patterns with varying frequencies. MATLAB is used for this purpose, with four frequencies used for both chessboard and bar images.
- Turbidity Simulation: Apply a Gaussian filter to the images to simulate turbidity. The Gaussian filter smooths or blurs the image by applying a weighted average to each pixel, with increasing standard deviation values used to adjust the level of turbidity.
-
Turbidity Measurement Using Fourier Transform:
- Fourier Transform: Convert the image into the frequency domain using the Fourier Transform. This results in a cross-shaped image for chessboards and a straight line for bar patterns, with peaks representing the frequencies of the image.
- Band-pass Filter: Apply a band-pass filter to isolate the main frequencies by removing high frequencies and the average value at the center. This filter is manually created by combining a high-pass filter and a low-pass filter.
- Frequency Analysis: Calculate the power of the frequencies in the image using the absolute value squared of the Fourier Transform. The results are plotted with turbidity levels marked as power and water quality assessed by the standard deviation applied to the image.
-
Experimental Project:
- Setup and Calibration: Set up the experimental system, including the water tank, camera, and light source. Calibrate the system to ensure accurate measurements of turbidity using real-world data.
Software
- MATLAB Installation: Ensure you have MATLAB installed on your system.
Hardware
- Required Equipment: The setup requires a water tank, a camera, and an appropriate light source. The light source is crucial as undesired shadows or reflections can impact the analysis.
- Optimal Conditions: Place the setup in a covered area to avoid shadows from surrounding objects. Conduct measurements during a time when sunlight is minimal, ideally between 12:00 and 14:00. Position the camera to cover the entire pattern.
- Chessboard and Bars: Use MATLAB to generate chessboard and bar patterns with varying frequencies. The MATLAB scripts for creating these patterns are included in this repository.
- Gaussian Filtering: Use MATLAB to apply a Gaussian filter to the images. Adjust the standard deviation to simulate different levels of turbidity.
- Fourier Transform: Perform the Fourier Transform on the simulated images to move them into the frequency domain.
- Band-pass Filtering: Manually create and apply a band-pass filter to remove undesired frequencies.
- Power Calculation: Compute the power of the frequencies by taking the absolute value squared of the Fourier Transform. The less frequency present, the higher the turbidity, as it blurs the pattern shown.
- Plotting Results: Plot the results of the power of frequencies versus turbidity levels. Compare the results simulated by the Gaussian filter with the actual turbidity measured using cocoa powder.
The project successfully demonstrated that turbidity in a water tank can be measured using a low-cost camera setup. The theoretical calculations and simulations were validated by practical results, showing that the method works effectively for basic quality control.
- Unit Considerations: The power and standard deviation values do not have explicit units, which may affect result interpretation. The analysis provides relative measurements of turbidity rather than absolute units.
I welcome contributions to improve this project! Please fork the repository and submit pull requests with your enhancements or bug fixes. For major changes, please open an issue to discuss what you would like to change.
For any questions or inquiries, please contact:
- Luis Granados - [email protected]
- GitHub Profile - luisgrana2
- LinkedIn Profile - Luis Granados