【发布时间】:2019-10-24 20:05:18
【问题描述】:
我正在尝试将彩色图像转换为灰度图像,但出现错误:
警告:'rgb2gray' 功能属于 Octave Forge 的图像包,但尚未实现
我在 Ubuntu 18.04 64 位上使用 Octave 4.2.2,目前无法将此版本升级到 Octave 5.1。
有解决办法吗?
我的目标是:
- 将彩色图像转换为灰度图像。
- 然后将每个灰度像素的强度/亮度置于
0-1之间的范围内。
我的代码:
pkg load image
% read image from url (I took a random image on internet)..
[url_img, map] = imread('http://i.imgur.com/9PDZb7i.png');
figure, imshow(url_img), title('Image from url')
% resize it..
resized_img1 = imresize(url_img, 0.2); % resize by a factor here 0.2
resized_img2 = imresize(url_img, [600 500]); % resize to a specific dimensions
% there are many ways of interpolation to perform resizing
%resized_img3 = imresize(url_img, 0.2,'method','nearest'); % rsize by a specific interpolation method
figure, imshow(resized_img1), title('Resized image')
% change color did you mean from RGB to grayscale
gray_img = rgb2gray(resized_img1);
figure, imshow(gray_img), title ('Grayscale image')
【问题讨论】:
-
我想你没有安装镜像包吧?