How to draw line in the image through the image processing

After conducting the evaporator viusalization experiment, want to procced image processing by matlab and found out boundary line between liquid refrigerant and vapor refrigerant. I have tried it with binarize and threshold but didnt get any satisfying result.
here shows my code and the current problem is that i cant get any clear boundary as i can see in the picture with own eyes.
i'd like to ask for some advice to get through this problem

6 Comments

I'd recommend using the sobel or canny filter (https://www.mathworks.com/discovery/edge-detection.html).
The liquid is inside the tube, right? If so, does the liquid level varies too much? If it does not, then it would be better to align the camera to the average liquid level (transforming the water plane touching the tube into a solid line if possible). If the variation is too high, then maybe a ruler behind the tube would help (or a paper with markers). I also recommend trying to remove unnecessary lights and reflections from the tube (they are not helping): adding some diffuse material on the ceiling and ground planes would probably help.
The following result was obtained by using Sobel -> Dilation (x2) -> Color Levels (in Gimp).
Really appreciate for your help. It will be probably helpful to make some ruler or paper with markers behind the tube, also It will be better to remove unnecessary lights and reflections but it is currently limited to change the experimental apparatus.
So Just in case if we have to proceed the image processing with this way, may i ask you for the code that you have made to analyze that image?
Having some problem with dilation and color levels.
Can you post an image with a red line drawn where you think the boundary between liquid and vapor are? Because with dozens of possible horizontal and vertical lines, I'm not sure which one you are looking at.
here is the image which i want to get from the image processing
Can you use polarizers in front of your light and your camera? Rotate the one in front of the camera lens until all the spurious reflections are eliminated. It will be much easier to process without all those reflections in there.
currently is it limited to eliminate the reflections due to the refrigerator's size and other spatial narrowness.
there is no other way but to proceed the image processing with these reflections.

Sign in to comment.

 Accepted Answer

Glad to help. I've obtained that image using the Gimp editor, but, it is possible to achieve a similar result in Matlab with:
image = imread("myImage.jpeg");
A = imadjust(image, [0.2 0.8]); % adjusting color levels to enhance the image
M = edge(A(:,:,1), 'sobel') | edge(A(:,:,2), 'sobel') | edge(A(:,:,3), 'sobel'); % sobel to detect edges
N = imdilate(M,ones(5)); % dilate to obtain wider edges
O = bwareaopen(N, 1000); % to remove elements with pixel area smaller than 1000 pixels
imshowpair(image,O,'montage')
I've looked at the image histogram and used the imtool for deciding the previous parameters. The result is the following (you could try adjusting the parameters of any of these functions for obtaining a better result):

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!