Exemplo n.º 1
0
    def mixer(self):
        self.gain1 = self.ui.component1_slider.value()
        self.gain2 = self.ui.component2_slider.value()
        self.type1 = self.types[0].currentText()
        self.type2 = self.types[1].currentText()
        self.img1 = self.opimg[0].currentText()
        self.img2 = self.opimg[1].currentText()
        if (self.img1 != self.img2):
            self.path1 = self.paths[0]
            self.path2 = self.paths[1]
            self.imgmix1 = inputimg(self.path1)
            self.imgmix2 = inputimg(self.path2)
            if (self.type1 == "Magnitude"
                    or self.type1 == "Phase") and (self.type2 == "Magnitude"
                                                   or self.type2 == "Phase"):
                self.mode = "magphase"
                print("check1")
                print(self.type1, self.type2)
                print(self.img1, self.img2)
            elif (self.type1 == "Real" or self.type1 == "Imaginary") and (
                    self.type2 == "Real" or self.type2 == "Imaginary"):
                self.mode = "realimg"
                print(self.type1, self.type2)
                print(self.img1, self.img2)
                print("check2")
            else:
                self.mode = "other"
                print("can't mix")
                print(self.type1, self.type2)
                print(self.img1, self.img2)

            if (self.img1 == "Image 1" and self.img2 == "Image 2"):
                output = self.imgmix1.mix(self.imgmix2, self.gain1, self.gain2,
                                          self.mode, self.type1, self.type2)
                print("check3")
            else:
                output = self.imgmix2.mix(self.imgmix1, self.gain1, self.gain2,
                                          self.mode, self.type1, self.type2)
                print("check4", "\n")
        elif (self.img1 == "Image 1" and self.img2 == "Image 1"):
            self.path1 = self.paths[0]
            output = inputimg(self.path1).img
        elif (self.img1 == "Image 2" and self.img2 == "Image 2"):
            self.path1 = self.paths[1]
            output = inputimg(self.path1).img
        else:
            print(self.type1, self.type2)
            print(self.img1, self.img2)
            print(" Unexpected error")
            #show the same image ba3deen
        if self.ui.output_channel.currentText() == "Output 1":
            self.images[4].setImage((output).T)
        elif self.ui.output_channel.currentText() == "Output 2":
            # self.ui.component1_type.setItemText(0)
            self.images[5].setImage((output).T)
Exemplo n.º 2
0
 def Components(self, y):
     self.images[2 + y % 2].clear()
     # if y==0 :
     #     self.path=self.paths[0]
     # else:
     #     self.path= self.paths[1]
     self.path = self.paths[y % 2]
     self.imgdata = inputimg(self.path)
     for i in range(0, y + 1):
         if self.img_combo[i].currentText() == "Magnitude":
             x = self.imgdata.magnitude
             print(self.img_combo[i].currentText())
             print(y)
         elif self.img_combo[i].currentText() == "Phase":
             x = self.imgdata.phaseshift
             print(self.img_combo[i].currentText())
             print(y)
         elif self.img_combo[i].currentText() == "Real":
             x = self.imgdata.realshift
             print(self.img_combo[i].currentText())
             print(y)
         elif self.img_combo[i].currentText() == "Imaginary":
             x = self.imgdata.imaginaryshift
             print(self.img_combo[i].currentText())
             print(y)
         else:
             self.images[2 + y % 2].clear()
     self.images[2 + y % 2].setImage(x.T)
     self.images[2 + y % 2].view.setRange(xRange=[0, self.imgheight[y % 2]],
                                          yRange=[0, self.imgwidth[y % 2]],
                                          padding=0)
Exemplo n.º 3
0
    def opensignal(self):

        self.readsignal()
        if (len(self.imgdata) != 0 and
            (self.width != self.Size[0] or self.height != self.Size[1])):

            QMessageBox.about(
                self, "Error !",
                "Please Choose Another image with the same dimensions")
            logger.warning("Opened Image with different dimensions ...")
        else:
            self.count += 1
            self.ui.images[self.count % 2].clear()
            if (len(self.imgdata) == 2):
                self.imgdata = []
                self.Size = []

            print(self.imgdata)
            print(self.Size)

            self.imgdata.append(inputimg(self.path))
            print(self.width)
            print(self.height)
            self.ui.enable[self.count % 2].setEnabled(True)
            self.Size.append(self.width)
            self.Size.append(self.height)
            self.ui.images[self.count % 2].setImage(
                (self.imgdata[self.count % 2].img).T)
            self.ui.images[self.count % 2].view.setAspectLocked(False)
            logger.info(f" Opening image {1+self.count%2} ...")

        if (len(self.imgdata) == 2):
            for i in range(1, 9):
                self.ui.enable[i].setEnabled(True)
