Closed ranok92 closed 6 years ago
In C, array's don't have any shape, they are just a contiguous "line" of memory. What is important is that the access to that buffer are consistent on both the NumPy and the C side. In this case, they are, since the C code is accessing the memory as [(yW+x)3+c], which is consistent with the memory layout NumPy gives to a [H,W,C]
C-contiguous array. Note that you have a typo in your question, the .pyx
file checks for the rgbim
array to be of [h_, w_, 3]
, not [w_, h_, 3]
. This distinction is important.
If you want to learn more, I recommend you read about memory layout, especially this part of the NumPy documentation. And maybe the NumPy ndarray paper helps, too.
I'm closing the issue as you're not reporting a bug, but feel free to ask more and, if you do find a bug, re-open the issue.
Hey, thanks for the reply. Can you please if possible explain to me these 2 notations in the context of the cpp code and why you are using this :
unsigned char[:,:,::1] rgbim in
def addPairwiseBilateral(self, sxy, srgb, unsigned char[:,:,::1] rgbim
not None, compat, KernelType kernel=DIAG_KERNEL, NormalizationType normalization=NORMALIZE_SYMMETRIC):
and
rgbim[0,0,0] in
sxy[0], sxy[1], srgb[0], srgb[1], srgb[2], &rgbim[0,0,0],
_labelcomp(compat), kernel, normalization
Regards, Abhisek
On Sat 31 Mar, 2018, 10:40 AM Lucas Beyer, notifications@github.com wrote:
Closed #59 https://github.com/lucasb-eyer/pydensecrf/issues/59.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucasb-eyer/pydensecrf/issues/59#event-1550757447, or mute the thread https://github.com/notifications/unsubscribe-auth/Acm2uco5aeDL3IdrgLVC7iZ4UZWIU95Wks5tj5V3gaJpZM4TCdYK .
Both of these are explained in the Cython User Guide, chapter about Typed Memoryviews, you should read that if you're interested.
Briefly, the first one means it's a 3D array that is C-contiguous in layout; if a non-C-contiguous array is passed, it will raise an exception.
The second one, &rgbim[0,0,0]
(you forgot the &
which is important) is a pointer to the start of the buffer.
Hello,
Thank you so much for your reply. I really appreciate you taking your time to reply. I will look into the guides.
Thanks, Abhisek
On Sat, Mar 31, 2018 at 1:02 PM, Lucas Beyer notifications@github.com wrote:
Both of these are explained in the Cython User Guide, chapter about Typed Memoryviews http://cython.readthedocs.io/en/latest/src/userguide/memoryviews.html, you should read that if you're interested.
Briefly, the first one means it's a 3D array that is C-contiguous in layout; if a non-C-contiguous array is passed, it will raise an exception.
The second one, &rgbim[0,0,0] (you forgot the & which is important) is a pointer to the start of the buffer.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucasb-eyer/pydensecrf/issues/59#issuecomment-377707692, or mute the thread https://github.com/notifications/unsubscribe-auth/Acm2udmLfSx9ROQX3sMHcLlY4452bBE0ks5tj7a2gaJpZM4TCdYK .
Hey, I was going through the original cpp code for the addPairwiseBilateral for denseCRF2D and there the array they pass, im, seem to be of the dimension [(w*h*3), 1], but in the .pyx file it checks for the size of the im array to be of [w , h , 3]. Can someone please explain to me this part? Sorry, I am kind of new to this. So, having an issue understanding how the stuff actually works.
Thanks,