Image Processing: Counting Lines in a Range of Angles
6 views (last 30 days)
Show older comments
Hi,
I'm working on a problem right now that involves a method to automate scanning drill core data from a mining property and identifying volume of vein and the angle at which the vein crosses the core axis.
With help from this forum and online, I've gone from the original image to the cleaned image. The cleaned image identifies the veins in the photo quite well.
If possible, it would be great if I could remove the rectangular sample tags and mini whiteboard. This step isn't completely necessary.
The main thing that I now need to do is somehow measure the angle of the veins to horizontal. I need to fit these objects with a line then identify lines between say 15 and 75 degrees (I don't want horizontal or vertical lines). Once they're identified, I need to record the angle to horizontal and count the number of them.
I'm trying to use the hough transform, houghpeaks and houghlines functions but it seems to be only grabbing the long, horizontal lines.
Thanks
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/145102/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/145103/image.jpeg)
0 Comments
Accepted Answer
Amir
on 14 Aug 2014
Edited: Amir
on 14 Aug 2014
Hi Cole. Please try this code. I hope it can give you some ideas
clc
clear all
close all
[filename, pathname] = uigetfile('*','File Selector');
I = imread(strcat(pathname,'\',filename)); % for example FileName='MyImage.jpg'
I=im2bw(I);
BW = edge(I,'canny',0.1);
[bw, loc2]= imfill(BW,'holes');
% http://www.mathworks.co.uk/help/images/ref/regionprops.html
rp = regionprops(bw,'All'); % you can specify the parameters which you need
ObjOrient=zeros(size(rp,1),1);
CenterX=zeros(size(rp,1),1);
CenterY=zeros(size(rp,1),1);
for i=1:size(rp,1)
ObjOrient(i)=rp(i).Orientation;
CenterX (i)= rp(i).Centroid(1);
CenterY (i)= rp(i).Centroid(2);
% you can other properties (for example area, perimeter etc here)
end
Final=[ObjOrient CenterX CenterY];
imshow(I);
hold on
for i=1:size(Final,1)
text(Final(i,2),Final(i,3),num2str(Final(i,1)),...
'HorizontalAlignment' , 'center',...
'VerticalAlignment' , 'middle');
end
title('Coordination of Particles - between -90 and +90');
figure
hist(Final(:,1));
title('Histogram');
xlabel('Angle - Degree');
ylabel('Number of objects');
4 Comments
Amir
on 21 Aug 2014
Edited: Amir
on 21 Aug 2014
Hi Cole Sorry for delay. I wanted to think about this and write a code (if I can) for you. But these days I am very busy and couldn't find any free time to think about this. I think you need to combine object detection (code above) with the colour detection. i.e. for those objects which have -5<orientation <5 (horizontal)find the colour histogram of ORIGINAL image and if white colour is dominant then you can say most likely that object is a label. Hope this helps.
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!