Clear Filters
Clear Filters

How can I find the droplet contact angle of the image using hough transform to determine the boundaries? The code gives me droplet contact angle 0. But I want to calculate the angle the contact surface makes with the bubble.

1 view (last 30 days)
Irgb = imread('hydrophobe1.jpg'); Igray = rgb2gray(Irgb); BW = edge(Igray,'canny'); [H,theta,rho] = hough(BW);
figure; imshow(imadjust(mat2gray(H)),[],... 'XData',theta,... 'YData',rho,... 'initialmagnification','fit'); colormap(gca,hot);
P = houghpeaks(H,5,'threshold',ceil(.7*max(H(:))));
lines = houghlines(BW,theta,rho,P,'Fillgap',5,'Minlength',7); figure, imshow(Igray), hold on max_len = 0; for k = 1:length(lines); xy = [lines(k).point1; lines(k).point2]; plot(xy(:,1),xy(:,2),'linewidth',2,'color','green');
plot(xy(1,1),xy(1,2),'x','linewidth',2,'color','green');
plot(xy(2,1),xy(2,2),'x','linewidth',2,'color','red');
len = norm(lines(k).point1 - lines(k).point2);
if (len > max_len)
max_len = len;
xy_long = xy;
end
end
plot(xy_long(:,1),xy_long(:,2),'Linewidth',2,'Color','Red');
x1 = xy_long(1); x2 = xy_long(2); x3 = xy(1); x4 = xy(2);
y1 = xy_long(3); y2 = xy_long(4); y3 = xy(3); y4 = xy(4);
theta1 = atan((y1-y2)/(x1-x2)) theta2 = atan((y3-y4)/(x3-x4)) ThetaFinal = abs((theta1-theta2)*(180/pi)
  1 Comment
Image Analyst
Image Analyst on 11 Jul 2017
What is the difference in your mind between the "contact angle" (which you say your code computes) and the "angle the contact surface makes with the bubble" (which you say you need)??? Please attach diagram with lines and angles indicated on it. Read this too.

Sign in to comment.

Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!