Pointer to image producing different results
I'm doing the following:
image = image.clone(); // ensure continuous memory
double *im = (double *) calloc(image.total() *image.elemSize(), sizeof (double));
im = (double *)image.data;
What I thought this was doing was giving me a pointer to the image data, however when i print out the memory in a debugger I get different values after I add the same offset to both (i.e. x/100 image.data+100 != x/100 im+100).
Is my pointing not doing what I think it is and if so why?
The reason I'm doing this is because I'm trying to port some mex stuff, and the whole function relies on a pointer to an rgb image and address offsetting.
wtf, there's almost nothing right with your current approach.
image.total() *image.elemSize()
is the size in bytes, but again, you're allocating doubles.im = (double *)image.data;
<-- this just overwrites your pointer, it does not copy memory (also, you're leaking your just allocated mem)honestly, it might be a good idea, to leave the mex stuff to someone else.