Refreshing an Image with PyQt4

by: elam, 9 years ago

Last edited: 9 years ago

I'm attempting to use PyQt4 to build an interactive image quantizer and I seem to be stuck at the point where the image needs to be refreshed. The temp.jpg file is updated after the refresh call by self._MiniKMeans.updateImage(imgPath1, self.K). I have also verified that the proper values of K are being passed from the slider into refreshImage().

path to files:

imgPath1 = 'C:/Users/elam/Pictures/profilebw.jpg'
imgPath2 = 'temp.jpg'


Original Images are loaded into the GUI:

# Get Original Image
pixmap1 = QtGui.QPixmap(imgPath1)
self.imageLabel1 = QtGui.QLabel(self)
self.imageLabel1.setPixmap(pixmap1)

# Second Processed Image
pixmap2 = QtGui.QPixmap(imgPath2)
self.imageLabel2 = QtGui.QLabel(self)
self.imageLabel2.setPixmap(pixmap2)

# Handle changing slider values
self.slider.valueChanged.connect(self.sliderNumber.display)
self.slider.valueChanged.connect(self.refreshImage)



Refresh image is then called:

# Refresh Image on change
def refreshImage(self):

      # Get updated values from slider
      self.K = self.sliderNumber.intValue()

      # redo clustering
      self._MiniKMeans.updateImage(imgPath1, self.K)


################################################
## This does not update as expected
# Reload images
    pixmapr1 = QtGui.QPixmap(imgPath1)
    self.imageLabel1.setPixmap(pixmapr1)

   pixmapr2 = QtGui.QPixmap(imgPath2)
   self.imageLabel2.setPixmap(pixmapr2)

   pass


Thanks in advance!



You must be logged in to post. Please login or register an account.