Trying to identify directions of overlapping lines in images, at my wit's end

2 views (last 30 days)
Hello everyone,
I have a large number of thermographic pictures of carbon-fibre reinforced plastic parts. My task is to build a Matlab tool which will read the image and give me the orientation of the fibres in the image. So far, I can recognise the orientation in single layers, like the image on the left:
I get the image matrix variance along lines in -45, 0, 45, and 90 degree angles. The direction with the least variance is the direction the lines have.
However, that breaks down when I get images like the one on the right.
Other things I've tried:
  • Get the gradient image, do Hough analysis: Works on the first picture, but the edge detection doesn't recognise the diagonal lines in the second image.
  • Use parts from the first picture, manually add lines with known angle to the picture, compute the similarity between my altered 1st image and the second image: Flat out doesn't work at all, neither ssim nor normxcorr2 give a higher degree of correlation/similarity for pictures with lines in the correct angle
  • Use parts from the first picture, stretch the image via imdilate function: Same problem as above.
Right now I'm getting desperate, because I've done all I can think of, and my supervisor is not content.
If anyone has any ideas, I'd be very grateful!

Accepted Answer

J. Alex Lee
J. Alex Lee on 25 Feb 2020
Have you looked into radon transforms? You might get some "signal" at the 45 and 135 directions for the right image...
If these are just small samples of images over larger areas, maybe fft could give you spokes in the right directions
It looks like you may have artifacts of your camera lens or something that isn't doing you any favors, e.g., there's some kind of line that cuts across the bottom right corner of hte image at a 45 degree angle on both images...
  13 Comments
Korbi
Korbi on 4 Apr 2020
To investigate this, I compiled a simple test image, consisting of a couple of vertical lines (value 1) equidistant from each other, which I named 'testbild5.png'
I tried four Radon transforms, the three you already did, and one where I added a window, with the window2 function from [this] excellent window generator.
im = imread('testbild5.png');
if size(im,3)~=1
im=(rgb2gray(im));
else
im=(mat2gray(im));
end
figure;
imshow(im,[])
[x,y]=size(im);
offset = mean(im(:));
B=double(im-offset).*window2(x,y,@hann);
figure;
imshow(B,[]);
theta=[-90:89];
R2 = radon(im-offset,theta); % radon of zero-mean
[R0,Xp] = radon(im,theta); % radon of raw
R1 = R0./radon(ones(size(im)),theta); % mean radon
R3=radon(B,theta);
figure;
subplot(4,2,1); imagesc(theta,Xp,R0);
subplot(4,2,3); imagesc(theta,Xp,R1);
subplot(4,2,5); imagesc(theta,Xp,R2);
subplot(4,2,7); imagesc(theta,Xp,R3);
Radvar0=var(R0);
Radvar1=nanvar(R1);
Radvar2=var(R2);
Radvar3=var(R3);
subplot(4,2,2); plot(theta,Radvar0);
subplot(4,2,4); plot(theta,Radvar1);
subplot(4,2,6); plot(theta,Radvar2);
subplot(4,2,8); plot(theta,Radvar3);
The result looks like this:
As we can see, the windowing function does a little more to suppress the ripples, but it also takes away a lot of contrast. Variance is an order of magnitude lower that way. Thank you for the suggestion, Image Analyst, maybe with that change I can make visible the layer orientations from deeper layers, so far everything past the 3rd is lost in the noise.
Lee, your observation that normalize() works on only one dimension also explains why I was unable to normalize() my test image, since each row of that image is either one or zero.
Image Analyst
Image Analyst on 4 Apr 2020
Yes, the standard deviations of the columns will be higher when the lines area aligned with the projection angle. So you'd look for the column with the highest standard deviation to get the angle. Something like
% Get standard deviation of all columns in a 1-D row vector.
sdVec = std(Radvar, 1);
% Find out which column has the highest standard deviation.
[maxSD, column] = max(sdVec);
% Get the angle for that particular column.
angle = theta(column)
Make obvious adaptations (variable names, etc.)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!