【发布时间】:2021-09-19 11:14:24
【问题描述】:
我正在尝试使用 Octave 5.2.0 调整非常小的图像,但我不确定为什么在尝试调整大小时会出错
错误发生在以下行:
img_unique_only = imresize(f2, [640, 480]); %reshape output of unique colors
error: interp2: cubic requires at least 2 points in each dimension
error: called from
interp2 at line 244 column 9
imremap at line 65 column 19
imresize at line 135 column 8
test_small_resize_question at line 30 column 17 (the last line which is the imresize line)
代码如下:
pkg load image
f(:,:,1)=[0;0;0;0;127;128;128;128];
f(:,:,2)=[0;0;127;128;0;0;0;0];
f(:,:,3)=[127;128;0;0;0;0;127;128];
%%%%%%%%%%%%%%%%-------------------------------------------------------------------------
[im_r im_c]=size(f);
size_min=min(im_r,im_c); %get minum size from row and col
f2=uint8(f)
imshow(f2)
img_unique_only = imresize(f2, [640, 480]); %reshape output of unique colors
使用imshow(f2) 创建下面的图像
img_unique_only = imresize(f2, [640, 480]); %reshape output of unique colors 行不会调整大小
创建的变量:
当使用img_unique_only = imresize(f2, [640, 480], "nearest"); %reshape output of unique colors这一行时
创建的变量:
我得到的是 灰度 图像,而不是 640x480 彩色图像
注意:如果更好,我也愿意尝试其他方式
【问题讨论】:
-
您有一个只有 1 行的图像。三次插值在每个方向上至少需要 2 个值。你没有它们。你确定它是一个图像?人们不称数组为“图像”。您可以尝试使用不同的插值方法,查看
imresizedocs。 -
我添加了一个 uint8 以确保它是一个图像并做了一个
imshow(f2)我用图像更新了问题 -
uint8的东西不会使它成为图像呵呵。使它成为图像的唯一原因是您说矩阵是图像。错误很明显,我告诉你如何解决它:使用与默认三次不同的插值技术 -
我想我错过了一些东西,因为我尝试了
nearest, cubic, bilinear, bicubic, linear示例:img_unique_only = imresize(f2, [640, 480], "nearest");最近会生成图像,但它是灰度而不是颜色 -
最近的
size(img_unique_only)和size(f2)是什么?其余的很明显,您至少需要 2 个值来插值,并且您没有将它们放在其中一个方向
标签: arrays image image-processing multidimensional-array octave