小编mmg*_*mgp的帖子

如何在matplotlib中进行3D革命?

假设您有一条2D曲线,例如:

from matplotlib import pylab
t = numpy.linspace(-1, 1, 21)
z = -t**2
pylab.plot(t, z)
Run Code Online (Sandbox Code Playgroud)

哪个产生

http://i.imgur.com/feQzk.png

我想进行一场革命以获得一个3d图(见http://reference.wolfram.com/mathematica/ref/RevolutionPlot3D.html).绘制3d表面不是问题,但它不会产生我期望的结果:

http://i.imgur.com/ljXHQ.png

如何在3d图中执行此蓝色曲线的旋转?

python numpy matplotlib

7
推荐指数
1
解决办法
3933
查看次数

块均值哈希方法

基于块平均值图像感知哈希卞押嗯提出了说,一个散列方法:

第一个感知散列函数基于均值

a) Normalize the original image into a preset sizes;

b) Divide the size-normalized image I into non overlapped blocks I1, I2, …, IN, 
in which N is the block number equal to length of the final hash bit string;

c) Calculate the mean value sequence {M1, M2, …, MN} from corresponding 
block sequence {I’1, I’2, …, I’N } and obtain the median value Md of 
this sequence as: Md = median (Mi) (i=1,2,…, N) 

d) Normalize …
Run Code Online (Sandbox Code Playgroud)

hash image image-processing

5
推荐指数
1
解决办法
1511
查看次数

Python 3上的CSV写入错误

我正在尝试将模块的输出保存到CSV文件,当我运行以下代码时出现错误,这是模块的一部分:

base_keys = ['path', 'rDATE', 'cDate', 'cik', 'risk', 'word_count']
outFile = open('c:\\Users\\ahn_133\\Desktop\\Python Project\\MinkAhn_completed2.csv','wb')
dWriter = csv.DictWriter(outFile, fieldnames=base_keys)
dWriter.writerow(headerDict)
Run Code Online (Sandbox Code Playgroud)

这是错误消息(base_keys是标题.)

return self.writer.writerow(self._dict_to_list(rowdict))
TypeError: 'str' does not support the buffer interface
Run Code Online (Sandbox Code Playgroud)

我甚至不理解错误信息是什么.我使用Python 3.3和Windows 7.

谢谢你的时间.

python python-3.x

4
推荐指数
1
解决办法
4348
查看次数

使用python和PIL对图像进行分割,以计算多个矩形对象的质心和旋转

我使用python和PIL在640x480图像中找到各种矩形(和正方形)的质心和旋转,类似于这个 在此输入图像描述

到目前为止,我的代码适用于图像中的单个矩形.

import Image, math

def find_centroid(im):
    width, height = im.size
    XX, YY, count = 0, 0, 0
    for x in xrange(0, width, 1):
        for y in xrange(0, height, 1):
            if im.getpixel((x, y)) == 0:
                XX += x
                YY += y
                count += 1
    return XX/count, YY/count

#Top Left Vertex
def find_vertex1(im):
    width, height = im.size
    for y in xrange(0, height, 1):
        for x in xrange (0, width, 1):
            if im.getpixel((x, y)) == 0:
                X1=x
                Y1=y
                return X1, Y1

#Bottom …
Run Code Online (Sandbox Code Playgroud)

python image-processing image-segmentation python-imaging-library

4
推荐指数
1
解决办法
7557
查看次数

运行Python时的AttributeError

运行我的程序时,调用函数

self.getFileButton = Button(self,
                            text = "...",
                            command =
                            tkFileDialog.askopenfilename(mode="r+b", **self.file_opt))
Run Code Online (Sandbox Code Playgroud)

我收到了错误

File "C:/Documents and Settings/l/My Documents/Python/csv_GUI.py", line 33, in create_widgets
tkFileDialog.askopenfilename(mode="r+b", **self.file_opt))
Run Code Online (Sandbox Code Playgroud)

AttributeError:selectFile实例没有属性'file_opt'

python

2
推荐指数
1
解决办法
234
查看次数