Difference between revisions of "PSD Sensor"

From BoSL Wiki
Jump to navigation Jump to search
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Introduction==
+
== Introduction ==
This page will present the development of the Camera Turbidity and PSD Sensor.
+
The PSD Sensor is a novel, low-cost camera-based sensor designed for near-continuous in-situ measurements of Particle Size Distribution (PSD) in stormwater. This sensor addresses the limitations of traditional PSD measurement methods, which are often expensive, labour-intensive, or unable to provide real-time data.
More introductions to come...
 
  
==Development Log==
+
== Key Features ==
===04 July 2022===
+
[[File:BoSLCam front and back.png|thumb|right|300px|Front and back of BoSLCam. Orange: OV7575 camera module, light blue: SIM card slot, yellow: UART connection, grey: battery connector, dark blue: LTE and GPS antenna, red: nRF9160, purple: 23LCV1024 SRAM chip, mint: SD card slot.]]
The very first experiment...
+
* Utilizes a self-developed and highly customised compact camera with a 25x macro lens
 +
* Employs image processing techniques for particle size estimation
 +
* Provides affordable (less than $100), low-power, and mini-sized solution
 +
* Capable of near-continuous measurements
 +
* Designed for field deployment in stormwater systems (work in progress)
 +
<br><br><br><br>
 +
== Methodology ==
 +
=== Image Acquisition ===
 +
The core of the PSD sensor is the [[BoSLcam|BoSLCam]], a self-developed camera logger. Key features of the BoSLCam include:
  
'''Camera'''
+
* Custom-designed PCB measuring 70 mm by 15 mm
 +
* Powered by a single 3.7V Li-ion battery
 +
* OV7675 colour camera module capable of capturing VGA (640x480) resolution images
 +
* nRF9160 chip for main microcontroller functions and LTE-M1 cellular connectivity
 +
* GPS location and time data acquisition capability
 +
* 23LCV1024 SRAM buffer for image data processing
 +
* SD card storage for captured images, and SIM card capability to upload images to FTP servers
 +
* Power-efficient design with sleep mode reducing current consumption to less than 400 µA
 +
* UART port for communication with external sensors and dataloggers
  
