HIGH QUALITY TEXTURE MAPPING PROCESS AIMED AT THE OPTIMIZATION OF 3D STRUCTURED LIGHT MODELS

: This article presents the evaluation of a pipeline to develop a high-quality texture mapping implementation which makes it possible to carry out a semantic high-quality 3D textured model. Due to geometric errors such as camera parameters or limited image resolution or varying environmental parameters, the calculation of a surface texture from 2D images could present several color errors. And, sometimes, it needs adjustments to the RGB or lightness information on a defined part of the texture. The texture mapping procedure is composed of mesh parameterization, mesh partitioning, mesh segmentation unwraps, UV map and projection of island, UV layout optimization, mesh packing and mesh baking. The study focuses attention to the mesh partitioning that essentially assigns a weight to each mesh, which reveals a mesh’s weight calculated by considering the flatness and distance of the mesh with respect to a chart. The 3D texture mapping has been developed in Blender and implemented in Python . In this paper we present a flowchart that resumes the procedure which aims to achieve a high-quality mesh and texture 3D model starting from the 3D Spider acquire, integrated with the SfM texture and using the texture mapping to reduce the color errors according to a semantic interpretation.


INTRODUCTION
In the last years, there has been an increasing use of digital techniques aimed at conservation, restoration and dissemination purposes.The HW/SW technological improvement of sensors is producing an exponential quality growth of the acquired data to provide a rigorous documentation of the Cultural Heritage regarding geometry, construction techniques, and materials used.Ideally, the texture quality at any view in 3D space should perfectly match that of the corresponding 2D image.Texture quality is a crucial issue to investigations in the field of the Cultural Heritage.Nevertheless, these new survey tools show some deficiencies and discrepancies, so much as to require an integration between different techniques.In literature, several studies have been able to confirm that 3D scanning surveys allow obtaining threedimensional models of high accuracy at the morphology and topological levels.However, nowadays the quality level of colour obtained with scanners (laser or structured light), usually, is not acceptable for high-quality colour texture mapping.On the other hand, the Image-Based Modeling (IBM) pipeline allows obtaining, in a few steps a higher (but not optimum) quality 3D textured model of real objects but these feature a lower precision of the polygonal mesh.The actual texture on the 3D model is often worse than that of 2D images, mainly because individual texture on the 3D model comes from different image sources.The 3D model reconstructed using multiple images of an object is only an approximation of the object geometry.The camera model and calibration method used to estimate the camera parameters might yield additional errors in the position and orientation of the object images.These errors, combined with errors caused by the texture mapping process, might lead to discrepancies between the texture of the 3D model and the real object.Any defects in the 3D texture could negatively impact perceptions of the product being presented.The most common problems presenting in the 3D texture include the low texture resolution, the missing colour in some mesh regions and photo inconsistencies that usually appears along the boundary of the various groups of meshes.
The purpose of this study is to develop a high-quality texture mapping implementation which makes it possible to carry out a high-quality 3D texture.Once the highest quality 3D texture is obtained it will be possible to associate the new texture to the laser-scanned 3D model.The results, obtained from 3D scanning and from digital photography, present a very dense sampling of both geometric and texture surface properties of real objects.The pipeline has been tested on a small object to verify its reliability (a small Russian matryoshka with a matte surface was used to avoid the problems due to the reflective materials) but, once tested, the pipeline has been applied at three different art ancient objects from the Archaeological Museum Salinas of Palermo.

