Reduce resolution of image in 2d array #1325
-
I've got pixel data in a 2 dimensional array and I want to reduce the resolution by splitting into chunks and running interpolation on it such as using the .mean() method.
The chunk_2d method doesn't exist of course, is there a similar method that would do what I want or how would I go about doing this? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Also the .chunks_exact() method doesn't seem to give a good way to resolve back into a 2d array and only gives one dimension to chunk the data by so can't have different x and y scales |
Beta Was this translation helpful? Give feedback.
-
Would this work?
exact_chunks is a producer, so it can be used with Zip. We usually zip over more than one array, but this is not mandatory. |
Beta Was this translation helpful? Give feedback.
-
It looks like that works, thank you
I'd rather iterate over the raw values Or do you think dereferencing wouldn't matter performance wise? |
Beta Was this translation helpful? Give feedback.
-
Awesome, thank you so much and yeah I'll do that now. |
Beta Was this translation helpful? Give feedback.
I can't remember where this is written, but you should use iter/into_iter as less as possible because it is slow. For example, what you wrote can be expressed as
If you're starting with ndarray, I strongly suggest you to read the quickstart and official doc.