bgawrych edited a comment on issue #20066:
URL: 
https://github.com/apache/incubator-mxnet/issues/20066#issuecomment-804675928


   NDArray is object describing array, but under the hood it contains normal 
memory. You can access this memory by calling i.e:
   ```
   int16_t* in_ptr = in_data.dptr<int16_t>();
   ```
   (bsaed on example)
   All offsets of different dimensions you can deduce by calling proper ndarray 
functions. 
   
   You can also utilize numpy array to create mxnet's ndarray
   ```
   from jpeg2dct.numpy import load, loads
   
   import mxnet as mx
   #read from a file
   jpeg_file = 'test.jpg'
   dct_y, dct_cb, dct_cr = load(jpeg_file)
   print ("Y component DCT shape {} and type {}".format(dct_y.shape, 
dct_y.dtype))
   print ("Cb component DCT shape {} and type {}".format(dct_cb.shape, 
dct_cb.dtype))
   print ("Cr component DCT shape {} and type {}".format(dct_cr.shape, 
dct_cr.dtype))
   
   print(type(dct_cr))
   print(dct_cr)
   mxnet_array = mx.nd.array(dct_cr)
   
   print(mxnet_array.shape)
   print(type(mxnet_array))
   print(mxnet_array)
   ```
   
   However if you wish to load file directly and operate on bytes you can check 
this operator:
   
https://github.com/apache/incubator-mxnet/blob/9de2a48fabf1b8a60eb539640dea4c0637b5522b/src/io/image_io.cc#L371
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to