RELATED WORKS
Most recent image-based texture reconstruction algorithms seem to use a charting approach.Lai, et al. (2018) and Phothong, et al. (2018) using a mesh partition minimizes the growing cost to find the optimized mesh group and developed an algorithm to follow the entire flowchart of mesh partitioning.Computation of a surface texture from input images is difficult since several images mapping to the same surface region can result in conflicting colour information due to geometric errors (camera parameters), limited image resolution, and varying environmental parameters (lighting) during image acquisition.Lai, et al. and Phothong et al., blend input image information per Texel using suitable costs for different source images.Nguyen, et al. (2013) study the effect of different input parameters, and present results obtained for reconstructing a variety of different 3D objects from input images acquired using an unconstrained and uncalibrated camera.There are several studies to reduce the texture distortion in the final model.The semi-automated software for the 3D reconstruction from 2D pictures uses an algorithm that consists in three steps: multiple-view stereo that computes depth maps given images and the corresponding camera poses, depth map fusion that merges the depth maps and model construction which generates the 3D mesh and defines the mapping of texture on the faces of the mesh.The depth map fusion step generates a depth estimate for each pixel of the reference view which is passed to the model module along with the image taken from that viewpoint.The output is a model in the form of a set of triangles in 3D whose faces are piecewise planar approximations of the scene surfaces.Each triangle is associated with a part of the image to add appearance to the geometry.Texture mapping can then be accomplished by creating a 2D texture image over the parameter space.An explicit surface parameterization can be avoided by determining the input image regions best representing the object's surface, blending them together, and storing them in a texture atlas indexed by the mesh vertices (Xu et al., 2010).However, since there is no global parameterization, post processing algorithms can result in unwanted artefacts.To overcome the texture mapping problems, they compute texture patches and fuse them seamlessly together by optimizing seam locations or warping texture patches.Surface parameterization methods can be classified according to their complexity, whether the resulting mapping is bijective, whether they have a predetermined boundary for the parameter space, and to what extent the distortion is minimized, (Stathopoulou, et al. 2011). Stathopoulou, et al. experiment with different kinds of maps and their combinations namely for true complex objects.The purpose is to explore the quality of the outcome and to find ways to produce realistic representations, avoiding large amounts of data and detailed surface models, easy to view in a simple web viewer.In this case study, the file sizes were considerably decreased up to 200 times.By employing the proposed workflow there is great potential in producing high resolution textures for large architectural objects or vast archaeological sites.The results can be easily delivered in different kinds of highly portable formats such as OBJ, VRML, 3DS etc. and thus there is a significant increase in the range of applications and software that can accept the final 3D textured models as input.Goldluecke and Cremers (2009) propose the first approach to super-resolution texture reconstruction from multi-view images which solves a super resolution model on curved surfaces.The image formation model leads to an energy with the desired texture map as the minimizer, whose Euler-Lagrange equation is a PDE on the surface.Using a conformal atlas for the known surface geometry, the equation can be solved via total variation deblurring on planar 2D texture space.The method produces high-fidelity texture maps, which approach the point-wise reconstruction quality from much higher resolution input.The visible texture detail can surpass the detail of individual input images.A current limitation is that no additional image registration is performed, so geometry and camera calibration needs to be accurate.Layer manufacturing enables us to fabricate a physical model with complicated internal structures.However, designing such a model is beyond the capability of current CAD systems.Chen, et al. (2012) designed a method based on mapping a microstructure into a design space to generate internal structures and present a representation scheme for defining general structures and use it to build a library of microstructures.The generated model can be saved as a watertight STL file for layer manufacturing systems.They use multi-band blending in order to minimize seam discontinuities and compute texture patches and blend them seamlessly together.Valkenburg and Alwesh reduce seams resulting from image illumination variations by applying a global optimization to all vertex colours of a 3D mesh (Valkenburg, et al., 2012).Supplementary optimization phases are possible to consider texture differences in input images, e.g., due to illumination changes, shadows, and camera parameters such as dynamic range adjustment.Xu et al. (2010) used radiometric correction to adjust colour differences between patches.Chen et al. removed highlight effects by determining all input images mapping to a surface area (Chen, et al., 2012).Image regions which vary too much from the median colour of the surface area are removed.Missing or deleted image regions (e.g., highlights) can be filled using Poisson image editing (Chen, et al., 2012, Colburn, et al., 2013).

3D GEOMETRY RECONSTRUCTION
In this paragraph there is a brief description of the image based modelling and Spider scanner procedure for geometry reconstruction, more details of the image based modelling algorithm are described in Nguyen, et al. (2013).The Nikon based acquired images are processed with a standard photogrammetric pipeline, based on tie point extraction, camera poses and interior parameters estimation, sparse point, cloud generation and dense point cloud production (Schonberger, et al., 2016).The adjustment is performed in a free network, scaling the photogrammetric process using a known distance in the scene.The geometric evaluation is performed comparing the Nikon D5300 DSLR camera 3D results to the 3D data obtained with Artec Spider structured light system.The first test to value the reliability of the procedure was made on a small object, a Russian matryoshka, with no reflective surface.Then, it was applied on two work art objects that are permanently hosted at the Salinas Archaeological Museum of Palermo (Inzerillo, 2017)  The work art objects were acquired by the Artec Spider 3D Scanner (structured light 3D scanner) and by a calibrated Nikon D5200 using the photogrammetry technique through a reverse modeling process.The models were georeferenced in the PhotoScan environment.The first stage of calibration is the estimation of the intrinsic parameters of the camera which determine the mapping of rays emanating from the optical centre to pixels in the image.These parameters include the focal length, aspect ratio and principal point as well as nonlinear parameters such as lens distortion.All parameters are jointly estimated using a planar calibration object.We estimated the calibration of the camera relative to the GPS/INS coordinate system.This process is termed hand-eye or lever-arm calibration.The hand-eye transformation, which consists of a rotation and a translation, is computed by detecting the positions of a few surveyed points in a few frames taken from different viewpoints.The pose of the camera can be determined for each frame from the projections of the known 3D points and the pose is given by the sensor measurements.The acquisition structured light system is based on the capture of the points that make up the surface of a physical object returning a digital 3D model with a high degree of geometric correspondence to the real object.The extremely versatile system scans at 8 frames/sec.Frames are automatically aligned in realtime (it does not require any special markers to be placed on the object being scanned).The process is functional, rapid, and capable of acquiring almost 1.000.000points∕s and turned out to be particularly suitable for the geometric dimensional characteristics of the objects (Tab.I; Tab.II).

