Image Analysis: measuring cusping and roughness
조회 수: 6 (최근 30일)
이전 댓글 표시
Dear All,
I am looking for a solution for the following problem. Please refer the image below.
A straight line was drawn though the mid-axis each of the black laths as shown. Lines perpendicular to this axial line were drawn to the peaks and valleys of the black laths.The height difference between peaks and valleys is defined as the roughness. The spacing between the valleys is defined as a measure of cusp spacing. Right now I am doing it manually and its subjective to lots of errors. Please suggest a way by which I can automate this process. ( ie findout the hight difference and spacing between an area of selected peaks and vallieys.
댓글 수: 1
Image Analyst
2011년 10월 31일
Funny. Two authors in one night posting the same questions as if for the first time when there had already been a discussion of the same topic weeks earlier:
http://www.mathworks.com/matlabcentral/answers/16296-image-analysis-finding-the-cusp-spacing
채택된 답변
Sven
2011년 10월 31일
Here's how I would approach it:
% Read the image and convert to BW mask of peaks
I_orig = imread('cusp_micro.jpg');
I = rgb2gray(I_orig);
BW_peaks = im2bw(I);
% How far is every non-peak pixel from its nearest peak?
distFromPeaks = bwdist(BW_peaks);
% Let's only choose pixels further from a peak than any of its neighbours
maxDistsMask = imregionalmax(distFromPeaks);
[trI,trJ] = find(maxDistsMask);
trVals = I(maxDistsMask);
tr2pkDists = distFromPeaks(maxDistsMask);
% Now loop over each trough and find the image intensity of its nearest
% peak (add 5 pixels padding so we choose the max from a few nearby peaks)
pkInds = find(BW_peaks);
[pkI,pkJ] = ind2sub(size(BW_peaks),pkInds);
trPartnerPkVals = zeros(size(trI));
for i = 1:length(trI)
tr2allPkDists = sqrt((pkI-trI(i)).^2 + (pkJ-trJ(i)).^2);
withinRangeMask = tr2allPkDists < (tr2pkDists(i) + 5);
trPartnerPkVals(i) = max(I(pkInds(withinRangeMask)));
end
% Display what we've got:
I_norm = double(I)/double(max(I(:)));
figure, imshow(cat(3,I_norm,max(BW_peaks, I_norm),I_norm)), hold on
plot(trJ,trI,'m.')
% Now if we look at all of the maxdists in the image, how far away from
% peaks are they?
figure, plot(sort(tr2pkDists)), title 'Distribution of cusp spacing'
figure, plot(sort(trPartnerPkVals - double(I(maxDistsMask))))
title 'Distribution of roughness'
So the largest trough2pk distance (or cusp spacing) is around 40 pixels. Notice of course that there are a range of pk2trough values depending on where you look in the image, likewise measures of roughness. You may need a scheme to select maximum cusp spacing or roughness within an X-pixel radius of an area you're interested in, or something similar.
Thanks, Sven.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!