We are using Python 2.7.9.and scikit image library. We are not able to use skimage.feature.greycomatrix because there is no file such as greycomatrix.py in the feature folder. Their documentation seems to be wrong as it says this function is available. We get an error module attribute has no object feature. Is there any other image processing library in Python which will help us achieve this goal?
from skimage.feature import greycomatrix
This works for me, just like the instructions at http://scikit-image.org/docs/dev/auto_examples/plot_glcm.html.
Maybe you just have an old version and need to update scikit-image? Or if it was actually a bug on their behalf they have probably fixed it now.
Which version of scikit-image do you have? That is more relevant for this problem than your Python version. For me:
import skimage
print skimage.__version__
'0.11.2'
So for version 0.11.2 up atleast it should work.
In my case I use the following imports and it works for me.
I say
import skimage.feature as sk
##Then I say
glcm = sk.greycomatrix(img, [1],[0])
This should work fine.
Related
Edit: As far as I can tell it's an issue with the build, I haven't figured out exactly what yet, but I've narrowed it down to that. For anyone reading this, try the suggestion in the marked answer first.
I'm trying to use the ConvexHull function from the scipy library to compute the convex hull for some points, but scipy.spatial.ConvexHull doesn't seem to exist.
The documentation has this as an example:
from scipy.spatial import ConvexHull
points = np.random.rand(30, 2) # 30 random points in 2-D
hull = ConvexHull(points)
I tried to use this example in my project but couldn't get it to work..
I typed in the appropriate import line but ConvexHull was not found, PyCharm underlined the ConvexHull reference in red, and a mouse-hover shows a 'not found' message.
I've found various mentions on SO about different methods that might be required for importing and using parts of scipy, which I've tried and none of them seem to work, including the import line in the docs example.
I'm running Python 3.6 inside a clean PyCharm venv that I've just created. The pip install of scipy worked fine and scipy is appearing when I try to import it, as is spatial... but ConvexHull doesn't seem to exist.
I'm using scipy 1.1.0, and I've tried using the import that a deleted answer provided...
from scipy.spatial.qhull import ConvexHull... but this didn't work.
Alternately, if this won't work then I am willing to use a different library if possible.
https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.ConvexHull.html
Did you try
from scipy import spatial
spatial.ConvexHull
In 1.0.1 both of these work
In [2]: spatial.qhull.ConvexHull?
In [3]: spatial.ConvexHull?
Glancing at the github issues, there may be some build issues, involving cython versions, that may prevent building the qhull file.
https://github.com/scipy/scipy/issues/8562 - CI: Appveyor builds fail because it can't import ConvexHull from spatial.qhull
I upgraded to 1.1.0, and had no problem accessing ConvexHull.
I want to use one of the newest versions of Python, (3.5+), and I need to import Image. I use:
from PIL import Image
except this returns an error. I don't have the error on my right now but the important part is there is a problem with PIL (I have already determined that from my Python Discord server)
Can I use pillow? I think I have that installed. I would try it but I want to know how (and if) it's applicable. Thanks
Can I use pillow?
Sure. pillow is a successor project of PIL, as development on the latter was last continued in 2011.
The first thing mentioned in the official pillow documentation is how to import the Image class.
I tried to use Python's Image Module on my Mac (new to mac)and I had trouble setting it up. I have Yosemite and some of the posts that I found online didn't work. I ended up installing Homebrew and I finally got PIL on my computer. However, instead of using import image (which I saw people doing it online), I have to use from PIL import image. Is there key difference between import Image and from PIL import Image. It's the first time that I actually use Image module.
One more question, do I actually need to install third party tools like Homebrew and Macports to set up my environment?
If you are using PIL, you might be able to use import Image.
If you are using Pillow, you must use from PIL import Image.
This is by design.
1-Pillow and PIL cannot co-exist in the same environment. Before installing Pillow, please uninstall PIL.
2-Pillow >= 1.0 no longer supports “import Image”. Please use “from PIL import Image” instead. so be careful with it
3-Pillow >= 2.1.0 no longer supports “import _imaging”. Please use “from PIL.Image import core as _imaging” instead.
In python, modules are represented by *.py files. These files can be imported using import module. That statement will first search for a build-in module, if it fails to find one it will search in a given list of directories (PYTHONPATH).
When you imported your module, you can then access names (aka functions or classes) via module.name.
However, when using from module import myFunc you can reference that function directly without using the modulename. The same goes for from module import *.
Now, to the PIL:
Image is a name (here class) in the PIL module. As, import Image searches for modules called Image. It can't find one, because Image is part of the PIL module.
You can also look at the documentation here: Modules in Python
I hope this helped you understanding modules better.
I am trying to use scikit-image to do some research. The system is Windows 7 64bit, and the python version is 2.7, 64bit.
The first program I run is from: http://scikit-image.org/
The code is
from skimage import data, io, filter
image = data.coins() # or any NumPy array!
edges = filter.sobel(image)
io.imshow(edges)
io.show()
However, the problem happens, and the error message is:
C:\Python27\lib\site-packages\skimage\io_plugins\null_plugin.py:14:
RuntimeWarning: No plugin has been loaded. Please refer to
skimage.io.plugins()
for a list of available plugins.
warnings.warn(RuntimeWarning(message))
I believe that both Python and scikit-image are correctly installed. So, may I know what is wrong with it?
Any suggestion is appreciated. Many thanks.
Just had precisely the same issue on amazon linux. The issue is that skimage requires PIL, and PIL is not installed. In the latest skimage they added the dependency, but the version that I got installed with pip didn't have it yet.
The solution is
pip install Pillow
EDIT: and after that you will probably immediately face another issue, with skimage loading image, but not being able to read it (in particular, shape being empty tuple). Here's the solution
Why does scipy.ndimage.io.imread return PngImageFile, not an array of values
I am working with different threshold algorithms from SKimage, and when I go to import certain packages I get an error, but have no problem with others. For example:
from skimage.filter import threshold_adaptive, threshold_isodata
returns the traceback:
ImportError: cannot import name threshold_isodata. I am using python 2.7, and following the documentation found here: http://scikit-image.org/docs/dev/api/skimage.filter.html#skimage.filter.threshold_isodata
Specifically, I'm hoping to use threshold_isodata and threshold_yen. Does anybody have suggestions for how to solve this error? Alternatively, are there other packages that use the same algorithm?
As mentioned in a comment, threshold_isodata is only available in the master repo (i.e. not officially released in v0.9), hence the import error.
It turns out that threshold_yen wasn't properly imported into the filter subpackage in version 0.9. (This has been fixed in master.) Until v0.10 is released, you should import threshold_yen as follows:
from skimage.filter.thresholding import threshold_yen
EDIT: Note that this question and answer are specific to very old versions of scikit-image. The skimage.filter module was renamed skimage.filters in v0.11