Fiber detection Hough Transform

6 views (last 30 days)
Marta Martos Valverde
Marta Martos Valverde on 10 Oct 2022
Answered: Image Analyst on 10 Oct 2022
Hello,
I am a bit new to matlab, so probably my question is not even correctly formulated 😅
I want to detect the fiber angles in the attached microscopy image, but the image is made of SEM microgrpahs, so it does not have a good contrast between the fibers and their surrounding. I have tried to first threshold the image to emphasize the lines that delimit the fibers in order to use the Hough Transform to detect the lines. However, I do not seem to succeed in detecting all the lines or length segments.
Other things that I have tried: bwpropfil to try to remove the unwanted shapes (i.e. non linear shapes), edge to detect the edges of the image and perhaps highlight the lines; bwskel, etc.
I´m sure there are better ways to process the image to achieve this, so I would like to ask you what can I do to improve the line detection.
Thanks a lot in advance!!
clc; % Clear the command window.
clear all;
close all;
img = imread('Stitched end indent.png');
figure
imshow(img)
%% image corrrection:
imgBright = imlocalbrighten(img);
figure
imshow(imgBright)
imgHaze = imreducehaze(imgBright);
figure
imshow(imgHaze)
imgContrast = imadjust(imgHaze);
figure
imshow(imgContrast)
%Obtain maximum pixel intensity
maxDiff = max(max(imgContrast))
%% Thresholding and "cleaning" the image
thresholdValue = 130;
imgThresh = imgContrast < thresholdValue;
%imgThresh = imfill(imgThresh, 'holes');
figure
imshow(imgThresh)
imgThresh2 = imcomplement(imgThresh);
imgRemoved=bwareaopen(imgThresh2,30);
figure
imshow(imgRemoved)
%se = strel('line',3,5);
%imgDilate=imdilate(~imgRemoved,se);
%figure
%imshow(imgDilate)
%% Hough Transform on the image to identify lines
[H,theta,rho] = hough(imgRemoved);
peaks = houghpeaks(H,1000,'threshold',ceil(0.5*max(H(:))));
lines = houghlines(imgRemoved,theta,rho,peaks,'FillGap',5,'MinLength',30);
figure,imshow(imgRemoved),hold on
max_len=0;
for k=1:length(lines)
xy=[lines(k).point1;lines(k).point2];
plot(xy(:,1),xy(:,2),'Linewidth',1,'Color','green');
% %plot(xy(1,1),xy(1,2),'x','LineWidth',1,'Color','yellow');
% %plot(xy(2,1),xy(2,2),'x','LineWidth',1,'Color','red');
len=norm(lines(k).point1-lines(k).point2);
if (len>max_len)
max_len=len;
xy_long=xy;
end
end

Answers (2)

Image Analyst
Image Analyst on 10 Oct 2022
Try my attached demo.
You can see it gives a histogram of fiber angles plus an output image that is vastly superior to the original input image.

Benjamin Thompson
Benjamin Thompson on 10 Oct 2022
Very small and fine features. You might try the 2D FFT and see if this provides a better way to estimate rotation.

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!