I have a color image that I'm trying to convert to grayscale, but I get an error:
warning: the 'rgb2gray' function belongs to the image package from Octave Forge but has not yet been implemented
I'm using Octave 4.2.2 on Ubuntu 18.04 64-bit and can't upgrade this version to Octave 5.1 yet.
Is there a workaround?
My goal is:
- To convert a color image into grayscale.
- Then place the intensity/brightness of each grayscale pixel into a range between
0-1.
My code:
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')