Exemplo n.º 4
0
 def readsignal(self):
     self.fname = QtGui.QFileDialog.getOpenFileName(
         self, ' Open File', os.getenv('home'),
         "jpg(*.jpg) ;; jpeg(*.jpeg) ")
     self.path = self.fname[0]
     self.imgdata = inputimg(self.path)
     self.img = cv2.imread(self.path, 0)
     self.height, self.width = self.img.shape
     if (self.path):
         pass
Exemplo n.º 5
0
 def readsignal(self):
     logger.info("Browsing image ...")
     self.fname = QtGui.QFileDialog.getOpenFileName(
         self, ' Open File', os.getenv('home'),
         "jpg(*.jpg) ;; jpeg(*.jpeg) ")
     self.path = self.fname[0]
     self.imgdata = inputimg(self.path)
     self.img = cv2.imread(self.path, 0)
     self.height, self.width = self.img.shape
     if (self.path == True):
         logger.warning(" No image to open ")
     else:
         logger.info(" Browsed Successfully ! ")
Exemplo n.º 6
0
 def Components(self, y):
     self.images[2 + y % 2].clear()
     self.path = self.paths[y % 2]
     self.imgdata = inputimg(self.path)
     for i in range(0, y + 1):
         if self.img_combo[i].currentText() == "Magnitude":
             x = self.imgdata.magnitude
             logger.info(" Presenting Magnitude.... ")
         elif self.img_combo[i].currentText() == "Phase":
             x = self.imgdata.phaseshift
             logger.info(" Presenting Phase.... ")
         elif self.img_combo[i].currentText() == "Real":
             x = self.imgdata.realshift
             logger.info(" Presenting Real.... ")
         elif self.img_combo[i].currentText() == "Imaginary":
             x = self.imgdata.imaginaryshift
             logger.info(" Presenting Imaginary.... ")
         else:
             self.images[2 + y % 2].clear()
     self.images[2 + y % 2].setImage(x.T)
     self.images[2 + y % 2].view.setAspectLocked(False)
Exemplo n.º 7
0
    def mixer(self, z, flag):

        gain1 = self.ui.component1_slider.value()
        gain2 = self.ui.component2_slider.value()
        type1 = self.types[0].currentText()
        type2 = self.ui.component2_type.currentText()
        type22 = self.ui.component2_type.currentText()
        self.img1 = self.opimg[0].currentText()
        self.img2 = self.opimg[1].currentText()
        opchannel = self.ui.output_channel.currentText()

        if (flag):
            self.setcombotext(type1, type22)

        if (self.img1 != self.img2):

            self.path1 = self.paths[0]
            self.path2 = self.paths[1]
            self.imgmix1 = inputimg(self.path1)
            self.imgmix2 = inputimg(self.path2)
            if (type1 == "Magnitude"
                    and type2 == "Phase") or (type2 == "Magnitude"
                                              and type1 == "Phase"):
                mode = "magphase"
            elif (type1 == "Real"
                  or type1 == "Imaginary") and (type2 == "Real"
                                                or type2 == "Imaginary"):
                mode = "realimg"
            elif (type1 == "Unimagnitude"
                  and type2 == "Phase") or (type2 == "Unimagnitude"
                                            and type1 == "Phase"):
                mode = "unimag"
            elif (type1 == "Uniphase"
                  and type2 == "Magnitude") or (type2 == "Uniphase"
                                                and type1 == "Magnitude"):
                mode = "uniphase"
            elif (type1 == "Uniphase" and type2 == "Unimagnitude") or (
                    type2 == "Uniphase" and type1 == "Unimagnitude"):
                mode = "uniuni"
            else:
                logger.info("Error! Can't Mix ... ")

            try:
                if (self.img1 == "Image 1" and self.img2 == "Image 2"):
                    output = self.imgmix1.mix(self.imgmix2, gain1, gain2, mode,
                                              type1, type2)
                else:
                    output = self.imgmix2.mix(self.imgmix1, gain1, gain2, mode,
                                              type1, type2)
            except:
                pass

        try:
            if self.ui.output_channel.currentText() == "Output 1":
                self.images[4].setImage((output).T)

            elif self.ui.output_channel.currentText() == "Output 2":
                self.images[5].setImage((output).T)
        except:
            pass

        # self.output(output)
        if (self.img1 == "Image 1" and self.img2 == "Image 1"):
            # logger.warning("Mixing the same image! , Dosen't affect the image")
            self.path1 = self.paths[0]
            output = inputimg(self.path1).img

        elif (self.img1 == "Image 2" and self.img2 == "Image 2"):
            # logger.warning("Mixing the same image! , Dosen't affect the image")
            self.path1 = self.paths[1]
            output = inputimg(self.path1).img

        try:

            logger.info(
                f"Mixing {gain1}% of {self.img1} {type1} and {gain2}% of {self.img2} {type2} in {self.ui.output_channel.currentText()} at mixing mood of: {mode} "
            )

        except:
            pass