How the streamline function is implemented?
7 views (last 30 days)
Show older comments
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!
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.
Thanks a lot for your help.
0 Comments
Answers (2)
Image Analyst
on 9 May 2015
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 Comments
Image Analyst
on 10 May 2015
Edited: Image Analyst
on 10 May 2015
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
on 9 May 2015
Following the gradient is equivalent to a shortest-path algorithm, such as the Dijkstra Shortest-Path algorithm.
2 Comments
See Also
Categories
Find more on Language Support 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!