Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 78cca4dc authored by NADAL Morgane's avatar NADAL Morgane
Browse files

corrected bugs in image_verification.py

parent 69e65a7e
No related branches found
No related tags found
No related merge requests found
......@@ -30,23 +30,25 @@
# knowledge of the CeCILL license and that you accept its terms.
import sys as sy_
from PySide2.QtGui import QImage, QPixmap
from PySide2.QtWidgets import *
import skimage.io as io_
import matplotlib as mpl_
import matplotlib.pyplot as pl_
import numpy as np_
from brick.general.type import array_t
mpl_.use('TkAgg')
channel = 'G'
data_path = '../../data/DIO_6H_6_1.70bis_2.2_3.tif'
data_path = 'D:/MorganeNadal/PyCharm/nutrimorph/data/DIO_6H_6_1.70bis_2.2_3.tif'
image = io_.imread(data_path)
class image_verification(QWidget):
def __init__(self, image: array_t, channel: str, parent=None):
def __init__(self, image: array_t = None, channel: str = None, parent=None):
super(image_verification, self).__init__(parent)
# Create widgets
# --Text
......@@ -67,6 +69,7 @@ class image_verification(QWidget):
if image is not None:
self.ImVerif(image, channel)
# self.PlotImage(image)
def Continue(self):
self.close()
......@@ -74,6 +77,14 @@ class image_verification(QWidget):
def Quit(self):
sy_.exit(0)
# def PlotImage(self, image: array_t) -> None :
# im = image.copy()
# im = np_.rint(im).astype(np_.uint8)
# im = QImage(im, im.shape[1], im.shape[0], im.shape[1] * 3, QImage.Format_RGB888)
# pix = QPixmap.fromImage(im)
# img = QLabel(self)
# img.setPixmap(pix)
def ImVerif(self, image: array_t, channel: str) -> array_t:
# The image must not be constant
if image.max() == image.min():
......@@ -91,21 +102,20 @@ class image_verification(QWidget):
pl_.imshow(image[10, :, :])
pl_.show(block=True)
layout = QVBoxLayout()
layout.addWidget(self.text1)
layout.addWidget(self.button_continue)
self.setLayout(layout)
text = self.text1
if channel is not None:
value_error = f'The image has only 3 dimensions. However, a value for the "channel" parameter is '
f'specified : {channel}. Give the channel the value None?'
value_error = f'The image has only 3 dimensions. However, a value for the "channel" parameter is ' \
f'specified : {channel}. Give the channel the value None? '
print(value_error)
text = self.text2
layout = QVBoxLayout()
layout.addWidget(self.text2)
layout.addWidget(self.button_continue)
layout = QVBoxLayout()
layout.addWidget(text)
layout.addWidget(self.button_continue)
if text == self.text2:
layout.addWidget(self.button_quit)
self.setLayout(layout)
self.setLayout(layout)
elif image.ndim == 4:
if channel == 'R' or channel == 'G' or channel == 'B':
......@@ -113,22 +123,23 @@ class image_verification(QWidget):
value_error = f'The image has multiple color channels. The channel {channel} is specified in the ' \
f'parameters. '
print(value_error)
text = self.text3
image = image[:, :, :, 'RGB'.find(channel)]
pl_.imshow(image[10, :, :])
pl_.show(block=True)
# The obtained image must not be constant
if image.max() == image.min():
text = self.text0
layout = QVBoxLayout()
layout.addWidget(self.text3)
layout.addWidget(self.button_continue)
layout.addWidget(text)
if text == self.text3:
layout.addWidget(self.button_continue)
layout.addWidget(self.button_quit)
self.setLayout(layout)
# TODO: Viewing bug when channel = 'R' or 'B'
# The obtained image must not be constant
if image.max() == image.min():
raise ValueError('The image input must not be constant.')
return image # TODO: How to return the image ??
else:
......@@ -149,10 +160,7 @@ class image_verification(QWidget):
if __name__ == '__main__':
# Create the Qt Application
app = QApplication(sy_.argv)
# Create and show the form
verif = image_verification(image, channel)
verif.show()
sy_.exit(app.exec_())
\ No newline at end of file
sy_.exit(app.exec_())
......@@ -42,6 +42,7 @@ import brick.component.extension as xt_
import brick.component.soma as sm_
import brick.general.feedback as fb_
import brick.processing.input as in_
import brick.processing.image_verification as iv_
# from main_prm import *
import os as os_
......@@ -96,7 +97,7 @@ image = io_.imread(data_path)
# Image size verification - simple version without user interface
image = in_.ImageVerification(image, channel)
# TODO make a user friendly interface (PySide2) /!\ conflicts between some versions of PySide2 and Python3
# /!\ conflicts between some versions of PySide2 and Python3
image = image[:, 512:, 512:] # 562
img_shape = image.shape
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment