Image Processing: Counting Lines in a Range of Angles
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Amir
2014-8-14
编辑:Amir
2014-8-14
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 个评论
Amir
2014-8-21
编辑:Amir
2014-8-21
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Computer Vision with Simulink 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!