Example #1
0
 def menuActionMatch(self):
     # get parameters
     popup = DialogMatch(self.window)
     popup.exec_()
     if not popup.path:
         return
     # read file at popup.path
     target = cv2.imread(popup.path, 0)
     if target is None:
         print("Could not open file or file is not an image.")
         return
     # copy current state
     old = self.history[self.historyIndex]
     matrix = old['matrix'].copy()
     histogram = deepcopy(old['histogram']['plots'][0])
     # apply histogram matching
     histogram1 = Histogram.hist(target)
     matrix = Transform.match(matrix, histogram, histogram1)
     # compute histogram
     histogram = {
         'plots': [Histogram.hist(matrix), histogram1],
         'legend': ["New", "Target"]
     }
     # add new state
     self.appendHistory({
         'matrix': matrix,
         'histogram': histogram,
         'saved': False
     })
     self.updateImage(matrix)
     hist = [old['histogram']['plots'][0]] + histogram['plots']
     legend = ["Old"] + histogram['legend']
     self.windowHist.setHistogram(hist, legend)