imresize error. "Expected input method to be a string or a character vector. Allowed values are: 'cubic' or 'bicubic'."

조회 수: 3 (최근 30일)
I get the error message:
Expected input method to be a string or a character vector. Allowed values are:
'cubic' or 'bicubic'.
when running the following code:
scale = delta1/delta2;
Image_scaled = imresize(Image, scale, 'bilinear');
Strangely, this error happens only when I run the code on a GPU server, but not on a CPU. Do you have any idea what is causing this error? I do not want to use cubic or bicubic interpolation in my code.
Note that the variable 'Image' is a gpuArray, and I also get the warning message:
Warning: The CUDA driver must recompile the GPU libraries because your device is more recent than the libraries. Recompiling can take several minutes.
In parallel_function>make_general_channel/channel_general (line 837)
In remoteParallelFunction (line 46)

채택된 답변

Daigo
Daigo 2021년 12월 28일
I could solve this problem by retrieving the array from the GPU by gather function.
grayImage = gather(gpu_grayImage);
grayImage_scaled = imresize(grayImage, scale, 'bilinear');

추가 답변 (2개)

Alex Taylor
Alex Taylor 2021년 12월 30일
If you look at the documentation for previous versions of MATLAB, under the Extended Capabilities section for gpuArray in the imresize doc, there is a note that only bicubic interpolation was supported for gpuArray/imresize in R2020b and previous versions:
In R2021a and later the full set of interpolants work for gpuArray inputs.
  댓글 수: 1
Daigo
Daigo 2021년 12월 30일
Thank you for your follow-up, Alex! I was missing the note in the documentation. This section will be helpful when I need to check the limitations of other functions as well. Thank you for pointing out!

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2021년 12월 27일
First of all, it's probably not a good idea to call your variable Image since image() is a built-in function. I know one is capital and one is not, but still, I would not recommend it.
What is delta1 and delta2? Take the semicolon off and see what the value is. Might scale be an array?
Does the code below work for you?
grayImage = imread('moon.tif');
whos grayImage
Name Size Bytes Class Attributes grayImage 537x358 192246 uint8
subplot(1, 2, 1);
imshow(grayImage);
axis('on', 'image')
delta1 = 3
delta1 = 3
delta2 = 50
delta2 = 50
scale = delta1/delta2
scale = 0.0600
whos scale
Name Size Bytes Class Attributes scale 1x1 8 double
smallImage = imresize(grayImage, scale, 'bilinear');
subplot(1, 2, 2);
imshow(smallImage);
axis('on', 'image')
  댓글 수: 1
Daigo
Daigo 2021년 12월 28일
편집: Daigo 2021년 12월 28일
Hi, thank you for your answer! Actually your code worked but not for my input image. The problem was due to the gpuArray. It seems like the imresize function does not work properly for the gpuArray input.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 GPU Computing에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by