创建一个由两个均值相同但方差不同的区域组成的图像 Python

Create an image made up of two regions with identical means but different variances Python

我们如何在 python 中创建由两个均值相同但方差不同的区域组成的图像(使用正常定律的实现创建的区域强度)。

我找到了这个小代码,但我不知道它是否真的是这样的:

  I = np.random.normal (128,10, (256, 256)); 
  Icentre = np.random.normal (128,50, (80, 80))
  I [100: 180,100: 180] = Icentre;

我正在研究全变分分割,所以第二部分是制作一个与图像大小相对应的掩码 m,然后使用该图像测试分割过程

有几个选项,一个是将两个图像连接在一起。例如:

import numpy as np

im1 = np.random.normal(128, 10, (256, 256)) #mean of 128, std of 10
im2 = np.random.normal(128, 6, (256, 256)) #mean of 128, std of 6

# create image from both regions, shape = (512, 256)
img = np.concatenate((im1, im2))

在此示例中,第 0-255 行的平均值为 128,标准差为 10,而第 256-512 行的平均值为 128,标准差为 6。

您上面发布的代码也可以。在这种情况下,您要将 Icentre 插入 I,从 row=100col=100 开始,到 row=180col=180 结束。