Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions PYME/LMVis/visHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,12 @@ def rendGaussProd(x,y, sx, imageBounds, pixelSize):

def rendTri(T, imageBounds, pixelSize, c=None, im=None, geometric_mean=False):
from PYME.Analysis.points.SoftRend import drawTriang, drawTriangles
xs = T.x[T.triangles] # x posititions of vertices [nm], dimensions (# triangles, 3)
ys = T.y[T.triangles] # y posititions of vertices [nm], dimensions (# triangles, 3)
#xs = T.x[T.triangles] # x posititions of vertices [nm], dimensions (# triangles, 3)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E265: block comment should start with '# '

#ys = T.y[T.triangles] # y posititions of vertices [nm], dimensions (# triangles, 3)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E265: block comment should start with '# '


Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W293: blank line contains whitespace

verts = T.points[T.simplices]
xs = verts[:,:,0]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E231: missing whitespace after ','

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E231: missing whitespace after ','

ys = verts[:,:,1]

if c is None:
# We didn't pass anything in for c - use 1/ area of triangle
Expand Down Expand Up @@ -356,7 +360,7 @@ def rendTri(T, imageBounds, pixelSize, c=None, im=None, geometric_mean=False):


def rendJitTri(im, x, y, jsig, mcp, imageBounds, pixelSize, n=1, seed=None):
from matplotlib import tri
from scipy.spatial import Delaunay
np.random.seed(seed)

for i in range(int(n)):
Expand All @@ -367,7 +371,9 @@ def rendJitTri(im, x, y, jsig, mcp, imageBounds, pixelSize, n=1, seed=None):
jsig2 = jsig[Imc]
else:
jsig2 = float(jsig)
T = tri.Triangulation(x[Imc] + jsig2*np.random.randn(Imc.sum()), y[Imc] + jsig2*np.random.randn(Imc.sum()))

T = Delaunay(np.vstack([x[Imc] + jsig2*np.random.randn(Imc.sum()), y[Imc] + jsig2*np.random.randn(Imc.sum())]).T)


rendTri(T, imageBounds, pixelSize, im=im, geometric_mean=False)

Expand All @@ -378,7 +384,7 @@ def rendJitTri(im, x, y, jsig, mcp, imageBounds, pixelSize, n=1, seed=None):


def _rend_jit_tri_geometric(im, x, y, jsig, mcp, imageBounds, pixelSize, n=1, seed=None):
from matplotlib import tri
from scipy.spatial import Delaunay
np.random.seed(seed)

#im_ = numpy.zeros(im.shape, 'f')
Expand All @@ -394,8 +400,8 @@ def _rend_jit_tri_geometric(im, x, y, jsig, mcp, imageBounds, pixelSize, n=1, se
jsig2 = jsig[Imc]
else:
jsig2 = float(jsig)
T = tri.Triangulation(x[Imc] + jsig2 * np.random.randn(Imc.sum()), y[Imc] + jsig2 * np.random.randn(Imc.sum()))


T = Delaunay(np.vstack([x[Imc] + jsig2 * np.random.randn(Imc.sum()), y[Imc] + jsig2 * np.random.randn(Imc.sum())]).T)
rendTri(T, imageBounds, pixelSize, im=im, geometric_mean=True)

#im[:] = (im + (im_))# + 1e9*(im_ <=0)))[:]
Expand Down Expand Up @@ -540,8 +546,11 @@ def rendJitTriang(x,y,n,jsig, mcp, imageBounds, pixelSize, seeds=None, geometric

def rendTri2(T, imageBounds, pixelSize, c=None, im=None, im1=None):
from PYME.Analysis.points.SoftRend import drawTriang, drawTriangles
xs = T.x[T.triangles]
ys = T.y[T.triangles]
#xs = T.x[T.triangles]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E265: block comment should start with '# '

#ys = T.y[T.triangles]
verts = T.points[T.simplices]
xs = verts[:,:,0]
ys = verts[:,:,1]

a = np.vstack((xs[:, 0] - xs[:, 1], ys[:, 0] - ys[:, 1])).T
b = np.vstack((xs[:, 0] - xs[:, 2], ys[:, 0] - ys[:, 2])).T
Expand Down Expand Up @@ -588,7 +597,7 @@ def rendTri2(T, imageBounds, pixelSize, c=None, im=None, im1=None):
return im, im1

def rendJitTri2(im, im1, x, y, jsig, mcp, imageBounds, pixelSize, n=1):
from matplotlib import tri
from scipy.spatial import Delaunay
np.random.seed()

for i in range(n):
Expand All @@ -601,8 +610,7 @@ def rendJitTri2(im, im1, x, y, jsig, mcp, imageBounds, pixelSize, n=1):
else:
jsig2 = float(jsig)

T = tri.Triangulation(x[Imc] + jsig2*np.random.randn(Imc.sum()), y[Imc] + jsig2*np.random.randn(Imc.sum()))

T = Delaunay(np.vstack([x[Imc] + jsig2*np.random.randn(Imc.sum()), y[Imc] + jsig2*np.random.randn(Imc.sum())]).T)
rendTri2(T, imageBounds, pixelSize, im=im, im1=im1)


Expand Down