def _update_image(self): wt = WaitProcess wt.run() wt.change_info("Obteniendo imagen") wt.change_value(5) id = self._images_ui_synchronizer.get_selected_image_id() #verificar si la imagen seleccionada es distinta de la imagen actual clean_pipes = (Application.get_current_image_id() != id) #limpia las tuberías en caso de ser necesario if id is not None: if clean_pipes: Application.get_current_document().clean_pipes() wt.change_info("Cambiando imagen") wt.change_value(50) Application.set_current_image_id(id) #cambiar la imagen actual img = Application.get_current_image() #obtener la imagen actual self._ui.imageName.setText( img.DisplayName) #actualiza el nombre mostrado de la imagen wt.change_info("Visualizando imagen") wt.change_value(65) #actualizar la vista de los tres planos de la imagen self._planes.Image = img #habilitar el procesameinto de la imagen self._ui.processImage.setEnabled(True) #habilitar la configuración de los filtros self._ui.filters.setEnabled(True) #habilitar la salva de la configuración de los filtros self._ui.actionGuardar_2.setEnabled(True) #habilitar la carga de la configuración de los filtros self._ui.actionCargar_configuraci_n.setEnabled(True) #actualizar la información de los filtros self._filters_ui_synchronizer.update() wt.stop()
def _update_current_image_name(self, item, col): id = self._images_ui_synchronizer.get_selected_image_id() img = Application.get_current_image() if id is None or img is None: return if id == img.Id and col == 1 and item.text(0) == "Nombre": self._ui.imageName.setText(item.text(1))
def _update_filters(self,item,col): """ Actualiza las propiedades de los filtros luego de editarlas @param item: item que se editó @param col: columna del item que se editó @return: None """ #cambiaron la etiqueta de la propiedad no el valor if col == 0: self._update_editable_labels() if item.text(0) == "Suavizador": Application.get_current_document().useSmoother(item.checkState(0) == Qt.Checked) elif item.text(0) == "Segmentador": Application.get_current_document().useSegmentor(item.checkState(0) == Qt.Checked) elif item.text(0) == "Segmentador estadístico": Application.get_current_document().useConfidenceConnected(item.checkState(0) == Qt.Checked) elif item.text(0) == "Votación": Application.get_current_document().useVoter(item.checkState(0) == Qt.Checked) return if item.text(0) == "Iteraciones" and item.parent().text(0) == "Suavizador": try: num = int(item.text(1)) if num<0 or num>20: raise ValueError() Application.get_current_document()._smooth_pipe.NumberOfIterations = num except ValueError: pass elif item.text(0) == "Iteraciones" and item.parent().text(0) == "Segmentador estadístico": try: num = int(item.text(1)) if num<0 or num>50: raise ValueError() Application.get_current_document()._confidence_connected_pipe.NumberOfIterations = num except ValueError: pass elif item.text(0) == "Paso de tiempo": try: num = float(item.text(1)) if num<0.0 or num>1.0: #límites del paso de tiempo raise ValueError() Application.get_current_document()._smooth_pipe.TimeStep = num except ValueError: pass elif item.text(0) == "Conductancia": try: num = float(item.text(1)) if num<0.0 or num>100.0: #límites rasonables de conductancia raise ValueError() Application.get_current_document()._smooth_pipe.Conductance = num except ValueError: pass elif item.parent().text(0) == "Semilla" and item.parent().parent().text(0) == "Segmentador": #los hijos de 'Semilla' son las coordenadas seed = [ self._seedX_prop.text(1), self._seedY_prop.text(1), self._seedZ_prop.text(1) ] try: seed = map(int,seed) #verificar que no se incluya como semilla un valor mayor que el tamaño de la imagen o #menor que cero if any(map(lambda x: x<0,seed)) or\ any(imap(lambda x,y: x>=y,seed,Application.get_current_image().Size)): raise ValueError() Application.get_current_document()._segment_pipe.Seed = seed except ValueError: pass elif item.parent().text(0) == "Semilla" and item.parent().parent().text(0) == "Segmentador estadístico": #los hijos de 'Semilla' son las coordenadas seed = [ self._conf_seedX_prop.text(1), self._conf_seedY_prop.text(1), self._conf_seedZ_prop.text(1) ] try: seed = map(int,seed) #verificar que no se incluya como semilla un valor mayor que el tamaño de la imagen o #menor que cero if any(map(lambda x: x<0,seed)) or\ any(imap(lambda x,y: x>=y,seed,Application.get_current_image().Size)): raise ValueError() Application.get_current_document()._confidence_connected_pipe.Seed = seed except ValueError: pass elif item.text(0) == "Mínimo": try: min = float(self._min_threshold_prop.text(1)) Application.get_current_document()._segment_pipe.LowerThreshold = min except ValueError: pass elif item.text(0) == "Máximo": try: max = float(self._max_threshold_prop.text(1)) Application.get_current_document()._segment_pipe.UpperThreshold = max except ValueError: pass elif item.text(0) == "Relleno" and item.parent().parent().text(0) == "Segmentador": try: val = float(self._replace_value_prop.text(1)) Application.get_current_document()._segment_pipe.ReplaceValue = val except ValueError: pass elif item.text(0) == "Relleno" and item.parent().parent().text(0) == "Segmentador estadístico": try: val = float(self._conf_repl_value_prop.text(1)) Application.get_current_document()._confidence_connected_pipe.ReplaceValue = val except ValueError: pass elif item.parent().text(0) == "Radio": radius = [ self._radiusX_prop.text(1), self._radiusY_prop.text(1), self._radiusZ_prop.text(1) ] try: radius = map(str,radius) radius = map(int,radius) #verificar que no se incluya como radio un valor sensato (por ahora entre 0 y 20) if any(map(lambda x: x<0 or x>20,radius)): raise ValueError() Application.get_current_document()._voting_pipe.Radius = radius except ValueError: pass elif item.text(0) == "Radio inicial": try: val = int(self._conf_radius_prop.text(1)) if val<0 or val>20: raise ValueError() Application.get_current_document()._confidence_connected_pipe.InitialRadius = val except ValueError: pass elif item.text(0) == "Multiplicador": try: val = float(self._conf_mult_value_prop.text(1)) if val<0: raise ValueError() Application.get_current_document()._confidence_connected_pipe.Multiplier = val except ValueError: pass elif item.text(0) == "Fondo": try: val = int(self._background_prop.text(1)) if val<0 or val>255: raise ValueError() Application.get_current_document()._voting_pipe.Background = val except ValueError: pass elif item.text(0) == "Máscara": try: val = int(self._foreground_prop.text(1)) if val<0: raise ValueError() Application.get_current_document()._voting_pipe.Foreground = val except ValueError: pass elif item.text(0) == "Supervivencia": try: val = int(self._survival_prop.text(1)) if val<0: raise ValueError() Application.get_current_document()._voting_pipe.SurvivalValue = val except ValueError: pass elif item.text(0) == "Nacimiento": try: val = int(self._birth_prop.text(1)) if val<0: raise ValueError() Application.get_current_document()._voting_pipe.BirthValue = val except ValueError: pass self._update_filters_properties()