[https://www.arducam.com/ov2640/ OmniVision OV2640 Camera], 640*480, JPG output, default camera settings (automatic exposure, gain, and white balance), lens not changed. The camera is connected to a [https://www.arducam.com/product/b0051b0011-arducam-f-shield-v2-camera-module-shield-with-ov2640-for-arduino-uno-mega2560-due/ ArduCAM Arduino Shield] which is compatible with the Arduino Mega board. The board is set up using ArduCAM's [https://github.com/ArduCAM/Arduino/tree/master/ArduCAM Arduino Library]. When taking images, the Arduino Mega is connected directly to the PC, and the images are sent and saved on the PC directly, for now.
+
=== Image Processing ===
 +
[[File:PSD image processing steps.png|thumb|right|300px|Image processing steps of a 75-90µm sample. (a) Original image captured by BoSLCam, (b) converted grayscale image, (c) image treated by Fourier Transform and high-pass filter, (d) binary mask created after applying threshold.]]
 +
The image processing workflow consists of the following detailed steps:
  
[[File:Turb sensor lab experiment setup 1.jpg|thumb|Camera Turbidity Sensor Lab Experiment Setup]]
+
==== 1. Image Pre-Processing ====
'''Turbidity Solution'''
+
# RGB to Grayscale Conversion:
 +
#* The RGB image is converted to grayscale using the following equation:
 +
#*: <code>Grayscale = 0.299 × Red + 0.587 × Green + 0.114 × Blue</code>
 +
#* This equation is commonly used in camera-based measurement of turbidity.
 +
# Fourier Transform and High-Pass Filter:
 +
#* A Fast Fourier Transform (FFT) is applied to convert the image from the spatial domain to the frequency domain.
 +
#* A high-pass filter with a cutoff frequency of 2 is used to mitigate background noise and enhance image contrast.
 +
#* The process involves:
 +
## Applying 2D Fourier transform to the grayscale image
 +
## Shifting the zero-frequency component to the center of the spectrum
 +
## Creating a high-pass filter mask
 +
## Applying the mask to the shifted Fourier transform
 +
## Performing inverse Fourier transform to obtain the filtered image
  
The tap water is mixed with natural silts to create the synthetic solution. The turbidity value ranges from 0 to 639 NTU in this experiment.
+
==== 2. Image Segmentation (Thresholding) ====
 +
# Threshold Determination:
 +
#* A threshold grayscale value of 241 was determined to be adequate for the BoSLCam sample images.
 +
#* This threshold distinguishes pixels representing particles (darker) from the background (brighter).
 +
# Binary Image Creation:
 +
#* The grayscale image is converted to a binary image where:
 +
#** 1 represents particle (foreground)
 +
#** 0 represents background
  
'''Methods'''
+
==== 3. Feature Extraction ====
 +
# Connected Component Labelling:
 +
#* 8-connectivity is used to perform connected component labelling on the binary image.
 +
#* This process identifies and labels patches of pixels that are grouped together, representing individual particles.
 +
# Particle Size Estimation:
 +
#* For each labeled pixel patch (particle):
 +
## The pixel size is multiplied by the theoretical area-per-pixel value (e.g., 30x30µm for BoSLCam).
 +
## Assuming spherical particles, the equivalent spherical diameter is calculated.
 +
## Particle surface area and volume are also calculated based on this diameter.
  
First, put the synthetic turbidity solution into the 3d-printed black container, after measuring the actual turbidity (in the unit of NTU) using the Thermo Fisher turbidity meter. Then, light up the LED (from the top hole of the container lid) and take images (from the side window) of the solution at a 90-degree angle. This light scattering method is a common method used for turbidity measurement. Generally, when the water is more turbid, the increased particles in the water scatter more light beams in directions other than the straight direction, hence the light intensity received from the side directions (such as 90 degrees) will increase. The RGB (red, green, and blue) values of each pixel of the images are obtained using python script and converted into a single value - grayscale (0 - 255, completely black to completely white) using the Luma formula (Y = 0.299R + 0.587G + 0.114B). The average grayscale value of all pixels of each photo is calculated. Finally, plot the relationship between the average grayscale value of each image and its corresponding solution turbidity.
+
==== 4. Data Cleaning and Preparation ====
 +
* Particles larger than 500 µm (exceeding the proposed detection range) are excluded.
 +
* Histogram bins containing fewer than 2 particle counts are removed to mitigate potential noise effects, such as those caused by bubbles.
  
'''Results'''
+
=== PSD Analysis ===
 +
The sensor produces the following outputs:
 +
* Number-based (count-based) and volume-weighted particle size distribution histograms
 +
* Cumulative distribution curves
 +
* Statistical parameters such as D10, D50 (median diameter), and D90
  
[[File:20220708 Experiment result 1.png|500px|thumb|none|Results of the 1st Experiment]]
+
== Validation Results ==
 +
Laboratory validation tests were conducted to assess the performance of the PSD Sensor against traditional laboratory analysis methods. The tests used standard particles of various sizes ranging from 38 to 355 µm, providing a comprehensive evaluation across different size ranges relevant to stormwater sediment analysis.
  
As shown in the plot, there is a linear relationship between the log(NTU) and average grayscale, with the squared-R = 0.8726. However, this result is not good at all, as the grayscale values almost plateau when the turbidity values go above 100 NTU. This may be attributed to the strength of the LED. To be more specific, the light intensity of the LED is too strong, hence when the turbidity reaches a certain value (more than 100 in this case), the particles in the water have already scattered too much light that the camera is not able to handle. Therefore, in future experiments, the LED intensity should be lowered. Another issue of this experiment is that the silts are so heavy that they settle down very quickly, thus the actual turbidity of the solution may also change quickly. Moreover, the container design should be improved so that the camera can be placed in a relatively fixed position near the "window".
+
=== Experimental Setup ===
 +
The laboratory validation test setup, as shown in Figure 1, consisted of the following components:
 +
* A 3D-printed black, closed container with an openable lid for sample changing
 +
* An LED backlight module (white, 3.3V, 20mA, 110cd/m²) at the bottom of the container
 +
* A clear acrylic plate above the LED module to hold a shallow depth (<5 mm) of water sample
 +
* The BoSLCam coupled with a 25x macro lens, mounted on top of the container
 +
* The shallow sample depth was chosen to prevent particle overlapping and minimize distance-related distortions
  
===10 August 2022===
+
=== Standard Particles and Sample Preparation ===
The second experiment with a great number of changes.
+
The following standard particle size ranges were used in the validation tests:
 +
* 38-45 µm
 +
* 53-63 µm
 +
* 75-90 µm
 +
* 125-150 µm
 +
* 300-355 µm
  
'''Camera'''
+
Samples were prepared using deionized (DI) water dosed with these artificial particles. To ensure proper dispersion of hydrophobic particles, surfactant and anti-foam agents were added to the samples.
  
Camera changed to [https://www.arducam.com/products/camera-breakout-board/0-3mp-ov7675/ OmniVision OV7675 Camera] for better documentation, size changed to 320*240, format changed to BMP output, camera setting changed (automatic exposure, gain, and white balance are disabled), lens not changed. The connection and software of the new camera remain the same as previous one.
+
=== Comparison with Laboratory Analyzer ===
 +
The PSD Sensor's performance was evaluated against the Accusizer 780 (Entegris), a traditional laboratory particle sizing system. The comparison revealed:
  
'''Turbidity Solution'''
+
* Strong correlations (R² > 0.99) between the two methods for key PSD parameters (volume-weighted D10, D50, and D90)
 +
* Consistent performance across various particle sizes, with some systematic differences:
 +
** Slight overestimation for particles smaller than 50 µm
 +
** Accurate measurements for mid-range particles (50-300 µm)
 +
** Some underestimation for particles larger than 300 µm
  
To overcome the problem that the settlement of turbidity particles is too fast, the standard turbidity solution is used this time. 4000 NTU Formazin turbidity standard solution and DI water are used to make standard solutions with the following turbidity values: 0 (pure water), 25, 50, 75, 100, 200, 300, and 400 NTU. The actual turbidity of each solution is measured and differs from the "standard value". The actual turbidity values are used in the plotting.
+
Figure 2 demonstrates this performance using a 75-90 µm sample, showing similar histogram shapes and peak locations in the volume-weighted particle size distribution and cumulative distribution plots for both methods.
  
'''Methods'''
+
Figure 3 further illustrates the correlation between the PSD Sensor and Accusizer 780A measurements across all tested size ranges. The graph shows strong linear relationships for D10 (red), D50 (blue), and D90 (green) values, with slopes around 0.70-0.75.
  
Most of the processes remain the same with the following few exceptions. (1) The 3d-printed container design is improved, so the camera can be placed in a relatively fixed position. (2) In the previous experiment, the software provided in the ArduCAM library is used to take and save images. But this time a Python script is used to obtain the images, hence we can set the image format to bitmap (BMP). (3) Most importantly, the [https://www.jaycar.com.au/white-5mm-led-4000mcd-round-clear/p/ZD0190 white LED] used for the experiment is tested with 3 resistors (20, 470, and 4700 ohms) which can provide different levels of light intensity (strong, moderate, and weak).
+
=== Performance Considerations ===
 +
While the PSD Sensor showed excellent overall performance, some limitations were observed:
  
'''Results'''
+
* The slight overestimation for smaller particles (<50 µm) is likely due to the current image resolution and quality limitations of the BoSLCam
<gallery>
+
* The underestimation for larger particles (>300 µm) may be partially attributed to the upper detection limit of the Accusizer 780, rather than solely a limitation of the PSD Sensor
20220810 Experiment Result 1.png|1. All Data Points
 
20220810 Experiment Result 2.png|2. High Intensity - all data
 
20220810 Experiment Result 3.png|3. High Intensity - excluding 1 NTU
 
20220810 Experiment Result 4.png|4. Moderate Intensity - excluding 400 NTU
 
20220810 Experiment Result 5.png|5. Moderate Intensity - range 0-100 NTU
 
20220810 Experiment Result 6.png|6. Low Intensity - all data
 
20220810 Experiment Result 7.png|7. Low Intensity - range 100-400 NTU
 
</gallery>
 
High Intensity: If we look at the turbidity estimation ranging from 0 to 400 NTU, the LED with full brightness is not ideal, as there is no correlation found. However, the hypothesis is that high-intensity LED may be useful when the turbidity is in a low range, and the strong scattered light may be sensitive to the change of turbidity in that range. Further experiments are needed to test this hypothesis.
 
 
 
Moderate Intensity: The average grayscale values for 300 and 400 NTU are almost the same, the assumption is that the detection limit is also reached for this level of LED intensity. Excluding 400 NTU, we are able to find a good linear relationship (R2 = 0.9837). And surprisingly, the range below 100 NTU shows a nearly perfect linear relationship (R2 = 0.9994).
 
 
 
Low Intensity: Although the images taken are extremely dark and I could not distinguish them using naked eyes, the linear relationship looks not bad (R2 = 0.9641). It appears that the linear relationship for the NTU ranging above 100 looks better (R2 = 0.9891). A consistent hypothesis is that, with the low LED intensity, the camera may be able to estimate the very turbid solutions. Further experiments are needed to test beyond 400 NTU.
 
 
 
===19 August 2022===
 
The completely replication of the previous experiment.
 
 
 
'''Camera'''
 
 
 
Same as the previous experiment.
 
 
 
'''Turbidity Solution'''
 
 
 
Same as the previous experiment. The turbidity solution is the one used in the previous experiment, but the actual turbidity values are all re-measured.
 
 
 
'''Methods'''
 
 
 
Same as the previous experiment.
 
  
'''Results'''
+
These findings highlight areas for future optimization, particularly in improving resolution for smaller particles and extending the accurate measurement range for larger particles.
  
 
<gallery>
 
<gallery>
20220819 Experiment Result 1.png|1. Comparison between Two Experiment Results
+
File:PSD sensor lab test setup.png|Figure 1: Laboratory validation test setup for image acquisition.  
20220819 Experiment Result 2.png|2. Combination of Two Experiment Results
+
File:PSD results comparison example.png|Figure 2: Comparison example: volume-weighted particle size distribution and cumulative distribution plots for a 75-90µm sample analysed by (a) Accusizer 780A, and (b) proposed PSD sensor.
20220819 Experiment Result 3.png|3. Moderate Intensity - range 0-100 NTU
+
File:PSD results D-values comparison.png|Figure 3: Comparison and linear relationships of the averaged volume-weighted D10, D50, and D90 reported by the proposed PSD sensor and Accusizer 780A. Red: D10, blue: D50, green: D90.
Turb sensor lab experiment setup 1.jpg|4. Experiment Setup
 
 
</gallery>
 
</gallery>
The results are very consistent with the previous one and prove the repeatability of the experiment. The squared-R values of the linear relationships in this experiment are slightly decreased, but the decrease is not significant. Nevertheless, the moderate-intensity LED shows a nearly perfect linear relationship for the turbidity values ranging from 0 to 100 NTU, again.
 
  
These two experiments are conducted based on the standard turbidity solutions to avoid the issue of fast settling of the particles, but this is only a temporary solution to the issue. In the subsequent experiments, I will change the solution back to the synthetic solutions, while trying to make the measurement more accurate.
+
== Future Work ==
 +
Planned improvements and future research directions include:
 +
* Trialing a 100x microscopy lens to improve measurement accuracy for smaller particles
 +
* Optimizing the image processing algorithm and calibration method
 +
* Investigating the underestimation issue for larger particle sizes
 +
* Developing a field-ready sensor and testing with real-world stormwater samples
 +
* Exploring machine learning algorithms for improved particle detection
 +
* Investigating simultaneous measurement of other water quality parameters such as turbidity and TSS
  
===22 August 2022===
+
== References ==
 +
For a complete list of references, please refer to the original research paper (currently not available, but contact Canwei if you are interested).
 +
A presentation slide on this PSD sensor is avilable at: https://docs.google.com/presentation/d/1nz9B4ax-7Trgf9BWI-0MAw2LRiOo3SrO/edit?usp=sharing&ouid=118015437923291707850&rtpof=true&sd=true

Latest revision as of 02:07, 2 October 2024

Introduction

The PSD Sensor is a novel, low-cost camera-based sensor designed for near-continuous in-situ measurements of Particle Size Distribution (PSD) in stormwater. This sensor addresses the limitations of traditional PSD measurement methods, which are often expensive, labour-intensive, or unable to provide real-time data.

Key Features

Front and back of BoSLCam. Orange: OV7575 camera module, light blue: SIM card slot, yellow: UART connection, grey: battery connector, dark blue: LTE and GPS antenna, red: nRF9160, purple: 23LCV1024 SRAM chip, mint: SD card slot.
  • Utilizes a self-developed and highly customised compact camera with a 25x macro lens
  • Employs image processing techniques for particle size estimation
  • Provides affordable (less than $100), low-power, and mini-sized solution
  • Capable of near-continuous measurements
  • Designed for field deployment in stormwater systems (work in progress)





Methodology

Image Acquisition

The core of the PSD sensor is the BoSLCam, a self-developed camera logger. Key features of the BoSLCam include:

  • Custom-designed PCB measuring 70 mm by 15 mm
  • Powered by a single 3.7V Li-ion battery
  • OV7675 colour camera module capable of capturing VGA (640x480) resolution images
  • nRF9160 chip for main microcontroller functions and LTE-M1 cellular connectivity
  • GPS location and time data acquisition capability
  • 23LCV1024 SRAM buffer for image data processing
  • SD card storage for captured images, and SIM card capability to upload images to FTP servers
  • Power-efficient design with sleep mode reducing current consumption to less than 400 µA
  • UART port for communication with external sensors and dataloggers

Image Processing

Image processing steps of a 75-90µm sample. (a) Original image captured by BoSLCam, (b) converted grayscale image, (c) image treated by Fourier Transform and high-pass filter, (d) binary mask created after applying threshold.

The image processing workflow consists of the following detailed steps:

1. Image Pre-Processing

  1. RGB to Grayscale Conversion:
    • The RGB image is converted to grayscale using the following equation:
      Grayscale = 0.299 × Red + 0.587 × Green + 0.114 × Blue
    • This equation is commonly used in camera-based measurement of turbidity.
  2. Fourier Transform and High-Pass Filter:
    • A Fast Fourier Transform (FFT) is applied to convert the image from the spatial domain to the frequency domain.
    • A high-pass filter with a cutoff frequency of 2 is used to mitigate background noise and enhance image contrast.
    • The process involves:
    1. Applying 2D Fourier transform to the grayscale image
    2. Shifting the zero-frequency component to the center of the spectrum
    3. Creating a high-pass filter mask
    4. Applying the mask to the shifted Fourier transform
    5. Performing inverse Fourier transform to obtain the filtered image

2. Image Segmentation (Thresholding)

  1. Threshold Determination:
    • A threshold grayscale value of 241 was determined to be adequate for the BoSLCam sample images.
    • This threshold distinguishes pixels representing particles (darker) from the background (brighter).
  2. Binary Image Creation:
    • The grayscale image is converted to a binary image where:
      • 1 represents particle (foreground)
      • 0 represents background

3. Feature Extraction

  1. Connected Component Labelling:
    • 8-connectivity is used to perform connected component labelling on the binary image.
    • This process identifies and labels patches of pixels that are grouped together, representing individual particles.
  2. Particle Size Estimation:
    • For each labeled pixel patch (particle):
    1. The pixel size is multiplied by the theoretical area-per-pixel value (e.g., 30x30µm for BoSLCam).
    2. Assuming spherical particles, the equivalent spherical diameter is calculated.
    3. Particle surface area and volume are also calculated based on this diameter.

4. Data Cleaning and Preparation

  • Particles larger than 500 µm (exceeding the proposed detection range) are excluded.
  • Histogram bins containing fewer than 2 particle counts are removed to mitigate potential noise effects, such as those caused by bubbles.

PSD Analysis

The sensor produces the following outputs:

  • Number-based (count-based) and volume-weighted particle size distribution histograms
  • Cumulative distribution curves
  • Statistical parameters such as D10, D50 (median diameter), and D90

Validation Results

Laboratory validation tests were conducted to assess the performance of the PSD Sensor against traditional laboratory analysis methods. The tests used standard particles of various sizes ranging from 38 to 355 µm, providing a comprehensive evaluation across different size ranges relevant to stormwater sediment analysis.

Experimental Setup

The laboratory validation test setup, as shown in Figure 1, consisted of the following components:

  • A 3D-printed black, closed container with an openable lid for sample changing
  • An LED backlight module (white, 3.3V, 20mA, 110cd/m²) at the bottom of the container
  • A clear acrylic plate above the LED module to hold a shallow depth (<5 mm) of water sample
  • The BoSLCam coupled with a 25x macro lens, mounted on top of the container
  • The shallow sample depth was chosen to prevent particle overlapping and minimize distance-related distortions

Standard Particles and Sample Preparation

The following standard particle size ranges were used in the validation tests:

  • 38-45 µm
  • 53-63 µm
  • 75-90 µm
  • 125-150 µm
  • 300-355 µm

Samples were prepared using deionized (DI) water dosed with these artificial particles. To ensure proper dispersion of hydrophobic particles, surfactant and anti-foam agents were added to the samples.

Comparison with Laboratory Analyzer

The PSD Sensor's performance was evaluated against the Accusizer 780 (Entegris), a traditional laboratory particle sizing system. The comparison revealed:

  • Strong correlations (R² > 0.99) between the two methods for key PSD parameters (volume-weighted D10, D50, and D90)
  • Consistent performance across various particle sizes, with some systematic differences:
    • Slight overestimation for particles smaller than 50 µm
    • Accurate measurements for mid-range particles (50-300 µm)
    • Some underestimation for particles larger than 300 µm

Figure 2 demonstrates this performance using a 75-90 µm sample, showing similar histogram shapes and peak locations in the volume-weighted particle size distribution and cumulative distribution plots for both methods.

Figure 3 further illustrates the correlation between the PSD Sensor and Accusizer 780A measurements across all tested size ranges. The graph shows strong linear relationships for D10 (red), D50 (blue), and D90 (green) values, with slopes around 0.70-0.75.

Performance Considerations

While the PSD Sensor showed excellent overall performance, some limitations were observed:

  • The slight overestimation for smaller particles (<50 µm) is likely due to the current image resolution and quality limitations of the BoSLCam
  • The underestimation for larger particles (>300 µm) may be partially attributed to the upper detection limit of the Accusizer 780, rather than solely a limitation of the PSD Sensor

These findings highlight areas for future optimization, particularly in improving resolution for smaller particles and extending the accurate measurement range for larger particles.

Future Work

Planned improvements and future research directions include:

  • Trialing a 100x microscopy lens to improve measurement accuracy for smaller particles
  • Optimizing the image processing algorithm and calibration method
  • Investigating the underestimation issue for larger particle sizes
  • Developing a field-ready sensor and testing with real-world stormwater samples
  • Exploring machine learning algorithms for improved particle detection
  • Investigating simultaneous measurement of other water quality parameters such as turbidity and TSS

References

For a complete list of references, please refer to the original research paper (currently not available, but contact Canwei if you are interested). A presentation slide on this PSD sensor is avilable at: https://docs.google.com/presentation/d/1nz9B4ax-7Trgf9BWI-0MAw2LRiOo3SrO/edit?usp=sharing&ouid=118015437923291707850&rtpof=true&sd=true