MCPcopy Create free account
hub / github.com/Jack-Cherish/Machine-Learning / img2vector

Function img2vector

SVM/svm-digits.py:257–271  ·  view source on GitHub ↗

将32x32的二进制图像转换为1x1024向量。 Parameters: filename - 文件名 Returns: returnVect - 返回的二进制图像的1x1024向量

(filename)

Source from the content-addressed store, hash-verified

255
256
257def img2vector(filename):
258 """
259 将32x32的二进制图像转换为1x1024向量。
260 Parameters:
261 filename - 文件名
262 Returns:
263 returnVect - 返回的二进制图像的1x1024向量
264 """
265 returnVect = np.zeros((1,1024))
266 fr = open(filename)
267 for i in range(32):
268 lineStr = fr.readline()
269 for j in range(32):
270 returnVect[0,32*i+j] = int(lineStr[j])
271 return returnVect
272
273def loadImages(dirName):
274 """

Callers 1

loadImagesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected