Making closed curves with random shapes filled with a solid color in matplotlib or OpenCV-python

Viewed 26

To create a dataset for deep learning, I need to produce gray-scale images like this:

enter image description here

To give you a context, it is droplet passing light. There I four features I need to produce which have been specified by a number:

  1. Backround - usually a shade of gray
  2. A light halo around the droplet
  3. A dark shadow
  4. A focused light

#3&4 could get thinner or wider or lighter and darker.

The shape of the droplet is a small deviation from the sphere.

My idea was to make randomly-deviated curve from a circle like this:

H = 10
rho = np.random.rand(H)*np.logspace(-0.5,-2.5,H)
phi = np.random.rand(H)* 2*np.pi

t = np.linspace(0,2*np.pi,101)
r = np.ones(len(t))
for h in range(H):
    r = r + rho[h]*np.sin(h*t+phi[h])
x = r * np.cos(t)
y = r * np.sin(t)

I need to create three closed curves and fill them with solid color and add a blur effect. Is it possible to do this in matplotlib? Can I use an equation to specify a contour in OpenCV and then do those operations?

0 Answers
Related