How the streamline function is implemented?
3 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I post this question some time ago, I am still searching about it. I found exactly what I want! However it is a MATLAB built in function and I need to know how it is done?!
Here is the link to streamline function which produces an amazing result for my problem. How these lines are generated? I need the points of these lines not only just drawing them!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/149954/image.png)
Any idea how streamline finds this curved smooth lines?
Thanks a lot.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%555%%
THIS IS THE OLD QUESTION, WHICH IS NOW TURNED INTO THIS NEW ONE
Hello People,
I have an image processing question. I want to go from 1 to 2 making curved lines (curvature is probably determined by the gradient of the image).
I have the following image. I used edge detection to find the edges of the image, red and green edges are the ones that I need and I got them extracted.
I select a pixel from the red edge (lets name it Pr) and find the closest pixel to it on the green edge (lets call it Pg).
Now the problem is, I don't know how to follow the gradient path of the image (roughly showed in yellow) from red point (Pr) to green point (Pg). I don't want to do straight lines, I connected them directly before but that's not satisfying.
Any ideas how can I do that please? I am thinking of some sort of region growing?!!!
Figure.1. A non-convext gray scale image. Start and finish points are marked with red and green and yellow roughly shows the direction of gradient vectors.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/149955/image.png)
Thanks a lot for your help.
0 个评论
回答(2 个)
Image Analyst
2015-5-9
Just threshold and call bwboundaries
binaryImage = grayImage > 0;
boundary = bwboundaries(binaryImage);
x = boundary{1}(:, 2);
y = boundary{1}(:, 1);
If you want just the top and bottom edge, you have to identify all indexes which have the x value of the sides and then take the pixels in between. Then, if the points go closckwise along the border, you will have to call fliplr() on the flat bottom section.
9 个评论
Image Analyst
2015-5-10
编辑:Image Analyst
2015-5-10
To hug that curve on the top of your first picture, you may want to treat it as an image - it may help. See this series on finding the shortest path by Steve Eddins, the leader of the imaging team at the Mathworks. http://blogs.mathworks.com/steve/2011/11/01/exploring-shortest-paths-part-1/ first find the two points, like I just showed. Then use bwgeodesicdist() to force it to go within some region of interest.
Walter Roberson
2015-5-9
Following the gradient is equivalent to a shortest-path algorithm, such as the Dijkstra Shortest-Path algorithm.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Language Support 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!