How is streamline function is implemented in MATLAB?!

Hello everyone,
I post a question some times ago, I am still searching about it. I found a function that does exactly what I want! However it is a MATLAB built in function and I need to know how it works?! It draws curved lines in th direction of the gradient! I want to do the same.
I have an image, I want to take it's gradient and draw the same lines for the gradient vectors! Just like the following image.
This produces an amazing result for my problem. How these lines are generated? I need the data points of these lines not only just drawing them!
Anyone has any clue how the lines are derived?! Or how can I do the same?!
Any idea how streamline finds these curved smooth lines?
Thanks a lot.

1 comentario

Dear Joseph,
Thanks a lot for your help, as you said the Euler Integration aka Forward Euler Prediction, is the solution.
And my problem is already solved! It wasn't hard to implement it at all!
Thanks a lot for your help.

Iniciar sesión para comentar.

 Respuesta aceptada

Well how to generate the lines will take a bit of thought but to get the lines
[x,y] = meshgrid(0:0.1:1,0:0.1:1);
u = x;
v = -y;
figure
quiver(x,y,u,v)
startx = 0.1:0.1:1;
starty = ones(size(startx));
hstream = streamline(x,y,u,v,startx,starty);
Xdata = get(hstream,'Xdata');
Ydata = get(hstream,'Ydata');
hold on
for ind =1:length(Xdata);
plot(Xdata{ind},Ydata{ind},'r--')
end

6 comentarios

Nick Earnhardt
Nick Earnhardt el 28 de Mayo de 2015
Editada: Nick Earnhardt el 28 de Mayo de 2015
Dear Joseph,
Thanks for your reply, that is inded helpful. Still I need to at least know how it is done! I'm afraid I am not good at copy pasting without understanding what is happening.
And I really need this, it's been my question for about a month!
As you said it needs a little bit of thought, I wish I could at least understood the concept behind it!
More than a month ago, I tried to write a code to start from a point and based on the maximum local gradient direction and value make a progress pixel by pixel, but that turned into a disaster! Any turbulence in the gradient deviated the movement into a circular infinite path!
I've oppened strem3 streamline xyzuvwchech files trying to understand what is happening inside these functions, yet now clue!
Many thanks.
Nick Earnhardt
Nick Earnhardt el 28 de Mayo de 2015
Editada: Nick Earnhardt el 28 de Mayo de 2015
BTW
stream3c.m is a mexFile which is hollow inside?!
How can I see what is happening inside stream3c mexFile?!
Thanks
Joseph Cheng
Joseph Cheng el 28 de Mayo de 2015
Editada: Joseph Cheng el 28 de Mayo de 2015
Are you more interested in the method or the points. The example code will get you the points of each line. They encrypt these functions for a reason whether for proprietary code, running the function in a complied language, etc.
So the example code i gave you will grab the X and Y data points used to plot the streamlines. And you should never cut and paste. Run example code and step through and try to understand what was done.
Nick Earnhardt
Nick Earnhardt el 28 de Mayo de 2015
Editada: Nick Earnhardt el 28 de Mayo de 2015
Dear Joseph,
I didn't mean to copy pasting from your kind response.
Imagine that I have to provide the method of how I did it for my employer! In fact that has nothing to do with imagination, this is my problem! I have to provide this knowledge and information for a pure programmer to write a code and embed it to a CFD software.
I am supposed to do this research and find such algorithm, then pass it someone who doesn't even know what's gradient to write a C++ code.
And to be honest as far as my algorithm works I am off the hook, I am not bothered with the next level, it's the C++ programmer to figure out how my MATLAB algorithm works! lol
That's the problem.
Well from what i gather the streamline() function is performing something along the lines of Euler Integration or Runge-Kutta to some order. performing a very quick google search
has a lecture on it (see slide 22+)
Dear Joseph,
Thanks for the clue.
I downloaded the PDF now, I'll have a look today.
Thanks a lot.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Image Processing Toolbox en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 28 de Mayo de 2015

Comentada:

el 29 de Mayo de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by