我正在对Kaggle进行CIFAR挑战.
他们给了一个包含5万张图片的.7z文件作为火车.我花了1个小时解压缩它然后再花40分钟读取所有文件并将其放在内存中.
试图不创建50k文件,因为这是这个的瓶颈,我已经安装了pylzma和其他库,但所有这些都会告诉我该文件无效.
来自bash的7z可以正确读取文件,并列出文件.所以我使用Popen了解压缩所有文件并使用bash 7z程序将它放在内存中的字符串中
import subprocess
p = subprocess.Popen(["7z", "e", "-so", "awa.7z"], stdout=subprocess.PIPE).communicate()[0]
Run Code Online (Sandbox Code Playgroud)
我已经设法通过查看其大小,然后从字符串中获取适当的字节来单独获取每个文件
f1 = p[0][0:2105]
Run Code Online (Sandbox Code Playgroud)
我现在想要的是欺骗Python认为F1文件指针,这样我就可以调用skimage.io.imread并将它转换为适当的结构.或者也许只是将内存值传递给skimage,它会为我转换它.
我注意到各种面向Python科学图形的软件包之间的骨架几何存在显着差异。
使用OpenCV-Python的骨架:

使用pymorph的骨架:

使用scikit-image的骨骼:

可以观察到,OpenCV-Python和pymorph产生相同的骨架,而scikit-image则不然。骨骼差异的原因是什么?哪一个是合适的骨架?
我有一个单波段二进制图像(仅包含0和1像素值),如下图所示.
我必须将外部白色边界内的所有黑色像素转换为白色.外部白色边界外的黑色像素应保持黑色.
你会怎么做?

我在Python 2.7中使用了Skimage软件包很长一段时间.
最近我将我的Ubuntu升级到14.10现在我无法从Skimage包中导入过滤器(过去是过滤器).
Python 2.7.9 (default, Apr 2 2015, 15:33:21)
[GCC 4.9.2] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> from skimage import filters
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from skimage import filters
File "/usr/local/lib/python2.7/dist-packages/skimage/filters/__init__.py", line 17, in <module>
from .. import restoration
File "/usr/local/lib/python2.7/dist-packages/skimage/restoration/__init__.py", line 21, in <module>
from .deconvolution import wiener, unsupervised_wiener, richardson_lucy
File "/usr/local/lib/python2.7/dist-packages/skimage/restoration/deconvolution.py", line 10, in <module>
from scipy.signal import convolve2d
File "/usr/lib/python2.7/dist-packages/scipy/signal/__init__.py", line 240, in <module> …Run Code Online (Sandbox Code Playgroud) 我的某些图像出现了零分割错误(即使其中许多图像都可以正常工作):
这是代码:
image = skimage.io.imread('test.png', False)
image_gray = skimage.io.imread('test.png', True)
blurred = cv2.GaussianBlur(img_as_ubyte(image_gray), (5, 5), 0)
thresh = threshold_li(blurred)
binary = blurred > thresh
binary_cv2 = img_as_ubyte(binary)
# find contours in the thresholded image
cnts = cv2.findContours(binary_cv2.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts[0] if imutils.is_cv2() else cnts[1]
# loop over the contours
for c in cnts:
# compute the center of the contour
M = cv2.moments(c)
cX = int(M["m10"] / M["m00"])
cY = int(M["m01"] / M["m00"])
# draw the contour and …Run Code Online (Sandbox Code Playgroud) 我正在尝试遵循scikit-image中有关模板匹配的教程(在此处检查)。
仅使用此示例,我想找到图像中所有匹配的硬币(最大值),而不仅仅是得分最高的硬币。我在考虑使用:
maxima = argrelextrema(result, np.greater)
Run Code Online (Sandbox Code Playgroud)
但是问题在于它还发现了很小的局部最大值,这只是一种噪声。有什么办法可以筛选numpy数组并找到最强的最大值?谢谢!