Centerline Detection in an Image
Show older comments
Hello,
I have a picture of a white tube against a black backdrop and I need to find a curve that follows the centerline of the tube. Not necessarily an equation for the curve just a graphical representation in a line graph or something. I am very very new to Matlab so I am not sure how to go about doing this.
What I have done so far is make the image in gray scale and then extracted the matrix. What I think I have to do now is find the maximum value in each row of the matrix since the white will have a higher value in the matrix. I cannot figure out how to do this though.
Another way I figured I could accomplish this is by doing a polyfit for each individual row since the values where the tube are appear to follow a quadratic relationship between the edges of the tube and the center. I could then find the maximum of each of of these polynomials and plot that. Again I don't know how to do this and the documentation doesn't help me.
So my main question is how do I find the column location of the maximum value of each row? So I get an output like:
Row | Column
1 12
2 13
3 14
4 13
5 12
6 11
7 10
or:
x=(1:7), y= 12 13 14 13 12 11 10
except obviously there are around 1000 entries for x
Thanks a lot,

Accepted Answer
More Answers (1)
Image Analyst
on 14 Oct 2013
Something like this (untested)
[rows, columns, numberOfColorChannels] = size(yourImage);
for row = 1 : rows
thisRow = yourImage(row, :, 2); % Kth row from green channel
[maxValue, indexOfMax(row)] = max(thisRow);
end
Categories
Find more on Images in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
