Initializing a 3D matrix

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Initializing a 3D matrix

sanann
Is there any method to initialize 3D matrices with boost, i am trying to use these for image processing of medical images.  I am used to working with matlab but now i have to work with c++. Boost has helped a lot in the case of 2D images now i need to extend my work to 3D images. so is there any possibility for this with boost ublas?
Reply | Threaded
Open this post in threaded view
|

Re: Initializing a 3D matrix

Nasos Iliopoulos

Hello,
There is no such functinallity in ublas but you can use boost
multi-dimensional array to achieve such functionality.
(http://www.boost.org/doc/libs/1_56_0/libs/multi_array/doc/user.html)

-Nasos


On 09/10/2014 09:55 AM, sanann wrote:

> Is there any method to initialize 3D matrices with boost, i am trying to use
> these for image processing of medical images.  I am used to working with
> matlab but now i have to work with c++. Boost has helped a lot in the case
> of 2D images now i need to extend my work to 3D images. so is there any
> possibility for this with boost ublas?
>
>
>
> --
> View this message in context: http://boost.2283326.n4.nabble.com/Initializing-a-3D-matrix-tp4667430.html
> Sent from the Boost - uBLAS mailing list archive at Nabble.com.
> _______________________________________________
> ublas mailing list
> [hidden email]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
> Sent to: [hidden email]

_______________________________________________
ublas mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Initializing a 3D matrix

sanann
Thank you very much it has helped me a lot, and i now have what i need. i have used it for quite a wide extent before coming to a major problem.

my case previously was that i used boost ublas matrix in a function whose output i could put into a boost array and use it as a function.

function f
{
matrix<double>l,m,n,o,p;

boost::array<f,5>t={l,m,n,o,p};
return t;
}

now i would like to do the same for 3D matrices which i generated using boost multi_array. do you know any possible way to send the 3d arrays from a function into another piece of code


Reply | Threaded
Open this post in threaded view
|

Re: Initializing a 3D matrix

Nasos Iliopoulos
The code you just wrote should probably be:

boost::array< matrix<double>,5> function f
{
matrix<double> l,m,n,o,p;

boost::array< matrix<double>,5> t={l,m,n,o,p};
return t;
}

I would say just replace matrix<double> with boost multi-dimensional array.

Also depending on your compiler the previous might not be optimal (as
indicated in a previous post I made). Hence also consider using a reference:

typedef boost::multi_array<double, 3> md_array_type;
typedef boost::array<md_array_type, 5> collection_type;

function f( collection_type &collection )
{
...
md_array_type & l = collection[0];
md_array_type & m = collection[1];
...
// Do whatever with l, m... as those can be used as regular
mult-dimensional arrays in here.

}

and call like:

collection_type mda_collection;

f ( md_collection );

// now md_collection has been modified from function f.


Please post any further question regarding multi-dimensional arrays to
the general boost mailing list because they are out of context here.

-Nasos


On 09/11/2014 10:51 AM, sanann wrote:

> Thank you very much it has helped me a lot, and i now have what i need. i
> have used it for quite a wide extent before coming to a major problem.
>
> my case previously was that i used boost ublas matrix in a function whose
> output i could put into a boost array and use it as a function.
>
> function f
> {
> matrix<double>l,m,n,o,p;
>
> boost::array<f,5>t={l,m,n,o,p};
> return t;
> }
>
> now i would like to do the same for 3D matrices which i generated using
> boost multi_array. do you know any possible way to send the 3d arrays from a
> function into another piece of code
>
>
>
>
>
>
> --
> View this message in context: http://boost.2283326.n4.nabble.com/Initializing-a-3D-matrix-tp4667430p4667483.html
> Sent from the Boost - uBLAS mailing list archive at Nabble.com.
> _______________________________________________
> ublas mailing list
> [hidden email]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
> Sent to: [hidden email]

_______________________________________________
ublas mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Initializing a 3D matrix

sanann
Thank you very much i asked it here since you seemed to have an idea as to how to work with them.