Nikon D5200
Sensor name / type  The structured light system works with a light source projecting a series of light patterns on the object to be scanned (blue LED).

Sensor
The reflected image is captured by cameras, and from the analysis of the distortion of the pattern, the position is evaluated on each point of the surface to be scanned (Di Paola, et al., 2017).
The high-quality 3D digital models are responsive to the complexity of the geometric-form of the analysed objects, and the digital collection reproduces the decorations in organic form really well.
The used tool also captures images, but the texture resolution is only 1.3 Mp and the image colour is of 24 bpp.

DATA-PROCESSING
During the process of scanning with a photogrammetric structured light technique, the data was recorded and processed within the proprietary software Artec Studio.The algorithm elaborates the dense point clouds and combines with semi-automatic procedures all the acquired frames in a single polygonal model, allowing the correct alignment of the various captured 3D frames while preserving the reference system.The workflow includes the following stages: revising and editing the data, alignment of scans, global data registration, fusion of data into a single 3D model, final editing of the 3D model, and texture mapping.The procedural steps of post-processing and tessellation of the polygonal mesh have been elaborated within the Leios reverse engineering software (EGS company).In these first steps, considering the geometry of the surface (curvature, contiguity edges and density of the polygonal mesh) the spatial structure of the model undergoes corrections, removing some artefacts generated by the scanning process.But, as we will see later, further control will be needed to optimize the geometry and eliminate topological errors.The 3D models carried out from both acquiring procedures are shown in figure 2. The method is the UV mapping that correlates the spatial coordinates of the polygon mesh (related to the points and mesh vertices) to texture coordinates; the Artec Studio software uses the "atlas texture" method (resolution texture used: 4096 × 4096).An atlas texture is a large image containing a collection, or "atlas," of sub-images, each of which is a texture for some part of a 3D object.This method cuts the surface into chunks, unfolds, The International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences, Volume XLII-2/W9, 2019 8th Intl.Workshop 3D-ARCH "3D Virtual Reconstruction and Visualization of Complex Architectures", 6-8 February 2019, Bergamo, Italy and nests them flat, and fits them into the image of a specified size (Fig. 3).As already said, the level of colour quality obtained with the scanner is not acceptable for mapping high quality colour textures.
Therefore, we started the Image-Based Modeling (IBM) pipeline, that allows one to obtain, in a few steps, a textured 3D model of real objects of a superior quality (but not optimal), but with a lower precision of the polygonal mesh (see the flowchart).
-Georeferencing and texture transferring Within the PhotoScan software, the model acquired with structured light is georeferenced with that processed by the photographic data set, through the alignment of at least three selected marker points.The result is a dense sampling 3D textured model.

