Commit 5a37c671 authored by Robert's avatar Robert Committed by Robert Ohmacht

-fixes transition from optical scan to raman scan

-detectionview uses unscaled image
parent 819efb02
......@@ -274,7 +274,7 @@ class ParticleDetectionView(QtWidgets.QWidget):
super().__init__(parent, QtCore.Qt.Window)
self.dataset = self.verifySeedpoints(dataset)
self.pyramid = pyramid
self.img = pyramid.getFullImage(.5)
self.img = pyramid.getFullImage()
self.imgclip = 0, 0, 0, 0
self.seg = Segmentation(self.dataset, self)
self.thread = None
......
......@@ -351,7 +351,7 @@ class SampleView(QtWidgets.QGraphicsView):
if not self.ramanctrl.connected:
return None
maxmode = "OpticalScan"
if os.path.exists(self.dataset.getImageName()):
if os.path.exists(self.dataset.getZvalImageName()):
maxmode = "ParticleDetection"
if self.dataset.particleDetectionDone:
maxmode = "RamanScan"
......
......@@ -462,46 +462,6 @@ class ScenePyramid:
"""
self.microscopeMode = microscopemode
def getFullImage(self, scale):
"""
returns full size image
for this we use numpy to concatenate the tile images
:param: float scale
:return: full size image
:rtype: np.array
"""
first_col = True
img = None
col = None
# for big images use np.concatenate
# for each tile col
for x in range(len(self.tileWorkingSets[0])):
first_tile = True
# for each tile in col
for y in range(len(self.tileWorkingSets[0][x])):
tile = self.readViewTile(0, x, y)
if 1. != scale:
w = math.floor(scale * tile.shape[1])
h = math.floor(scale * tile.shape[0])
tile = np.array(Image.fromarray(tile).resize((w, h), resample=Image.BICUBIC))
if not first_tile:
col = np.concatenate((col, tile), axis=0)
else:
col = tile
first_tile = False
# self.imageOut(col, f"_col_{x}_{y}.tif")
# self.imageOut(col, f"_col_{x}.tif")
if not first_col:
img = np.concatenate((img, col), axis=1)
else:
img = col
first_col = False
# self.imageOut(img, f"_fullimage.tif")
return img
def getBoundingRectDim(self):
"""
returns bounding rectangle of all currently rendered tiles
......@@ -513,24 +473,6 @@ class ScenePyramid:
self.scene.destroyItemGroup(group)
return rect.width(), rect.height()
def getSubImage(self, clip):
"""
:param (int, int, int, int) clip: (y1, y2, x1, x2)
:return:
:rtype: (np.array, QtGui.QPixmap)
"""
y1, y2, x1, x2 = clip
width = x2 - x1
height = y2 - y1
subimg = self.getImagePart(y1, y2, x1, x2)
pix = QtGui.QPixmap()
pix.convertFromImage(
QtGui.QImage(subimg, width, height, 3 * width, QtGui.QImage.Format_RGB888)
)
return subimg, pix
def addSrcTileSimple(self, img, pos, p):
"""
gets called by opticalscan.takePoint() in scan setup process
......@@ -811,6 +753,24 @@ class ScenePyramid:
p['maxSliceNumber'] = slice_nr - 1
dset.setPyramidParams(p)
def getSubImage(self, clip):
"""
:param (int, int, int, int) clip: (y1, y2, x1, x2)
:return:
:rtype: (np.array, QtGui.QPixmap)
"""
y1, y2, x1, x2 = clip
width = x2 - x1
height = y2 - y1
subimg = self.getImagePart(y1, y2, x1, x2)
pix = QtGui.QPixmap()
pix.convertFromImage(
QtGui.QImage(subimg, width, height, 3 * width, QtGui.QImage.Format_RGB888)
)
return subimg, pix
def getImagePart(self, p0y, p1y, p0x, p1x):
"""
returns part of the full img
......@@ -871,8 +831,50 @@ class ScenePyramid:
cv2.warpAffine(tile, m_trans, size, img, flags=cv2.INTER_CUBIC, borderMode=cv2.BORDER_TRANSPARENT)
# comment in(?) to check result in tile path
self.imageOut(img, f"_image_part.tif")
# self.imageOut(img, f"_image_part.tif")
return img
def getFullImage(self, scale=1.):
"""
returns full image scaled to the given value
for this we use numpy to concatenate the tile images
:param: float scale
:return: full size image
:rtype: np.array
"""
assert 0. <= scale <= 1.
first_col = True
img = None
col = None
# for big images use np.concatenate
# for each tile col
for x in range(len(self.tileWorkingSets[0])):
first_tile = True
# for each tile in col
for y in range(len(self.tileWorkingSets[0][x])):
tile = self.readViewTile(0, x, y)
if 1. != scale:
w = math.floor(scale * tile.shape[1])
h = math.floor(scale * tile.shape[0])
tile = np.array(Image.fromarray(tile).resize((w, h), resample=Image.BICUBIC))
if not first_tile:
col = np.concatenate((col, tile), axis=0)
else:
col = tile
first_tile = False
# self.imageOut(col, f"_col_{x}_{y}.tif")
# self.imageOut(col, f"_col_{x}.tif")
if not first_col:
img = np.concatenate((img, col), axis=1)
else:
img = col
first_col = False
# self.imageOut(img, f"_fullimage.tif")
return img
def imageOut(self, img, name):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment