필터 지우기
필터 지우기

How the streamline function is implemented?

조회 수: 2 (최근 30일)
Nick Earnhardt
Nick Earnhardt 2015년 5월 9일
편집: Nick Earnhardt 2015년 5월 28일
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.

답변 (2개)

Image Analyst
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
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.
Nick Earnhardt
Nick Earnhardt 2015년 5월 10일
Thanks a lot for the hint.
I read some part of it, which was about distance transform, last night. I'll go through the rest of it.
Thanks a lot.

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2015년 5월 9일
Following the gradient is equivalent to a shortest-path algorithm, such as the Dijkstra Shortest-Path algorithm.
You might also want to consider the gray-weighted distance routine, graydist
  댓글 수: 2
Nick Earnhardt
Nick Earnhardt 2015년 5월 9일
편집: Nick Earnhardt 2015년 5월 10일
Thanks for the clue Walter, I'll check these things right now.
Thanks a lot
Nick Earnhardt
Nick Earnhardt 2015년 5월 12일
Dear Image Analyst & Walter,
I just read this tutorial on shortest path by Steve! That's just amazing, I love it! I'll definitely try to write something similar using graydist. Lets keep fingers crossed ;)
Thanks

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Language Support에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by