Reconstruction à vue multiple
Un objet 3D peut être reconstruit à partir de plusieurs vues en 2D. Utilisez ImageDisplacements pour déterminer la parallaxe d'une vue à l'autre. Plus le changement de parallaxe est grand, plus l'objet derrière le pixel correspondant se rapproche. Avec cette information en profondeur, vous pouvez extruder les sommets d'un maillage d'objets obtenus à l'aide d' ImageMesh et de TriangulateMesh. Le résultat est affiché via l'application de texture sur l'objet de maillage en 3D.
![Click for copyable input](assets.fr/multi-view-reconstruction/In_62.png)
Obtenez un masque d'objet du centre de l'image.
![Click for copyable input](assets.fr/multi-view-reconstruction/In_63.png)
mask = Erosion[Binarize[imgs[[2]], 0], 1];
Déterminez la parallaxe dans les images gauche et droite par rapport au centre de l'image.
![Click for copyable input](assets.fr/multi-view-reconstruction/In_64.png)
parallaxL = First@ImageDisplacements[imgs[[{2, 1}]]];
![Click for copyable input](assets.fr/multi-view-reconstruction/In_65.png)
parallaxR = First@ImageDisplacements[imgs[[{2, 3}]]];
Combinez ces déplacements dans une parallaxe complète.
![Click for copyable input](assets.fr/multi-view-reconstruction/In_66.png)
parallax = parallaxL - parallaxR;
Compte tenu de la configuration, la composante de la parallaxe est à peu près proportionnelle à la profondeur de la source du pixel correspondante.
![Click for copyable input](assets.fr/multi-view-reconstruction/In_67.png)
depth = Blur@
Opening[ImageMultiply[ImageAdjust@Image[parallax[[All, All, 1]]],
mask], DiskMatrix[4]]
![](assets.fr/multi-view-reconstruction/O_29.png)
Créez une fonction de profondeur.
![Click for copyable input](assets.fr/multi-view-reconstruction/In_68.png)
depthFunction = ListInterpolation[Transpose@Reverse@ImageData[depth]];
Obtenez un objet avec un raffinement de maillage qui dépend de la saillance de l'objet.
![Click for copyable input](assets.fr/multi-view-reconstruction/In_69.png)
resolution = ImageAdjust@ImageSaliencyFilter[imgs[[2]]];
![Click for copyable input](assets.fr/multi-view-reconstruction/In_70.png)
resolutionFunction =
ListInterpolation[Transpose@Reverse@ImageData@resolution];
![Click for copyable input](assets.fr/multi-view-reconstruction/In_71.png)
\[CapitalOmega] = TriangulateMesh[
ImageMesh[Erosion[mask, DiskMatrix[2]]],
MeshRefinementFunction ->
Function[{vertices, area},
area > 32 + 512 (1 - resolutionFunction @@ Mean[vertices])^6]
]
![](assets.fr/multi-view-reconstruction/O_30.png)
Extrudez le maillage de l'objet avec la fonction de profondeur.
![Click for copyable input](assets.fr/multi-view-reconstruction/In_72.png)
Graphics3D[
GraphicsComplex[
Apply[{##, depthFunction[##]} &,
MeshCoordinates[\[CapitalOmega]], {1}],
{EdgeForm[], MeshCells[\[CapitalOmega], 2]}
],
PlotRange -> Append[Thread[{0, ImageDimensions[mask]}], {0, 1}],
BoxRatios -> {1, 1, 2/3},
ViewPoint -> Top
]
![](assets.fr/multi-view-reconstruction/O_31.png)
Extrayez l'objet de texture à partir de l'image centrale.
![Click for copyable input](assets.fr/multi-view-reconstruction/In_73.png)
texture = SetAlphaChannel[imgs[[2]], mask]
![](assets.fr/multi-view-reconstruction/O_32.png)
Appliquez la texture sur l'objet 3D.
![Click for copyable input](assets.fr/multi-view-reconstruction/In_74.png)
Graphics3D[
{Texture[texture],
GraphicsComplex[
Apply[{##, depthFunction[##]} &,
MeshCoordinates[\[CapitalOmega]], {1}],
{EdgeForm[], MeshCells[\[CapitalOmega], 2]},
VertexTextureCoordinates ->
Map[#/ImageDimensions[texture] &, MeshCoordinates[\[CapitalOmega]]]
]
},
PlotRange -> Append[Thread[{0, ImageDimensions[mask]}], {0, 1}],
BoxRatios -> {1, 1, 2/3},
Lighting -> {{"Ambient", White}},
ViewPoint -> Top,
Boxed -> False
]
![](assets.fr/multi-view-reconstruction/swf_7.png)