分形显微镜模拟器
我曾开发过用于控制成像硬件(例如显微镜)的软件,但有时很难找到时间。这意味着很难测试需要访问仪器的新的/不同的算法。我想创建一个可用于其中一些测试目的的合成仪器,并且我正在考虑使用某种分形图像生成来创建合成图像。关键是能够以某种确定性的方式在许多不同的“放大倍数”和位置生成特征。这是因为一些正在测试的算法可能需要平移/缩放并重新定位先前的“成像”区域。然后,我可以在这些基础图像上应用任何合适的仪器“缺陷”(焦点、噪声、饱和度等)。
我对如何为基本图像选择/实现良好的分形算法感到有点困惑。任何帮助将不胜感激。它最好具有以下品质:
- 快速渲染新图像区域。
- 在尽可能多的地点和规模上进行相当广泛的“特征”覆盖。
- 具有确定性(但从随机起始参数初始化)。
- 能够进行调整以使图像看起来更像“真实”图像。
第 2 项很重要,例如曼德尔布罗特集,其具有大的平滑/空区域,可能不好,因为控制合成范围的软件可能落入这些区域之一。
到目前为止,我已经考虑使用类似曼德尔布罗特的东西,但随机移动/旋转/缩放并合并两个或多个分形集以获得更完整的“特征”覆盖。
我还看到了分形火焰算法的图像,它们似乎生成了可能有用的图像(而且看起来很漂亮)。
最后,我考虑过使用某种暂停的粒子模拟运行来生成更像细胞的图像(我当前的成像目标),但我不确定这种方法是否可以满足其他要求。
编辑: @Jeffrey - 所以听起来某种地形生成可能是可行的方法,只要我完全控制 PSRNG。也许我可以使用一些存储的初始种子 + x 位置 + y 位置来生成我的随机数?但是我不确定如何一致地生成跨尺度的地形,除了,正如您所提到的,以最粗的尺度创建基础地形,并在某些预先确定的“放大倍数”下向该基础添加新的确定性伪随机变化。我还必须小心何时生成下一级别的地形,因为如果我过于激进,我就必须适当地生成并集成结果以在较粗糙的级别上显示......这就是我最初的原因倾向于更“传统”的分形,因为这种来自更精细尺度的整合将被更隐式地处理(我认为)。
I've done work on software used for controlling imaging hardware, such as microscopes, that are sometimes hard to get time on. This means it is difficult to test out new/different algorithms which would require access to the instrument. I'd like to create a synthetic instrument that could be used for some of these testing purposes, and I was thinking of using some kind of fractal image generation to create the synthetic images. The key would be to be able to generate features at many different 'magnifications' and locations in some sort of deterministic manner. This is because some of the algorithms being tested may need to pan/zoom and relocate previously 'imaged' areas. Onto these base images I can then apply whatever instrument 'defects' are appropriate (focus, noise, saturation, etc.).
I'm at a bit of a loss on how to select/implement a good fractal algorithm for the base image. Any help would be appreciated. Preferably it would have the following qualities:
- Be fast at rendering new image areas.
- Fairly wide 'feature' coverage at as many locations and scales as possible.
- Be deterministic (but initialized from random starting parameters).
- Ability to tune to make images look more like 'real' images.
Item 2 is important, for example a mandelbrot set, with its large smooth/empty regions, might not be good since the software controlling the synthetic scope might fall into one of these areas.
So far I've thought of using something like a mandelbrot, but randomly shifting/rotating/scaling and merging two or more fractal sets to get more complete 'feature' coverage.
I've also seen images of the fractal flame algorithms and they seem to generate images that might be useful (and nice to look at).
Finally, I've thought of using some sort of paused particle simulation run to generate images that are more cell-like (my current imaging target), but I'm not sure if this approach can be made to work with the other requirements.
Edit:
@Jeffrey - So it sounds like some kind of terrain generation might be the way to go, as long as I have complete control over the PSRNG. Perhaps I can use some stored initial seed + x position + y position to generate my random numbers? But then I am unsure of how to consistently generate the terrains across scales, except, as you mentioned, to create the base terrain at the coursest scale, and at certain pre-determined 'magnifications' add new deterministic pseudo-random variations to this base. I'd also have to be careful about when to generate the next level of terrain, since if I'm too aggressive I'd have to generate and integrate the results appropriately for display at the coarser level... This is why I initially was leaning toward a more 'traditional' fractal, since this integration from finer scales would be handled more implicitly (I think).
分形地形创建算法背后的想法是分别构建每个比例的图像。对于景观来说,这很简单:只需制作一小组高度值,然后随机设置它们即可。然后将其放大到更大的数组,对值进行平均,以使轮廓平滑,然后向这些值添加小的随机量。然后按比例放大等等,原来的小凹凸已经变成了山,里面布满了复杂的地形。
不过,这里提出的问题有两个特别的困难。首先,您不想存储任何这些值,因为它可能会很大。其次,每个尺度的特征与其他尺度的特征属于不同类型。
这些问题并非无法克服。
基本上,您可以将图像划分为网格,并使用确定性伪随机数确定网格中每个方块的关键特征。例如,每个方格可以具有一定密度的细胞类型。
在下一个放大级别,将每个方块细分为另一个网格,在网格上应用基于包含方块及其周围方块的值的值梯度。然后将伪随机变化应用于以包含方块的网格坐标为种子的种子。对于随机种子,无论图像在何处裁剪,始终使用所考虑的细分的直接包含正方形的坐标,以确保在多次运行中正确地重新创建它。
在一定程度的放大倍数下,随机值从粒子类型的密度变为粒子位置。那么对于每个粒子,都有粒子特征。然后对这些特征进行特征分析。
尽管需要任意左/右和上/下滚动,但每次移动帧时都必须计算当前场景上方所有放大级别的图像,以确保包括所有必要的特征。这样,图像可以从一个单元格滚动到另一个单元格,而不会失去一致性。局部模拟可用于确保单元或单元特征不重叠。这可以以可重复的、确定性的方式完成。
并且在添加随机变化之前,不要忘记应用基于较高级别周围方块的平均值的平滑梯度。否则,突然的变化会使方块本身出现在图像中!
这个答案有点漫无目的,可能令人困惑,但最好我现在就能解释它。我希望它有帮助!
The idea behind a fractal terrain creation algorithm is to build the image at each scale separately. For a landscape it's easy: just make a small array of height values, and set them randomly. Then scale it up to a larger array, averaging the values so that the contour is smooth, and then add small random amounts to those values. Then scale it up, etc. The original small bumps have become mountains, and they are filled with complex terrain.
There are two particular difficulties with the problem posed here, though. First, you don't want to store any of these values, since it would be potentially huge. Secondly, the features at each scale are of a different kind than the features at other scales.
These problems are not insurmountable.
Basically, you would divide the image up into a grid, and using deterministic psedorandom numbers establish the key features of each square in the grid. For example, each square could have a certain density of cell types.
At the next level of magnification, subdivide each square into another grid, apply a gradiant of values across the grid that is based on the values of the containing square and its surrounding squares. Then apply pseudorandom variations to that seeded with the containing square's grid coordinates. For the random seed, always use the coordinates of the immediately containing square of the subdivision under consideration regardless of where the image is cropped, in order to ensure that it is recreated correctly accross multiple runs.
At some level of magnification the random values go from being densities of paticles types to particle locations. Then for each particle, there are partical features. Then features on those features.
Although arbitrary left/right and up/down scrolling will be desired, the image at all levels of magnification above the current scene will have to be calculated each time the frame is shifted to ensure that all necessary features are included. This way the image can be scrolled from one cell to another without loss of consistancy. Partical simulations can be used to ensure that cells or cell features don't overlap. This could be done in a repeatable, deterministic manner.
And don't forget to apply a smoothing gradient based on averages of surrounding squares at higher levels before adding in the random variations. Otherwise, the abrupt changes will make the squares themselves appear in the images!
This answer is somewhat rambling and probably confusing, but that is best I can explain it right now. I hope it helps!