New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How could I get the Buffer of NdArray returned by numjs? #21
Comments
Could you check that dtype is set to uint8 and that the underlying datastructure is an Uint8Array? |
Can you share the 4000x4000 image? |
Yes I had confirmed, it's unit 8. To reproduce you can just run my posted script, |
As you say, the problem comes from To access the raw data of the image, you can do this: var nj = require('numjs')
var img = nj.images.data.lena;
img.shape // => [ 512, 512, 3 ]
img.dtype // => uint8
img.selection.data // Uint8Array see https://github.com/nicolaspanel/numjs/blob/master/src/images/read.js#L8-L26 and https://github.com/nicolaspanel/numjs/blob/master/src/images/read-dom.js#L20-L52 for more info |
Thank you very much! |
What I want to do, is to save the memory usage.
I have a project that will deal with large photos, like a 4000 x 4000 JPEG file. what I want to do is:
The current operation is use a
image.flatten().tolist()
and uses lots of memory, which caused a nodejs OUT OF HEAP MEMORY ERROR. (only addnode --max-old-space-size=4096
can make it)I saw a method of
nj.getRawData()
, may I use that? And another question: does it the same function likenp.getbuffer()
? If so, why not the same name.Thanks!
UPDATE: I make a reproduce-able code to demo the problem:
Both
flatten()
andreshape()
will not work with very large NdArray, like [8000, 10000].But a for-loop with NdArray will be ok.
The text was updated successfully, but these errors were encountered: