Droplet Contact Angle Measurement

26 views (last 30 days)
Voon Loong
Voon Loong on 19 Aug 2012
Hi,
I am using the code below to generate the droplet image and measure the contact angle. After truncation, I only can get the subtrate image but not the actual droplet image i need. Can somebody help me to look into it?
Thanks you.
% Surface Tension Measurements Using the Pendant Drop Method
[filename, pathname] = ...
uigetfile({'*.jpg';'*.tif';'*.gif';'*.*'},'Select an image'); %Open standard dialog box for retrieving files
rgbImage = imread([pathname,filename]);
im = im2double(rgb2gray(rgbImage)); % Convert image to gray
imshow(im); % Display image
BW = im2bw(im);
L = bwlabeln(1-BW, 4); % Label White Spots
S = regionprops(L, 'Area'); % Measure Area of Spots
BW2 = ismember(L, find([S.Area] ==max( [S.Area]) )); % Find Largest Spot
BW2(1,:) = 1; % Turn First Row White
imshow(BW2);
figure(2);clf;
BW3 = imfill( BW2, 'holes' ); % Fill In Holes in Image
imshow(BW3);
[x_coordinates y_coordinates Pixel_vals] = impixel;
rot_line = polyfit(x_coordinates ,y_coordinates ,1 ); % Replicate Substrate
rot_point = round( polyval( rot_line, 1 )); % Truncation Point
rot_angle = atan( rot_line(1) ); % Correction Angle
BW4 = BW3( rot_point:end,: ); % Truncation
BW4 = imrotate( BW4, -rot_angle*180/pi ); % Correction
BW4 = BW4( -y_coordinates(2) + rot_point:end,: ); % Truncation Correction
imshow( BW4 ); % Display Image
Function_ContactAngleb([200 300], 250, BW4)
[val, status, message] = fminsearch( @(cntr_radius) ...
Function_ContactAngleb( cntr_radius(1:2), cntr_radius(3), BW4 ), ...
[200, 200, 100], optimset('display', 'iter' ) );
crcl = Function_ContactAngle( val(1:2), val(3), size(BW4) ); % Optimized Generated Circle
imagesc( 10*crcl+BW4 ); % Picture/Optimization Overlay
axis image; % Show axes
% Math manipulation to calculate contact points based on radius and
% location of the center of the circle
contact_pt = [ (sqrt( val(3)^2 - ( 1-val(1) )^2 ) + val(2)), ...
-(sqrt( val(3)^2 - ( 1-val(1) )^2 ) + val(2)) ];
% Determine tangent lines of contact points
tangent_slope = -( contact_pt-val(2) )/( 1-val(1) );
contact_angle = atan(tangent_slope); % Contact Angle
contact_angle = (contact_angle*180/pi); % Radians to Degrees
corrected_angle = [ mod( 180-contact_angle(1), 180 ),...
mod( 180+contact_angle(2), 180)]; % Correction for proper domain
return
%*******************************************************************************
% Finish Main Program
  2 Comments
Image Analyst
Image Analyst on 19 Aug 2012
And how can we do that? (Put yourself in our position and think a minute.)
Walter Roberson
Walter Roberson on 20 Aug 2012
... For example, is the cameraman image a suitable input?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 20 Aug 2012
Your array Function_ContactAngle is not initialized anywhere in the code you show.
The portion of your code starting at "Math manipulation" references the variable "val" which is previously unreferenced.
A reasonable hypothesis would be that the portion of your code starting at "Math manipulation" should be a function named Function_ContactAngle .
With regards to plotting not working as you expect, please read my graphics advice in http://www.mathworks.co.uk/matlabcentral/answers/22208-show-figure
  4 Comments
Voon Loong
Voon Loong on 21 Aug 2012
Edited: Walter Roberson on 21 Aug 2012
Hi,
Thanks for your reply.
I have a problem when I need to truncate the substrate in order to get my actual droplet especially when those droplet with reflection on the substrate. Is it the problem with the truncation?
[x_coordinates y_coordinates Pixel_vals] = impixel;
rot_line = polyfit(x_coordinates ,y_coordinates ,1 ); % Replicate Substrate
rot_point = round( polyval( rot_line, 1 )); % Truncation Point
rot_angle = atan( rot_line(1) ); % Correction Angle
BW4 = BW3( rot_point:end,: ); % Truncation
BW4 = imrotate( BW4, -rot_angle*180/pi ); % Correction
BW4 = BW4( -y_coordinates(2) + rot_point:end,: ); % Truncation Correction
imshow( BW4 ); % Display Image
Kind regards,
Voon Loong
Walter Roberson
Walter Roberson on 21 Aug 2012
I do not understand what you mean by "truncation" in this context?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!