help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Signed distance function vectorization


From: fotios
Subject: Signed distance function vectorization
Date: Wed, 04 Sep 2013 12:52:44 +0200
User-agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8

Hello list!

So here is my problem (weakly coupled to Octave). Given a non-self-intersecting closed curve (simply connected) and a grid comprised by square elements, I would like to get the signed distance function from the centers of those elements on that grid. Currently the way I do it is shown below

function [ d ] = sdistf ( cx, cy, x, y )

n = [ diff( y ), -diff( x ) ];
n = (n ./ repmat( sqrt( n(:, 1).^2 + n(:, 2).^2 ), 1, 2 ));
r = [ x(1:(end - 1)) - cx, y(1:(end - 1)) - cy ]';
d = min( diag( n*r ) );
endfucntion

mytest
# yada yada
for row = 1 : numel( cx )
  for col = 1 : numel (cx)
    d(row, col) = sdistf ( xc(row, col), yc(row, col), px, py );
  end
end
# bla bla

and I was able to vectorize everything in the worst (memory-wise) way . . . a clever way of doing this in Octave (without using level-sets or anything like that, just an vectorized version of the above). As a result of my try to find some info - or a starting point for you that will try to help me - I found that one

http://statinfer.wordpress.com/2011/11/14/efficient-matlab-i-pairwise-distances/

/Fotis






reply via email to

[Prev in Thread] Current Thread [Next in Thread]