-
Notifications
You must be signed in to change notification settings - Fork 27
Change some matplotlib.tri calls to use scipy.spatial.Delaunay #649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) | ||
| #ys = T.y[T.triangles] # y posititions of vertices [nm], dimensions (# triangles, 3) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. E265: block comment should start with '# ' |
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. E231: missing whitespace after ',' There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
@@ -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)): | ||
|
|
@@ -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) | ||
|
|
||
|
|
@@ -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') | ||
|
|
@@ -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)))[:] | ||
|
|
@@ -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] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
@@ -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): | ||
|
|
@@ -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) | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
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 '# '