Microfluidics Gradient Analyzer
TL;DR
Microfluidics Gradient Analyzer is a comprehensive pipeline written in R that includes two separate methods to quantify laminar flow in microfluidic devices under different flow rates.
The first method includes using the magick:quantize function that the author utilized. The second method applies a Sobel-Kernel filter (commonly used in Edge-Detection systems) to quantify gradient, inspired by this paper.
💦 Laminar Flow
Typically, at R < 3000 (Reynold's number), fluids exhibit laminar flow. Essentially, this means that instead of the fluid flowing in a chaotic, circular motion in turbulent flow, the liquids "follow smooth paths in layers, with each layer moving smoothly past the adjacent layers with little or no mixing" (Wikipedia).
Method I - Quantize Detection System
This system utilizes the magick:quantize function to select the top 50 most prominent colors in any particular section of the microfluidics device where the gradient is most prominent.
palette <- image_quantize(img, max = 50, colorspace = "RGB")
The pixels are then extracted.
data <- image_data(palette, channels = "RGB")
Then the number of unique pixels are counted. The higher the number of unique pixels, the more gradual the gradient, which reflects a higher flow rate. If the pixels are very similar, it would mean that the gradient was very abrupt, indicating a higher flow rate.
Method II - Sobel-Kernel Detection System
This algorithm is a lot more comprehensive than the Quantize detection system. It includes steps for normalization, Sobel convolution, gradient calculation, non-maximum suppression, and graphing with quantitative metrics. This was modified based on this paper here.
Step 1: Image Normalization
In this step, the images were normalized in a three-part process.
The first part includes image scaling. Since the input images may have different x-values and y-values, they were all scaled to the same height (since height remains a more important factor of measure where vertical gradients are important).
The second part includes grey-scaling. By grey-scaling the image, we can better observe this gradient change from green to red. This also allows the third step to be conducted more easily.
The third part includes changing normalizing the illumination of the images, achieved through a function in the magick package.
Step 2: Sobel Convolution
The Sobel operator is a convolution filter commonly used in edge-detection systems.
Edge-detection systems usually work by taking the partial derivatives of the change in color intensity in the x- and y-direction to find the local maxima or minima, and defines that as an edge. Convolution filters allow the partial derivatives to be approximated through the intensity of neighboring pixels. The tangent of the y-partial derivative over the x-partial derivative could also be calculated to determine the gradient direction.
In our case, the3x3 Sobel convolution filterwas chosen.
Step 3: Non-maximum Suppression
Since the Sobel operator is applied on every pixel on the image, we would need to extract prominent "edges" that can be used to determine the gradient. Hence, we refined our edge (gradient) detection system by only keeping local maxima.
Step 4: Quantitative Metrics & Graphing
We quantified the gradient by calculating the number of edge pixels, which reflected the intensity of the gradient. A gradual gradient would have a higher number of pixels since there would be more transitions. A shaper gradient would only have a few number of edge pixels since there would only be one sharp transition. Graphing was done by comparing flow-rate against the number of edge pixels.
Additional Information
This project was developed for the Nanotechnology course at the Engineering Summer Academy at Penn summer program that I took during the summer of 2025.
More pictures and information will be added to this page as I slowly organize them.
Disclaimer
This pipeline was developed for educational purposes as part of the Engineering Summer Academy at Penn (summer 2025). Both methods are experimental and have known limitations.
This software is provided "as-is" without any warranty. Users are solely responsible for validating results for their specific applications. The author(s) are not liable for any errors, inaccuracies, or damages arising from the use of this software.
For critical research applications, please independently verify all measurements and consult established methodologies in the field.