MATLAB: Need help to remove the intersecting point from fiber

computer visionimage processing

Trying to find the diameter of fibers by fitting circle. But need to remove the intersecting point from fibers to get more accurate result. Here is the image
<<fiber>>
image.
<<
>>
want to get this kind of image after removing the intersecting point from the skeleton. How can I do that? Please need valuable suggestion.

Best Answer

Start with something like this:
%===============================================================================

% Get the name of the image the user wants to use.
baseFileName = 'fiber.png'; % Assign the one on the button that they clicked on.
% Get the full filename, with path prepended.
folder = pwd; % Determine where demo folder is (works with all versions).
fullFileName = fullfile(folder, baseFileName);
%===============================================================================
% Read in a demo image.
grayImage = imread(fullFileName);
% Get the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(grayImage);
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
% Use weighted sum of ALL channels to create a gray scale image.
grayImage = rgb2gray(grayImage);
% ALTERNATE METHOD: Convert it to gray scale by taking only the green channel,
% which in a typical snapshot will be the least noisy channel.
% grayImage = grayImage(:, :, 2); % Take green channel.
end
% Display the image.
subplot(2, 3, 1);
imshow(grayImage, []);
axis on;
caption = sprintf('Gray Image');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
hp = impixelinfo();
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
drawnow;
% binarize the image
binaryImage = grayImage > 128;
subplot(2, 3, 2);
imshow(binaryImage);
% Get the skeleton.
skelImage = bwmorph(binaryImage, 'skel', inf);
subplot(2, 3, 3);
imshow(skelImage);
% Get the crossings.
crossings = bwmorph(skelImage, 'branchpoints');
subplot(2, 3, 4);
imshow(crossings);
% Dilate the points
se = strel('disk', 13, 0);
crossings = imdilate(crossings, se);
subplot(2, 3, 5);
imshow(crossings);
% Mask the original
finalImage = skelImage; % Initialize
finalImage(crossings) = false;
subplot(2, 3, 6);
imshow(finalImage);