Python Forum
How do I apply a Gaussian blur to a particular edge of geometry in Matplotlib?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I apply a Gaussian blur to a particular edge of geometry in Matplotlib?
#1
I want to apply Gaussian blur to a particular edge of polygons. The code below generates 4 white polygons in black rectangle which the left edge in green (fig below). I want to apply the Gaussian blur just to that green edge.Please note that I can't apply cv.circle or cv.rectangle since the location of green edge is changing in each polygon.

[Image: mjXc4.png]


Quote:import numpy as np
import matplotlib.pyplot as plt
import cv2 as cv

pixels = 600
my_dpi = 100
num_geo=3

coord = np.array([[[-150, -200], [300, -200], [300, 0], [150, 200], [-150, 200]],
[[-300, -200], [200, -300], [200, -50], [200, 300], [-150, 200]],
[[-140, -230], [350, -260], [350, 0], [140, 200], [-180, 220]],
[[-180, -240], [370, -270], [370, 0], [170, 200], [-190, 230]]])

for i in range(4):
geo = coord[i, :, :]
fig = plt.figure(num_geo,figsize=( pixels/my_dpi, pixels/my_dpi),facecolor='k', dpi=my_dpi)
plt.axes([0,0,1,1])
rectangle = plt.Rectangle((-300, -300), 600, 600, fc='k')
plt.gca().add_patch(rectangle)
polygon = plt.Polygon(coord[i],color='w')
plt.gca().add_patch(polygon)
b=plt.plot([coord[i][0][0], coord[i][-1][0]], [coord[i][0][1], coord[i][-1][1]], color='#008000', lw=4)
img = cv.blur(b,(5,5))
plt.axis('off')
plt.axis([-300,300,-300,300])
plt.savefig('figure2/%d.png' % i, dpi=my_dpi)
plt.close()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Networkx: Visualize an edge weight with a bubble/circle uvw 0 1,947 Sep-01-2021, 06:26 AM
Last Post: uvw
  Returning values from Gaussian fitting Laplace12 0 1,549 Aug-05-2021, 08:09 AM
Last Post: Laplace12
  Fitting Gaussian curve to data file Laplace12 0 2,673 Jun-09-2021, 10:45 AM
Last Post: Laplace12
  IF statement to apply at each date illmattic 2 2,599 Apr-08-2021, 12:31 PM
Last Post: illmattic
  Matplotlib: How do I convert Dates from Excel to use in Matplotlib JaneTan 1 3,162 Mar-11-2021, 10:52 AM
Last Post: buran
  Rotate 2D Gaussian given parameters schniefen 4 2,845 Dec-11-2020, 03:34 PM
Last Post: schniefen
Photo Setting Marker Edge Color In Plotting JoeDainton123 0 2,660 Oct-26-2020, 10:48 PM
Last Post: JoeDainton123
  Multi-gaussian function Laplace12 5 3,926 Jul-21-2020, 11:38 PM
Last Post: scidam
  Import Text, output curve geometry Alyner 0 1,933 Feb-03-2020, 03:05 AM
Last Post: Alyner
  How to apply VLookup formula jonzee 2 3,502 Jan-12-2020, 04:16 PM
Last Post: Clunk_Head

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020