gpuArray/imresize Input array has too many elements

7 views (last 30 days)
I am doing alot of image processing and to speed things up I am using my GPU to help with that
I got an error and I couldn't find help for it anywhere so I decided to ask a question
I made a gpuArray of size 250x250x3x1000 (these are concatenated images so 4D Array) or larger and I tried running imresize on it.
I was following the advice of "Joss Knight" who I have seen answering many questions on GPU related processing and it helped me greatly to speed up my computation.
I was wondering what reason is there that I am getting this error and is there a solution or a workaround for it?
Thank you very much.
Edit:
I just found something.
Dim= cat(4,ImageGroupContainer{ : } ));
So I use cat and when I call size(Dim), I get 273, 273, 3, 1095
and I call numel on it, it gives "244827765"
can't use gpuArray/imresize with it
?
  3 Comments
Shammakh Naseer
Shammakh Naseer on 6 Jan 2021
I am trying to resize them to different sizes but the smallest is 192x72 and largest would 500x500 i would say
Shammakh Naseer
Shammakh Naseer on 6 Jan 2021
Edited: Shammakh Naseer on 6 Jan 2021
My gpu has enough memory but not sure what other limitations there are. As you can tell, I am new at this
I have an RTX 2070

Sign in to comment.

Accepted Answer

Joss Knight
Joss Knight on 8 Jan 2021
Edited: Joss Knight on 8 Jan 2021
There is a size limitation for gpuArray/imresize of <= 2^27 elements which is only documented in help text.
>> help gpuArray/imresize
imresize Resize image.
B = imresize(A,SCALE)
B = imresize(A,SCALE,METHOD)
B = imresize(A,[NUMROWS NUMCOLS])
B = imresize(A,[NUMROWS NUMCOLS],METHOD)
B = imresize(...,PARAM1,VAL1,PARAM2,VAL2,...)
The input A must have at most 2^27 elements and be non-sparse.
Categorical and indexed images are not supported.
For bicubic interpolation, the output image can have some
values slightly outside the range of pixel values in the input
image.
Sorry about this - the documentation will be updated.
To work around this, simply divide your images up into multiple smaller batches.
  1 Comment
Shammakh Naseer
Shammakh Naseer on 8 Jan 2021
Ah yes, My solution was to work around this by dividing it up, but I was not sure what the element limits are or why they are there since it wasn't in the docs.
Thank you very much for your help though and hope to see you around :)

Sign in to comment.

More Answers (0)

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!