Can we generate “foveated Image” in Mathematica

后端 未结 3 1713
刺人心
刺人心 2020-12-28 08:32

\"Foveated imaging is a digital image processing technique in which the image resolution, or amount of detail, varies across the image according to one or more \"fixation po

3条回答
  •  心在旅途
    2020-12-28 09:05

    WaveletMapIndexed can give a spatially-varying blur, as shown in the Mathematica documentation (WaveletMapIndexed->Examples->Applications->Image Processing). Here is an implementation of a foveatedBlur, using a compiled version of the acuity function from the other answer:

    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}]]
    

    where the compiled acuity is

    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]}]];
    

    The distance parameter sets the rate of falloff of the acuity. Focusing point {cx,cy}, and blind-spot radius are self-explanatory. Here is an example using Manipulate, looking right at Lena's right eye:

    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

    See the blind spot?

提交回复
热议问题