smoothing vector fields with gmic

hello everybody and happy new year to all the community.
i was wondering if there is a function in gmic to smooth orientation of a vector field (.flo file) while keeping the norm of the vectors.
otherwise how could it be done
thanks for any insight
thanks in advance
lulu

Yes, that is possible.
Basically, you can separate the norm and orientation of a vector field, and blur only the orientation, with one of the smoothing algorithm available in G’MIC.
For instance:

$ gmic square.flo +norm orientation.. blur.. 5 orientation.. mul o square_smoothed.flo

Here, with input field square.flo:
square.flo (8.0 KB)
dq1

We end up with field square_smoothed.flo:
square_smoothed.flo (8.0 KB)
dq2

Here I used the simple blur command to do the smoothing, but of course, any kind of smoothing command can be used as a replacement.

I noticed that you used orientation twice: is that something we should do?

Yes, orientation forces the vector field to have a norm of 1, and after the blur, there is no guarantee that this norm is preserved.

There is a (slightly different) alternative though:

$ square.flo +norm blur.. 5 orientation.. mul o square_smoothed.flo

The only difference is that the blur is applied on the whole input field rather than on the normalized field. But this won’t have a large impact on the outcome.

Are you saying that the first solution is more correct? More things to fix in my *.gmic files. :blush:

No, I don’t say that.
The first solution solves :

  • Smooth the orientation of the input vector field.

The second solution solves:

  • Smooth the vector field while ensuring the norm is preserved.

This is slightly different, but anyway the differences should be unnoticeable most of the time
(I don’t say of course that there won’t be large differences for particular cases).

What I have done so far is use only one norm and orientation (or more precisely luminance and colour separation) prior to the processing. When combining the two, the resultant image can become unstable. In that context, in light of what you just said, I should use the second pipeline:

image
→ norm → processing
→ processing → orientation
combine

Of course, there are other reasons why things don’t work out, but in relation to the separation, I should probably do it this way.

Yes maybe. The second solution is actually the projection of the smoothed vector field to the space of vector fields having the same pixelwise norm than the input field.

great thank you so much. may i ask how you get this arrows visualisation ?

G’MIC command display_quiver (aka dq):

$ gmic input.flo dq
2 Likes

cooool. thanks