|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
octave contributor?I have a general interest in contributing code to octave-forge. While it is possible I will contribute code to more than one package (or perhaps not at all, as I have to get accustomed to distributed programming---svn, in particular), my primary focus will likely be on functions for the image package, at least initially. Thomas L. Scofield -------------------------------------------------------- Associate Professor Department of Mathematics and Statistics Calvin College -------------------------------------------------------- ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Octave-dev mailing list Octave-dev@... https://lists.sourceforge.net/lists/listinfo/octave-dev |
|
|
Re: octave contributor?tor, 19 06 2008 kl. 12:41 -0400, skrev Thomas L. Scofield:
> I have a general interest in contributing code to octave-forge. > While it is possible I will contribute code to more than one package > (or perhaps not at all, as I have to get accustomed to distributed > programming---svn, in particular), my primary focus will likely be on > functions for the image package, at least initially. Sounds great. In general we prefer to see some code before we give access to the SVN. This is just to keep the number of users with SVN access down. So, just show us some code, and give us your source-forge user name, and we'll give you SVN access. As to learning SVN, then don't worry, it's quite easy. But if you have problems just ask :-) Søren ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Octave-dev mailing list Octave-dev@... https://lists.sourceforge.net/lists/listinfo/octave-dev |
|
|
|
|
|
|
|
|
bwdistHello Mr. Hauberg. I've been thinking some about this alteration to bwdist to handle NDArrays. I have hit on a couple of snags, and am hoping you can point me in the right direction. You made the following suggestion: On Jun 20, 2008, at 1:02 AM, Søren Hauberg wrote: > You would need to look at the source code of __bwdist, and change > that. > You can just download the image package from sourceforge and > uncompress > that, there you'll find the source code. The source can then be > compiled > with the mkoctfile command from within Octave. Basically, what the > code > does is that it implements the 1D Euclidian distance transform. > This is > then computed along each dimension of the image. This is currently > hard > coded to two dimensions. What I'd do is to change __bwdist to only > work > on 1D data, and then I would change bwdist.m to call this function for > each dimension. > First off, the existing bwdist.m works for 1 and 2D arrays (since, apparently, an n-vector is seen by ndims as having 2 dimensions, so just like a matrix). Thus, an extension is really only needed in cases of ND arrays with N > 2. Supposing that I follow you advice for a binary N-by-N-by-N array im, and let us assume that I could make direct calls to the dt() function inside the file __bwdist.cc whose declaration looks like static float* dt (float *f, int n) Then I would have Octave code (inside bwdist.m) something like im = 1 ./ im - 1; for ii = 1:N for jj = 1:N im(ii, jj, :) = dt (im(ii, jj, :), N); end end for ii = 1:N for kk = 1:N im(ii, :, kk) = dt (im(ii, :, kk), N); end end for jj = 1:N for kk = 1:N im(:, jj, kk) = dt (im(:, jj, kk), N); end end This is, of course, the kind of thing Octave/Matlab programmers are encouraged NOT to do---handle repetitive things inside of FOR loops (instead of finding ways to achieve the same goal through some "vectorized" approach). I suppose if FOR loops are the only way to carry this out, then those loops are best implemented inside __bwdist.cc where they will be compiled rather than executed by the Octave interpreter. (More on that below.) That aside, this code handles only the N-by-N-by-N case, so is not much of an extension of the existing bwdist.m at this point. Is there a way to avoid embedding this code inside a SWITCH-CASE type construct like dims = ndims (im); switch case dims < 3: # handled like currently case dims == 3: # insert the above code case dims == 4: # redo the code above so that it contains 4 FOR loops, at each stage # fixing 3 of the four coordinates in im case dims == 5: # redo the code above so that it contains 5 FOR loops, at each stage # fixing 4 of the four coordinates in im etc. As for implementing the FOR loops inside __bwdist.cc instead of bwdist.m, the likely place for these loops would be in the dt() function whose declaration is static void dt (NDArray &im) I think I run into the same difficulty as above having to hardcode the various cases (although I know very little about the Octave API to C++, so perhaps there are methods that would streamline this). But here I may run into another difficulty. I believe there is a dim3 method that matches dim1 and dim2 currently being used in this dt () function. But I see no indication that there is a dim4 method. What would make more sense is a method dim that accepts the dimension number as an argument. Is there such a thing, so far as you know? Thanks. Thomas L. Scofield -------------------------------------------------------- Associate Professor Department of Mathematics and Statistics Calvin College -------------------------------------------------------- ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Octave-dev mailing list Octave-dev@... https://lists.sourceforge.net/lists/listinfo/octave-dev |
|
|
Re: bwdistHi,
It's great to see somebody pick up my work, and try to finish it. Thank you. (answers below) Quoting "Thomas L. Scofield" <scofield@...>: > First off, the existing bwdist.m works for 1 and 2D arrays (since, > apparently, an n-vector is seen by ndims as having 2 dimensions, so > just like a matrix). Thus, an extension is really only needed in > cases of ND arrays with N > 2. Yes. > Supposing that I follow you advice for a binary N-by-N-by-N array > im, and let us assume that I could make direct calls to the dt() > function inside the file __bwdist.cc whose declaration looks like > > static float* dt (float *f, int n) > > Then I would have Octave code (inside bwdist.m) something like > > im = 1 ./ im - 1; > > for ii = 1:N > for jj = 1:N > im(ii, jj, :) = dt (im(ii, jj, :), N); > end > end > > for ii = 1:N > for kk = 1:N > im(ii, :, kk) = dt (im(ii, :, kk), N); > end > end > > for jj = 1:N > for kk = 1:N > im(:, jj, kk) = dt (im(:, jj, kk), N); > end > end The problem with this approach is that then you'll only handle the 3D case. You'll need another implementation for the 4D case, the 5D case, etc. This way the amount of code will quickly grow, and the result will likely be a mess, and we would still only support a limited set of dimensions. In general, working with ND can be quite a pain, but it's quite nice to have support for the ND case. [snip] > I think I run into the same difficulty as above having to hardcode > the various cases (although I know very little about the Octave API > to C++, so perhaps there are methods that would streamline this). > But here I may run into another difficulty. I believe there is a > dim3 method that matches dim1 and dim2 currently being used in this > dt () function. But I see no indication that there is a dim4 > method. What would make more sense is a method dim that accepts > the dimension number as an argument. Is there such a thing, so far > as you know? I think the function you want is called 'dims'. It returns a 'dim_vector' which you can then index, i.e. something like this (untested code): const dim_vector my_dims = my_nd_array.dims (); for (int k = 0; k < mu_dims.length (); k++) printf ("my_dims [%d] = %d\n", k, my_dims (k)); The way I imagined ND support in 'bwdist' was to be implemented is something like this. Basically I would change the '__bwdist' function to only wrap the static float* dt (float *f, int n) function. That is, I think '__bwdist' should only implement the 1D squared distance transform. You should then call '__bwidst' with a dimension argument that tells it along which dimension the distance transform should be computed. Then the 'bwdist' function should look something like this: function D = bwdist (I) ## Compute squared distance transform for dim = 1:ndims (I) I = __bwdist (I, dim); endfor ## Convert to Euclidian distances D = sqrt (I); endfunction That way the number of interpreted for loops would be quite low. I think this approach can be implemented, but as I haven't actually done it, it might be harder then I think. Anyway, thanks for looking into this, Søren ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Octave-dev mailing list Octave-dev@... https://lists.sourceforge.net/lists/listinfo/octave-dev |
| Free Forum Powered by Nabble | Forum Help |