示例#1
0
 def go_result(self):
     mpp = float(self.txtMPP.text())  # micrometers per pixel
     self.data = pycv.evaluate(self.cnts, mpp)
     elements = []
     if self.chbContours.isChecked():
         elements.append(('contour', (255, 255, 255)))
     if self.chbFitting.isChecked():
         elements.append(('fit', (0, 255, 0)))
     if self.chbIndex.isChecked():
         elements.append(('index', (255, 255, 255)))
     if self.chbAngle.isChecked():
         elements.append(('angle', (255, 0, 0)))
     self.imres = pycv.draw(self.im1, self.cnts, elements)
     pycv.shown([self.imres], True, True, 0, 0,True, 'Resulting Image')
示例#2
0
    def go_thresholding(self):
        self.im1 = self.imoriginal.copy()
        self.im2 = self.imisolated.copy()

        b = int(self.txtBottom.text())
        t = int(self.txtTop.text())
        l = int(self.txtLeft.text())
        r = int(self.txtRight.text())
        self.im1 = pycv.crop(self.im1, b, t, l, r)
        self.im2 = pycv.crop(self.im2, b, t, l, r)
        self.im2 = pycv.gray(self.im2)  # for analysis
        self.im1_canvas = self.im1.copy()  # original for visual
        self.im2_canvas = pycv.rgb(self.im2.copy())  # analysis for visual
        fig, axarr, self.thresh_ims = pycv.shown([self.im1_canvas, self.im2_canvas], False, True, AxisVisible=False,
                                                 Title='Thresholding')
        # Sliders
        # Slider Threshold
        ax_slid_th = plt.axes([0.1, 0.01, 0.8, 0.02])  # left, bottom, width, height
        self.slid_th = Slider(ax_slid_th, 'THRESHOLD', 0, 100, valinit=50)
        self.slid_th.on_changed(self.go_thresholding_update)
        # Slider GAUSS-BLUR
        ax_slid_blurk = plt.axes([0.1, 0.03, 0.8, 0.02])
        height, width = pycv.img_size(self.im2)
        self.slid_blurk = Slider(ax_slid_blurk, 'BLUR', 1, int(max([height, width]) / 20), valinit=5)
        self.slid_blurk.on_changed(self.go_thresholding_update)
        self.go_thresholding_update(0)
        plt.show()
示例#3
0
 def imisolated_crop(self):
     fig, self.cropax, ims = pycv.shown([self.imisolated], False, True, 0, 0, True, 'CROP ISOLATED IMAGE')
     (h, w) = pycv.img_size(self.imisolated)
     self.cropax[0].set_xlim([int(self.txtLeft.text()), w - int(self.txtRight.text())])
     self.cropax[0].set_ylim([h - int(self.txtBottom.text()), int(self.txtTop.text())])
     ax_apply = plt.axes([0.85, 0.05, 0.1, 0.05])  # left, bottom, width, height
     btnApply = Button(ax_apply, 'APPLY')
     btnApply.on_clicked(self.imisolated_crop_apply)
     ax_reset = plt.axes([0.75, 0.05, 0.1, 0.05])  # left, bottom, width, height
     btnReset = Button(ax_reset, 'RESET')
     btnReset.on_clicked(self.imisolated_crop_reset)
     plt.show()
示例#4
0
 def imisolated_manipulate(self):
     try:
         imr, img, imb = cv2.split(self.imisolated)
         fig, axarr, self.ims = pycv.shown([self.imisolated, imr, img, imb], False, True, AxisVisible=False,
                                           Title='Manipulate Isolated Image')
         ax_s_r = plt.axes([0.1, 0.05, 0.8, 0.02])  # left, bottom, width, height
         ax_s_g = plt.axes([0.1, 0.03, 0.8, 0.02])
         ax_s_b = plt.axes([0.1, 0.01, 0.8, 0.02])
         self.slid_r = Slider(ax_s_r, 'RED', 0.0, 3.0, valinit=1)
         self.slid_g = Slider(ax_s_g, 'GREEN', 0.0, 3.0, valinit=1)
         self.slid_b = Slider(ax_s_b, 'BLUE', 0.0, 3.0, valinit=1)
         self.slid_r.on_changed(self.imisolated_manipulate_update)
         self.slid_g.on_changed(self.imisolated_manipulate_update)
         self.slid_b.on_changed(self.imisolated_manipulate_update)
         fig.canvas.mpl_connect('close_event', self.imisolated_manipulate_close)
         plt.show()
     except:
         print('Error while trying to open manipulate window.')
示例#5
0
 def cal_determine(self):
     try:
         img = pycv.load(self.txtImgOriginal.text())
         fig, axarr, ims = pycv.shown([img], False, True, AxisVisible=True,
                                      Title='MAKE ZOOM RECTANGLE ON SCALE BAR AND CLOSE')
         plt.title("Zoom to scale bar and click APPLY. Close the window to abort.")
         ax_apply = plt.axes([0.85, 0.05, 0.1, 0.05])  # left, bottom, width, height
         btnApply = Button(ax_apply, 'APPLY')
         btnApply.on_clicked(self.cal_determine_apply)
         plt.show()
         if self.determine_apply:
             dx = axarr[0].get_xlim()
             x1 = int(numpy.ceil(dx[0]))
             x2 = int(numpy.ceil(dx[1]))
             p = x2 - x1
             self.txtPixels.setText(str(p))
             self.btnEqual.click()
     except Exception as e:
         print(e)
         self.statusBar.showMessage('Error while loading Master image for pixel calibration!')
示例#6
0
 def imisolated_show(self):
     if self.imisolated is not None:
         pycv.shown([self.imisolated], True, False, AxisVisible=False, Title='Isolated Image')
示例#7
0
 def imoriginal_show(self):
     if self.imoriginal is not None:
         pycv.shown([self.imoriginal], True, False, AxisVisible=False, Title='Original Image')