# Can I make these shapes from torch?

I want to make an image like (1). (Black is 0 and white is 1)
And I want to multiply this by the image like (2).

Finally, I want to combine the two pictures as follows.
(gradation * image1) + ((1 - gradation) * image2)

Is there any tool in pytorch(or cv2… or any fast python modules) that can create these gradation image?

I’m not sure, how you are creating the first image, but if that’s just a multivariate normal distribution, you could use `scipy` for it.
Here is a dummy code:

``````from PIL import Image
from scipy.stats import multivariate_normal
import matplotlib.pyplot as plt
import numpy as np

# Create multivariate normal
x, y = np.mgrid[-1:1:.01, -1:1:.01]
pos = np.empty(x.shape + (2,))
pos[:, :, 0] = x
pos[:, :, 1] = y
rv = multivariate_normal(mean=[0., 0.], cov=[[0.1, 0.], [0., 0.1]])
pdf = rv.pdf(pos)
plt.contourf(x, y, pdf)

# Open image
img = Image.open(IMAGE_PATH)
img = img.resize(x.shape)

# Blend both images
img_arr = np.array(img)
img_blend = img_arr * pdf[:, :, None]
img_blend = img_blend / img_blend.max()
plt.imshow(img_blend)
``````

The covariance matrix will scale the size of your normal distribution.
Setting it to a lower value basically makes to “visible window” smaller in your use case.

It doesn’t seem like a PyTorch specific question or would you like to create the multivariate normal using PyTorch or a model?