I am working on a project where I need to measure the water level using a white-caliber panel. Currently my approach is:
- segmentation of a white caliber board.
- Measure the water level at the level of the calibration plate.
But I'm stuck in segmenting the meter board. I avoid using color-based segmentation since I need it to be invariant to light changes, so I detect edges using morphological operations. I have this image:


The result of morphological operations seems promising. The edges on the white-caliber panel are sharper than the others. But I still donβt know how to segment a board correctly. Can you suggest a board segmentation algorithm? Or ask if you have another algorithm for measuring water level.
Here is my code:
#include <opencv2/imgproc/imgproc.hpp> #include <opencv2/highgui/highgui.hpp> #include <iostream> int main() { cv::Mat src = cv::imread("image.jpg"); if (!src.data) return -1; cv::Mat bw; cv::cvtColor(src, bw, CV_BGR2GRAY); cv::medianBlur(bw, bw, 3); cv::Mat dilated, eroded; cv::dilate(bw, dilated, cv::Mat()); cv::erode(bw, eroded, cv::Mat()); bw = dilated - eroded; cv::imshow("src", src); cv::imshow("bw", bw); cv::waitKey(); return 0; }
I use C ++, but I am open to other implementations in Matlab / Mathematica.
source share