3D grid support (take 2)
Opened this issue · 5 comments
mxhf commented
Hi,
I am trying to create a 3D grid like
nodes = g.add_nodes( (c.shape[0],c.shape[1],c.shape[2]) )
(c is a 3D numpy array)
But am getting
TypeError: an integer is required
Any suggestions?
Max
pmneila commented
Hi @mxhf,
add_nodes
expects a single integer and creates as many nodes as indicated by that integer. I think you might be looking for add_grid_nodes
, which takes a tuple of integers:
nodes = g.add_grid_nodes( (c.shape[0], c.shape[1], c.shape[2]) )
Also note that if c
is a 3D array, you can simply write:
nodes = g.add_grid_nodes(c.shape)
Regards!
mxhf commented
OK, I clearly should have been able to figure this out myself. Many thanks!
Quick additional question though.
I'd like to be able to set the "structure" or costs according to
neighboring pixel value differences (in a 3D pixel cube).
And idea on how to achieve this while pushing it to the c++ layer. Doing it
a python loop takes foerever.
Max
…On Fri, Aug 23, 2019 at 11:14 PM pmneila ***@***.***> wrote:
Closed #43 <#43>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#43?email_source=notifications&email_token=AB2AZST6B6XUF3LASUCG62TQGBHLJA5CNFSM4IPCG4K2YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOTHKOVVQ#event-2580867798>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB2AZSQ2BRK6RCU734EI6N3QGBHLJANCNFSM4IPCG4KQ>
.
--
--------------------------------------------------------------------
Maximilian Fabricius
* Max Planck Institute for Extraterrestrial Physics (MPE)
Giessenbachstrasse, D-85748 Garching, Germany
* University Observatory Munich / Wendelstein Observatory
Scheinerstr. 1, D-81679 München, Germany
eMail: mxhf@mpe.mpg.de
Phone: +49 89 30000 3779
--------------------------------------------------------------------
pmneila commented
Hi @mxhf,
Have you looked at the layout_example3D.py? It builds a 3D graph and then connects nodes with a specific pattern (that of course can be adapted to your needs). Is this what you want?
mxhf commented
I have (now), yes I know the custom structure
ala
structure = np.array([[[0, 1, 0],
[1, 1, 1],
[0, 1, 0]],
[[0, 1, 0],
[1, 0, 1],
[0, 1, 0]],
[[0, 1, 0],
[1, 1, 1],
[0, 1, 0]]])
but I want to adjust the structure on a pixel by pixel basis. Essentially
the interpixel edge capacity should be a function of the pixel value
differences.
This is easy of course if I do it in python but slow.
Max
…On Mon, Aug 26, 2019 at 2:49 PM pmneila ***@***.***> wrote:
Reopened #43 <#43>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#43?email_source=notifications&email_token=AB2AZSVDD5TURBVT2M44SNTQGPGNLA5CNFSM4IPCG4K2YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOTH7CQJA#event-2583570468>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB2AZSQLBX47O63GZGE7FHTQGPGNLANCNFSM4IPCG4KQ>
.
--
--------------------------------------------------------------------
Maximilian Fabricius
* Max Planck Institute for Extraterrestrial Physics (MPE)
Giessenbachstrasse, D-85748 Garching, Germany
* University Observatory Munich / Wendelstein Observatory
Scheinerstr. 1, D-81679 München, Germany
eMail: mxhf@mpe.mpg.de
Phone: +49 89 30000 3779
--------------------------------------------------------------------
nirmalsnair commented
You could use numba
to speed-up your Python loops. Usually, I get 10-100x speed-up.