Commit 70b1c429 authored by Josef Brandt's avatar Josef Brandt

blur images in optical scan

parent c5a3864a
...@@ -25,8 +25,10 @@ import sys, os ...@@ -25,8 +25,10 @@ import sys, os
stdout = sys.stdout stdout = sys.stdout
from time import sleep from time import sleep
import numpy as np import numpy as np
import cv2
from shutil import copyfile from shutil import copyfile
from .ramanbase import RamanBase from .ramanbase import RamanBase
from ..helperfunctions import cv2imread_fix, cv2imwrite_fix
class SimulatedRaman(RamanBase): class SimulatedRaman(RamanBase):
magn = 20 magn = 20
...@@ -38,11 +40,11 @@ class SimulatedRaman(RamanBase): ...@@ -38,11 +40,11 @@ class SimulatedRaman(RamanBase):
self.currentpos = None, 0., 0. self.currentpos = None, 0., 0.
self.currentZ = 0. self.currentZ = 0.
# some plausible data to simulate consecutively changing positions # some plausible data to simulate consecutively changing positions
self.positionlist = np.array([[ -1201, 1376, -1290], self.positionlist = np.array([[ -201, 876, -1290],
[ -1195, -1200, -1279], [ -55, -900, -1279],
[ 1097, -1254, -1297], [ 1097, -754, -1297],
[ 2704.1, 1288.2, -1381], [ 2004.1, 788.2, -1381],
[ 1884. , -1500.8, -1381]]) [ 1884., -1000.8, -1381]])
self.znum = 4 self.znum = 4
self.gridnum = 36 self.gridnum = 36
self.positionindex = 0 self.positionindex = 0
...@@ -95,7 +97,17 @@ class SimulatedRaman(RamanBase): ...@@ -95,7 +97,17 @@ class SimulatedRaman(RamanBase):
assert self.connected assert self.connected
cwd = os.getcwd() cwd = os.getcwd()
fakeImgPath = os.path.join(cwd, "gepard", "fakeData/image.bmp") fakeImgPath = os.path.join(cwd, "gepard", "fakeData/image.bmp")
copyfile(fakeImgPath, fname) if fname.endswith('tmp.bmp'):
copyfile(fakeImgPath, fname)
else: # fake defocussing
img: np.ndarray = cv2imread_fix(fakeImgPath)
zLevel: int = int(fname.split('.bmp')[0].split('_')[-1])
if zLevel > 0:
blurRad: int = 8*zLevel + 1 # increase and make it odd
self.logger.info(f'blurring fake image with radius {blurRad} for z-Level {zLevel}')
img = cv2.medianBlur(img, blurRad)
cv2imwrite_fix(fname, img)
self.imageindex = (self.imageindex+1)%(self.znum*self.gridnum) self.imageindex = (self.imageindex+1)%(self.znum*self.gridnum)
sleep(.01) sleep(.01)
......
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