进行铸造时的结果不同

时间:2015-11-06 21:22:15

标签: python opencv numpy

我正在运行以下脚本,并在转换为int和float时得到不同的结果!

import cv2
import numpy as np
feat1 = cv2.imread('0002.png')
feat2 = cv2.imread('0001.png')

dist1 = np.sum(np.power((feat1 - feat2), 2), axis = 2)
dist2 = np.sum(np.power((feat1 - feat2).astype(int), 2), axis = 2)
dist3 = np.sum(np.power((feat1 - feat2).astype(float), 2), axis = 2)

print dist1
print dist2
print dist3

结果:

[[308 387 389 ..., 176 305 344]
 [566 587 424 ..., 152 474 309]
 [409 293 377 ..., 381 209 161]
 ..., 
 [373  80 499 ..., 366 185 354]
 [ 89 627 526 ..., 211 245 305]
 [233 361 491 ..., 120 414 269]]

[[  6452   8835   1925 ..., 121776 126257 140120]
 [  5942  10059   1960 ..., 110744 123354 123701]
 [  6041   3365    377 ..., 103549 119761 113569]
 ..., 
 [  2933   3408   4595 ...,  96622  98489  93794]
 [  4697   4211   6158 ..., 101331  97013  94769]
 [   233   1897   4075 ..., 106104 104606  95501]]

[[   6452.    8835.    1925. ...,  121776.  126257.  140120.]
 [   5942.   10059.    1960. ...,  110744.  123354.  123701.]
 [   6041.    3365.     377. ...,  103549.  119761.  113569.]
 ..., 
 [   2933.    3408.    4595. ...,   96622.   98489.   93794.]
 [   4697.    4211.    6158. ...,  101331.   97013.   94769.]
 [    233.    1897.    4075. ...,  106104.  104606.   95501.]]

如何理解这一点?

链接到图片:https://www.dropbox.com/sh/k11s5gek47hxd4v/AAB9M31xpiCUUr1N1RXbOJnWa?dl=0

feat1的结果 - feat1.astype(int)

[[308 387 389 ..., 176 305 344]
 [566 587 424 ..., 152 474 309]
 [409 293 377 ..., 381 209 161]
 ..., 
 [373  80 499 ..., 366 185 354]
 [ 89 627 526 ..., 211 245 305]
 [233 361 491 ..., 120 414 269]]
[[  6452   8835   1925 ..., 121776 126257 140120]
 [  5942  10059   1960 ..., 110744 123354 123701]
 [  6041   3365    377 ..., 103549 119761 113569]
 ..., 
 [  2933   3408   4595 ...,  96622  98489  93794]
 [  4697   4211   6158 ..., 101331  97013  94769]
 [   233   1897   4075 ..., 106104 104606  95501]]
[[   6452.    8835.    1925. ...,  121776.  126257.  140120.]
 [   5942.   10059.    1960. ...,  110744.  123354.  123701.]
 [   6041.    3365.     377. ...,  103549.  119761.  113569.]
 ..., 
 [   2933.    3408.    4595. ...,   96622.   98489.   93794.]
 [   4697.    4211.    6158. ...,  101331.   97013.   94769.]
 [    233.    1897.    4075. ...,  106104.  104606.   95501.]]
[[[0 0 0]
  [0 0 0]
  [0 0 0]
  ..., 
  [0 0 0]
  [0 0 0]
  [0 0 0]]

 [[0 0 0]
  [0 0 0]
  [0 0 0]
  ..., 
  [0 0 0]
  [0 0 0]
  [0 0 0]]

 [[0 0 0]
  [0 0 0]
  [0 0 0]
  ..., 
  [0 0 0]
  [0 0 0]
  [0 0 0]]

 ..., 
 [[0 0 0]
  [0 0 0]
  [0 0 0]
  ..., 
  [0 0 0]
  [0 0 0]
  [0 0 0]]

 [[0 0 0]
  [0 0 0]
  [0 0 0]
  ..., 
  [0 0 0]
  [0 0 0]
  [0 0 0]]

 [[0 0 0]
  [0 0 0]
  [0 0 0]
  ..., 
  [0 0 0]
  [0 0 0]
  [0 0 0]]]

0 个答案:

没有答案