我们可以在Mathematica中生成“foveated Image”吗?

时间:2011-09-12 18:15:45

标签: image image-processing wolfram-mathematica

Foveated imaging是一种数字图像处理技术,其中图像分辨率或细节数量根据一个或多个”固定点“在图像上变化。固定点表示最高分辨率区域。图像对应于眼睛视网膜的中心,即中央凹。“

enter image description here

我想使用这样的图像来说明人类的视力,波纹图显示左眼的相对敏锐度(水平部分),以度为中心(维基百科):

enter image description here

有没有办法使用图像处理功能在Mathematica中创建一个foveated图像?

3 个答案:

答案 0 :(得分:10)

以下内容可能对您有用。过滤细节应根据您​​的喜好进行调整。

lena = ExampleData[{"TestImage", "Lena"}]

lena

ImageDimensions[lena]

==> {512, 512}

mask = DensityPlot[-Exp[-(x^2 + y^2)/5], {x, -4, 4}, {y, -4, 4}, 
                    Axes -> None, Frame -> None, Method -> {"ShrinkWrap" -> True}, 
                    ColorFunction -> GrayLevel, ImageSize -> 512]

mask

Show[ImageFilter[Mean[Flatten[#]] &, lena, 20, Masking -> mask], ImageSize -> 512]

enter image description here

答案 1 :(得分:9)

根据Sjoerd的回答,您可以Fold[]如下所示依赖于半径的模糊。

敏锐度模型(非常粗糙的模型):

Clear[acuity];
acuity[distance_, x_, y_, blindspotradius_] := 
    With[{\[Theta] = ArcTan[distance, Sqrt[x^2 + y^2]]}, 
       Clip[(Chop@Exp[-Abs[\[Theta]]/(15. Degree)] - .05)/.95, 
            {0,1}] (1. - Boole[(x + 100.)^2 + y^2 <= blindspotradius^2])]

Plot3D[acuity[250., x, y, 25], {x, -256, 256}, {y, -256, 256}, 
       PlotRange -> All, PlotPoints -> 40, ExclusionsStyle -> Automatic]

Acuity of fovea model

示例图片:

size = 100;
lena = ImageResize[ExampleData[{"TestImage", "Lena"}], size];


Manipulate[
 ImageResize[
   Fold[Function[{ima, r}, 
   ImageFilter[(Mean[Flatten[#]] &), ima, 
      7*(1 - acuity[size*5, r, 0, 0]), 
      Masking -> Graphics[Disk[p/2, r], 
                    PlotRange -> {{0, size}, {0, size}}]
   ]], 
   lena, Range[10, size, 5]], 
 200], 
{{p, {size, size}}, Locator}]

一些例子:

Acuity example 1

Acuity example 2

答案 2 :(得分:2)

WaveletMapIndexed可以提供空间变化的模糊,如Mathematica文档(WaveletMapIndexed->Examples->Applications->Image Processing)中所示。以下是foveatedBlur的实现,使用了另一个答案的acuity函数的编译版本:

Clear[foveatedBlur];
foveatedBlur[image_, d_, cx_, cy_, blindspotradius_] := 
   Module[{sx, sy}, 
      {sy, sx} = ImageDimensions@image;
      InverseWaveletTransform@WaveletMapIndexed[ImageMultiply[#, 
          Image[acuityC[d, sx, sy, -cy + sy/2, cx - sx/2, blindspotradius]]] &, 
          StationaryWaveletTransform[image, Automatic, 6], {___,  1 | 2 | 3 | 4 | 5 | 6}]]

编译后的敏锐度为

Clear[acuityC];
acuityC = Compile[{{distance, _Real}, {sx, _Integer}, {sy, _Integer}, {x0, _Real}, 
                   {y0, _Real}, {blindspotradius, _Real}}, 
            Table[With[{\[Theta] = ArcTan[distance, Sqrt[(x - x0)^2 + (y - y0)^2]]},  
                  (Exp[-Abs[\[Theta]]/(15 Degree)] - .05)/.95 
                  *(1. - Boole[(x - x0)^2 + (y - y0 + 0.25 sy)^2 <= blindspotradius^2])], 
                  {x, Floor[-sx/2], Floor[sx/2 - 1]}, {y, Floor[-sy/2], Floor[sy/2 - 1]}]];

distance参数设置视敏度的衰减率。聚焦点{cx,cy}和盲点半径是不言自明的。以下是使用Manipulate的示例,正​​好看着Lena的右眼:

size = 256;
lena = ImageResize[ExampleData[{"TestImage", "Lena"}], size];

Manipulate[foveatedBlur[lena, d, p[[1]], p[[2]], 20], {{d, 250}, 50, 
    500}, {{p, ImageDimensions@lena/2}, Locator, Appearance -> None}]

Foveated Image Example with blind spot

看到盲点?