Geoscience Reference
In-Depth Information
lines1 = houghlines(I4,theta,rho,peaks(1:5,:));
lines2 = houghlines(I4,theta,rho,peaks(6:10,:));
lines3 = houghlines(I4,theta,rho,peaks(11:15,:));
We then display the Hough transform and mark the 15 maxima of the Hough
transform with blue squares.
imshow(imadjust(mat2gray(H)),[], ...
'XData',theta, ...
'YData',rho, ...
'InitialMagnification','fit')
colormap(hot), axis square, hold on
plot(theta(peaks(:,2)),rho(peaks(:,1)), ...
'LineStyle','none', ...
'Marker','s', ...
'Color','b')
xlabel('\theta')
ylabel('\rho')
title('Hough Transform')
h e variables
lines1
,
lines2
and
lines3
can now be used to display the
lines on the image, with the line thickness decreasing from
lines3
to
lines1
depending on the rank of the lines in the Hough transform.
imshow(I1,'InitialMagnification',30), hold on
for k = 1:length(lines1)
xy = [lines1(k).point1; lines1(k).point2];
plot(xy(:,1),xy(:,2),'LineWidth',3,'Color',[1 0 0]);
end
hold on
for k = 1:length(lines2)
xy = [lines2(k).point1; lines2(k).point2];
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color',[1 0 0]);
end
for k = 1:length(lines3)
xy = [lines3(k).point1; lines3(k).point2];
plot(xy(:,1),xy(:,2),'LineWidth',1,'Color',[1 0 0]);
end
h e result shows that the clearly recognizable white layers are well detected
whereas the less pronounced layers are not identii ed. h e method also
mistakenly marks non-existing lines on the image because of the low
quality of the image. Using a better quality image and carefully adjusting the
parameters used with the Hough transform will yield better results.
In the second example the Hough transform is used to automatically
count pollen grains in a microscope image of Argentine honey (Fig. 8.13).
h e quality of the image is again not perfect, which is why we can not expect
optimum results. In particular, the image of three-dimensional objects was
taken with a very large magnii cation, so it is slightly blurred. We i rst read
the pollen image and store it in the variable
I1
. h e size of the image is 968-