Image Analysis: measuring cusping and roughness

6 ビュー (過去 30 日間)
Shan  Kapoor
Shan Kapoor 2011 年 10 月 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
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
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.
  5 件のコメント
Shan  Kapoor
Shan Kapoor 2011 年 12 月 30 日
dear Sven,
Can I further join the points in each laths and draw perpendiculars from the line to the lath edges and measure their lengths based on a pixels distance we specify ?? so that the expected output should look like this
https://picasaweb.google.com/116243239493929305987/December292011#5691497323268999938
My idea is to just describe the laths roughness based on the distribution of lengths of perpendiculars based on the width we specify. At a particular width, there will be a nice distribution of long and short lines and I will be able to manipulate it further.
Shan  Kapoor
Shan Kapoor 2012 年 1 月 12 日
dear Sven
could you please guide me understanding this portion of the code ?
% 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
what exactly is [pkI,pkJ] ?? and what does it do with the rest of the code ? when I tried plotting [pkI,pkJ], it filled everywhere other than the black pixels...
thanks in advance,
Shanoob

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by