mahotas

Python 十大图像处理工具

北城余情 提交于 2021-01-08 18:53:32
作者:Parul Pandey 编译:大数据文摘 本文主要介绍了一些简单易懂最常用的Python图像处理库 当今世界充满了各种数据,而图像是其中高的重要组成部分。然而,若想其有所应用,我们需要对这些图像进行处理。图像处理是分析和操纵数字图像的过程,旨在提高其质量或从中提取一些信息,然后将其用于某些方面。 图像处理中的常见任务包括显示图像,基本操作(如裁剪、翻转、旋转等),图像分割,分类和特征提取,图像恢复和图像识别等。Python之成为图像处理任务的最佳选择,是因为这一科学编程语言日益普及,并且其自身免费提供许多最先进的图像处理工具。 让我们看一下用于图像处理任务的一些常用Python库。 1. scikit Image scikit-image是一个基于numpy数组的开源Python包。 它实现了用于研究、教育和工业应用的算法和实用程序。 即使是对于那些刚接触Python的人,它也是一个相当简单的库。 此库代码质量非常高并已经过同行评审,是由一个活跃的志愿者社区编写的。 使用说明文档: https://scikit-image.org/docs/stable/user_guide.html 用法举例: 图像过滤、 模版匹配 可使用“skimage”来导入该库。大多数功能都能在子模块中找到。 import matplotlib.pyplot as plt %matplotlib

How can I read an image from an Internet URL in Python cv2, scikit image and mahotas?

生来就可爱ヽ(ⅴ<●) 提交于 2020-08-02 05:39:25
问题 How can I read an image from an Internet URL in Python cv2? This Stack Overflow answer, import cv2.cv as cv import urllib2 from cStringIO import StringIO import PIL.Image as pil url="some_url" img_file = urllib2.urlopen(url) im = StringIO(img_file.read()) is not good because Python reported to me: TypeError: object.__new__(cStringIO.StringI) is not safe, use cStringIO.StringI.__new__ 回答1: Since a cv2 image is not a string (save a Unicode one, yucc), but a NumPy array, - use cv2 and NumPy to

Detect objects on a white background in Python

家住魔仙堡 提交于 2019-12-30 07:10:34
问题 I'm trying to use Python to detect how many objects are on a white surface. An example image is found at the end of this post. I'm wondering how I should do this, mainly because the background is white and most of the time it gets detected as foreground. What I have now in Python based on this tutorial (http://pythonvision.org/basic-tutorial) uses several libraries and detects the white as the object so count is 1, the tools get detected as background and thus are ignored: dna = mahotas

Why python raise a runtime error only with certain images?

倾然丶 夕夏残阳落幕 提交于 2019-12-20 07:28:53
问题 It is the third question i do in stackoverflow about that because every time i got some changes in the way python raise runtime erro. Previous questions were: here and here. In the first question i think was a matter of memory because i anylized many images, in the second case the runtime error happen at this line p2 = numpy.percentile(img, 2) and i think was a numpy module problem. but now i the runtime error happens here: imgbnbin = mh.morph.dilate(gray, disk7) At mahotas function dilate.

How can i subtract the background from an image in mahotas and opencv in python?

微笑、不失礼 提交于 2019-12-13 08:29:21
问题 I have many image like this or like this and i use this code: fork = mh.imread(path) bin = fork[:,:,0] bin = mh.erode(bin) bin = (bin < 80) for the 2nd image, but i have to use this: bin = (bin < 127) for the first. There is a way for automatically obtain a good image without background, or i have to choose a median value hopefully is good for the most of my images? 回答1: There is a threshold value that is called "Otsu Threshold". Here you have more information. You can use otsu to do it in

Cannot determine type of file

我的梦境 提交于 2019-12-12 18:33:13
问题 Hi i have just started learning image processing using python. When i tried to open an image that i downloaded from the net, I keep getting this error and I have no idea about how to resolve it. Can anyone please help me with this? >>> dna=mahotas.imread('dna.jpeg') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\mahotas\io\freeimage.py", line 773, in imread img = read(filename) File "C:\Python27\lib\site-packages\mahotas\io\freeimage

Detect objects on a white background in Python

雨燕双飞 提交于 2019-12-01 00:18:39
I'm trying to use Python to detect how many objects are on a white surface. An example image is found at the end of this post. I'm wondering how I should do this, mainly because the background is white and most of the time it gets detected as foreground. What I have now in Python based on this tutorial ( http://pythonvision.org/basic-tutorial ) uses several libraries and detects the white as the object so count is 1, the tools get detected as background and thus are ignored: dna = mahotas.imread('dna.jpeg') dna = dna.squeeze() dna = pymorph.to_gray(dna) print dna.shape print dna.dtype print

Python: taking the GLCM of a non-rectangular region

家住魔仙堡 提交于 2019-11-30 09:47:08
问题 I have been using the SLIC implementation of skimage to segment images in superpixels. I would like to use GLCMs to extract additional features from these superpixels for a classification problem. These superpixels are not rectangular. In MATLAB you can set pixels to NaN and they will be ignored by the algorithm (link). I could use this to make bounding boxes around the superpixels and then just setting the unused pixels to NaN. The greycomatrix function in skimage does not work entirely the

Python: taking the GLCM of a non-rectangular region

跟風遠走 提交于 2019-11-29 17:42:15
I have been using the SLIC implementation of skimage to segment images in superpixels. I would like to use GLCMs to extract additional features from these superpixels for a classification problem. These superpixels are not rectangular. In MATLAB you can set pixels to NaN and they will be ignored by the algorithm ( link ). I could use this to make bounding boxes around the superpixels and then just setting the unused pixels to NaN. The greycomatrix function in skimage does not work entirely the same as the MATLAB implementation however. When setting pixels to NaN the function fails on an assert