【发布时间】:2018-08-17 04:13:51
【问题描述】:
我想在grey_scale() 中使用browse_file() 中的"img"。
我可以使用band_count(type Int),但是当我尝试在grey_scale() 中使用"img" 时,出现以下错误:
the type of "img" is class 'spectral.io.bilfile.BilFile'
Traceback (most recent call last):
File "main.py", line 50, in grey_scale
view = imshow(img,(bandGrey,))`
NameError: global name 'img' is not defined`
我的代码:
def browse_file(self,MainWindow):
file = str(QtGui.QFileDialog.getOpenFileName(self,"Select Directory"))
img = envi.open(file) #load image to img object.
band_info = str(img.read_band)
band_count = int((band_info.split(start))[1].split(end)[0])
view = imshow(img,(1,0,0))
def grey_scale(self):
bandGrey = self.spinBox_grey_band.value()
print bandGrey #working
view = imshow(img,(bandGrey,)) #error
【问题讨论】: