2017-04-08 8 views
0

.tifイメージのサイズを変更しようとしています。 しかし、ときに私が次のエラーを取得コードを実行しようとしているイム:以下AttributeError: 'NoneType'オブジェクトに属性 'shape'のサイズ変更イメージがありません

AttributeError: 'NoneType' object has no attribute 'shape' 

は、コードスニペットです:

# Open de beeldfile 

image = cv2.imread(fullinname) 

# Bepaal afmetingen en aantal kleurkanalen 

width = image.shape[1] 

height = image.shape[0] 

colors = image.shape[2] 

print ("{} pixels breed".format(width)) 
print ("{} pixels hoog".format(height)) 
print ("{} kleur kanalen".format(colors)) 

img = cv2.resize(image, (512, 512)) 

誰もがこの問題を解決する方法を知っていますか?ここで

+0

いいえ、私のファイルには1つのcv2.imreadしかありません –

+1

5つの回答のどれもそこに掲載されていない場合、あなたの問題を解決できない場合は、[いずれか](https://www.google.ca/search?client) = safari&rls = en&q = python + cv2.imread +は返されません+ none&ie = UTF-8&oe = UTF-8&gfe_rd = cr&ei = NF7pWLCjNMuC8Qe4hqPACw)これはかなり一般的な問題ですが、私はいくつかの研究が解決策を生み出すと確信しています。 ([Stack Overflowユーザーにどの程度の研究努力が期待されていますか?](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users) ) –

+0

'fullinname'をデバッグできますか? – ZdaR

答えて

0

私は私のボックス上で実行されていたコード:

import cv2 
# Open de beeldfile 
image = cv2.imread("/fullPathImageName.jpg") 
# Bepaal afmetingen en aantal kleurkanalen 

width = image.shape[1] 
height = image.shape[0] 
colors = image.shape[2] 
print ("{} pixels breed".format(width)) 
print ("{} pixels hoog".format(height)) 
print ("{} kleur kanalen".format(colors)) 

img = cv2.resize(image, (512, 512)) 

width = img.shape[1] 
height = img.shape[0] 
colors = img.shape[2] 
print ("{} pixels breed".format(width)) 
print ("{} pixels hoog".format(height)) 
print ("{} kleur kanalen".format(colors)) 

ここでは、印刷し何:

python -u "cv2questionImageResize_Cg.py" 
816 pixels breed 
612 pixels hoog 
3 kleur kanalen 
512 pixels breed 
512 pixels hoog 
3 kleur kanalen 

だから、私の視点から、ここで解決するものは何もありません... EXCEPT ...

put "fullinname" in quotation marks

となり、ファイルが存在するかどうかを確認してください。

関連する問題