-
Polygonal mesh parameterization Now the aim is to segment the resulting meshes into patches and unwrap them a 2D planar surface.The new vertices on the 2D domain must be calculated in accordance with the optimized angles.Let three vertices of a  The International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences, Volume XLII-2/W9, 2019 8th Intl.Workshop 3D-ARCH "3D Virtual Reconstruction and Visualization of Complex Architectures", 6-8 February 2019, Bergamo, Italy triangle be v1, v2 and v3, and the corresponding angles be α1, α2, and α3, respectively.The calculation of the new vertices on the 2D domain uses the following least-squares approximation: where R is a rotation matrix with angle α1, and j is the jth iteration.
Assume that the two vertices v1 and v2 of a triangle are known.Equation (1) employs the known vertices v1 and v2 to optimize they unknown vertex v3, where Qobj is the objective function for the optimization.For all 2D meshes, if the first two vertices on a mesh can be determined, the remaining vertices can be evaluated by using the least-squares approximation, which is formulated as a set of linear equations.
The topology of all vertices on the UV domain can be maintained correctly.
The libraries available within the Blender software workspace were used to parameterize the meshes.Thanks to the tools available, it is possible to create a very disjointed map of triangle patches or create a single parameter patch with large distortions.Texture mapping includes multiple processing, such as mesh partitioning, mesh parameterization, texture transferring, and correction and optimization, which are related to each other and affect the texture quality (Remondino, 2003).Before proceeding to the mesh segmentation (unwrap) it is necessary to check for topological errors to optimize the mesh structure.
Before proceeding to the mesh segmentation (unwrap) it is necessary to check for topological errors to optimize the mesh structure.
-Mesh collision detection/re-meshing/mesh correction Following the acquisition of the 3D object, vertices are often detected and inserted that overlap, or are not connected to each other, and then through a Blender tool of detection of superfluous vertices, are eliminated thus lightening the polygonal load and the visualization of the mesh without altering the geometry.Sometimes, by reducing the polygonal weight, there are visualization problems due to the removal of the vertices necessary for the visualization, which are wrongly classified by the software as not relevant.
-Model quality/final user At this point, in relation to the field of application (restoration, museum use or gaming) we choose the path to follow: continue working on a model with full polygonal load or lightened for a real-time display.The main steps of the data acquisition and texture optimization workflow are described in the following paragraph.

TEXTURE RECONSTRUCTION
During the texturing process, the latest software technology uses tools dedicated to generating vertex maps, known as UV vertex maps, to assign the texture to a numerical model with a complex geometric shape (presence of undercuts and variable curvatures).The UV maps aim to relate the elements (vertexes) that make up the structure of a 3D polygonal mesh with the pixels of the associated bitmap image.(Valanis et.al, 2010) As the texture is a planar 2D figure, the UV vertex maps establish a strict biunivocal correspondence between the vertices of the model and the pixels of the image.One of the most used tools in Computer Graphics applications is baking.This procedure defines a UV vertex map (in which the user can choose which type of information to save) and effectively associates it to mesh models with a different UV reference system (Figs. 4.a;4.b).The proposed mesh partitioning technique essentially assigns a weight to each mesh, which denotes a mesh's weight calculated by considering the flatness and distance of the mesh with respect to a chart.An iterative procedure combining chart growth and seed meshes upgrading is implemented to expand and modify charts as well as seed meshes in sequence.The chart growth is a process to cluster all meshes into charts in accordance with each mesh's weight.When a closed chart is detected as possibly occurring, a new seed mesh is added to separate the chart into two.The seed mesh upgrading is a process to upgrade the seed mesh of each chart that has been expanded.Whenever a chart is grown, its seed mesh is recomputed by putting it near the centre of the new chart.Two weights are defined and used in chart growth and seed mesh upgrading.The weight used in chart growth is defined as: where Weight 1 (F,F′) denotes the weight of a candidate mesh M′ neighbouring a chart C, M is the neighbouring mesh of M′ that has been in C, NC is the normal vector of C evaluated by the average of all normal vectors of the meshes in C, NM′ is the normal vector of the candidate mesh, and PM′ and PM are the centroids of M′ and M, respectively.Equation (2) indicates that the Weight1(M, M′) considers both the flatness and distance of M′ with respect to the chart C.

