问题
I am new to Octave platform and am trying the image tool for image processing version-2.8.0. I have installed this tool using 'pkg install -forge image'. It installed perfectly and even contains in the package list. Now when i try to convert a colored image into gray scale it gives me following error.
warning: the 'rgb2gray' function belongs to the image package from Octave Forge but has not yet been implemented.
Please read http://www.octave.org/missing.html to learn how you can contribute missing functionality.
error: 'rgb2gray' undefined near line 1 column 1*
Here is my code:
pkg load image;
img = imread('IMG_20170815_004922_213.jpg');
img_gray = rgb2gray(img);
imshow(img_gray);
I have read some errors that were due to not having 'pkg load image' line that is like an import statement. But in my case even this statement haven't solved my problem. I am using Octave Version-4.2.2 , Windows 7 64-bit and i5-processor.
回答1:
The image package decides at install time whether it should install the rgb2gray function or not. Octave 4.4 includes an implementation of rgb2gray so the image package at install time does the following:
- start Octave in another process (
octave -qf) - check if the
rgb2grayexists in this new process - adds
rgb2grayto list of functions to install, only if function is missing
This means that if starting a new Octave process when you installed the package had such a symbol, then you might end up with the image package without the function. I'm not sure how that could happen since the check is done after starting octave without reading any initialization file.
One possibility is if you have some hack in Octave to automatically load the image package and that installation of the image package you done was an upgrade.
Solution: uninstall and then install the image package.
来源:https://stackoverflow.com/questions/51358082/eror-rgb2gray-undefined-in-octave-4-2-2