Python Implementation
Like other modern programming languages, Python also supports several programming paradigms.It supports object oriented and structured programming fully.Also, its language features support various concepts in functional and aspectoriented programming.At the same time, Python also features a dynamic type system and automatic memory management.The programming paradigms and language features help you to use Python for developing large and complex software applications.You can use Python for developing desktop GUI applications, websites and web applications.Also, Python, as a high-level programming language, allows you to focus on core functionality of the application by taking care of common programming tasks.The simple syntax rules of the programming language further make it easier for you to keep the code base readable and application maintainable.We used python in the Blender environment and used it to achieve a semantic selection of the object.Indeed, in the Blender environment exists an automatic method of unwrapping a mesh that is called Smart UV Project is.If we choose this option Blender will try to automatically place new seams (it won't mark them on the mesh) and unwrap the mesh.We can adjust the Angle Limit in the operator menu to try to minimize distortion, but, often, the result is not adequate because it does not allow the geometric-formal features of an object.Therefore, we have started to develop alternative methods to create a mesh unwrap that is more compatible with its geometry and other custom user-defined aspects.
For the matryoshka we selected the face of the object and established the tolerance of the nearest pixels.In the case of the Krater, the goal was that to select and control the human silhouette to carry out.Once selected it is possible to establish the value to follow to achieve that result.In the case of Urn, the goal was that to select the texture according to the geometric fields.

Texture mapping process
For the purposes of our study, baking is particularly useful for managing models with high information density and a high polygonal load (high-poly).It can collect the following data of the acquired model in high resolution and "cook" them in a lowpoly model: -morphological data (onerous calculation of the simulation of the light/matter ratio, global illumination, radiosity);   -Baking, texture transferring onto seed mesh UV domain In order to proceed with the baking procedure, previously described, it is necessary to create a material within the "Node Editor" of Blender and assign a new texture to the resulting mesh (taking care to choose as resolution a double value, always in power of 2, to the original one of the acquired high-poly model) (Fig. 9).-Final texture correction As a result of the changes that are made, it is often necessary to correct the final texture from any imperfections.The background color of the image might be wrongly extracted for some meshes near the image silhouette, resulting in white spots on the 3D textured model.The incorrect extraction is caused by the meshes that are located outside the image silhouette when they are projected onto the front image.Thus, we wish to eliminate the influence of the error.
In Blender, using the "Texture Painting" mode, it is possible to correct the image previously obtained with a tool like the "Clone Stamp".The selection of the area that must be corrected, is driven by the goal that must be achieved: it could be a colour or a writing or a silhouette, it depends on the semantic objective.The result is a very dense sampling of both geometric and texture surface properties of real objects (Fig. 10).The final optimization process is blending the texture information on the image transition area.

CONCLUSIONS
We have described a process that reconstructs and optimizes the final texture of an acquired object by the integration of two photogrammetric systems: the structured light one and the imagebased modelling one.By employing the proposed workflow there is great potential in producing high resolution textures associated to models with different resolutions (high poly/low poly) in relation to the final use (restoration and conservation; real-time 3D visualization and gamification).We have demonstrated the quality of the reconstruction process using objects with different geometries, typology, colours and surface properties.We used some advanced surface parameterization methods to reconstruct the texture, used in the Blender environment, but we also propose alternative methods defined by implementing an algorithm, written in Python.These alternative developed methods create a mesh unwrap that is more compatible with the geometric-formal features of a complex object and with other custom user-defined semantic criteria.All aspects of the production workflow are presented and discussed.
. The work art objects have been chosen according to the geometry complexity and colours, surface materials and time period: an Etruscan Urn (II century b.C.) belonging to the Casuccini collection, and a black-figure Krater, belonging to the San Martino collection (19th century) (Fig. 1).

Figure 1 :
Figure 1: Salinas Archaeological Museum of Palermo.Etruscan Urn (II century b.C.), belonging to the Casuccini collection, on the left.A black-figure Krater (19th century), belonging to the San Martino collection, on the right.

Figure 2 :
Figure 2: Cases study.Dense sampling polygonal mesh (by Spider scanner) with high-quality resolution texture mapping (by Nikon camera).

Figure 3 :
Figure 3: The flowchart to develop a high-quality texture mapping implementation, on the left.Small matt Matryoshka: the tester to verify the reliability of the pipeline, on the right.
Figures 4.a; 4.b: Krater case study.Initial UV Map arrangement on the left; final UV Map arrangement, on the right.

Figures 5
Figures 5.a; 5.b: Krater case study.Weight paint mode, for highlight the principal parts, on the left; Final Packing and arrangement of UV Islands, on the right -displacement maps; -normal maps of the RGB type (normal map) (Fig. 6).Each numerical model can be matched to UV vertex maps of different types that present alternative criteria of biunivocal correspondence between numerical model and bitmap.-Mesh segmentation unwrap Usually, in order to avoid errors of mismatch (overlap between polygons, loss of similitude between the 3D faces and the corresponding 2D ones), special un-wrap tools are used which require the operator to define a sequence of seams based on which the numerical model is "cut" (Figs.7.a; 7.b).-Projectisland and UV Map layout optimization The objective of the pipeline developed in this study is to determine controllable solutions of the "UV vertex project" that allow one to obtain a perfect correspondence between the vertices of the model and the pixels and, at the same time, to occupy the entire perimeter of the UV map of the bitmap optimizing the high resolution of the image associated with the model(Figs.8a; 8.b).

Figures 7
Figures 7.a; 7.b: Krater case study.Seam selection, on the left; Closing seam, and edges connections review, on the right.

Figure 11 :
Figure 11: Final Urn rendering, on the left.Final Urn rendering after the colour correction (only a test, for the writing in the upper part, and for some parts of grown), on the right.The texture information is extracted from different front images.The boundary between two image sources might be inconsistent in colour.The results before and after the implementation of the proposed blending algorithm for Urna are shown in Figure 11.The texture quality on the transition area has been improved.The quality of the entire 3D textured model can therefore be improved for the purpose of e-CH dissemination.