IMPROVING MEASUREMENTS’ SPATIAL PRECISION BY MEANS OF 3D PRINTERS- BASED SYSTEMS. A CASE STUDY: COLORIMETRIC ASSESSMENT OF MODERNIST HYDRAULIC TILES

The ability to repeat analyses on the same very small area of a surface is crucial to obtain reliable comparative data. For example, in a painting the boundary between two different, small painted areas can be very blurred; if an analyst needs to track over the time a specific and tiny pigment spot (e.g., to assess the reliability of a conservation treatment), manual positioning of the analyser can lead to a mismatch that might undermine any data comparison. The use of automatic positioning systems can improve the ability to hit the right spot, so to collect reliable data. This work focuses on the development of an open hardware XYZ system based on 3D printers’ architecture and equipped with an imaging system. It demonstrates that the combination of image processing methods with the G-code generated during the movements of the XY axes can allows to avoid misalignment of the object that needs to be analysed, and thus to improve measurements’ spatial precision. The XYZ positioning system and the positioning calibration method are now tested on Modernist hydraulic tiles from Barcelona (Catalunya, Spain), a decorative and functional element in danger because of the estate speculation that is affecting the architectonic identity of the Catalan capital.


INTRODUCTION
The ability to repeat analyses on the same very small area of a surface is crucial to obtain reliable comparative data. This is a critical point of any measurement campaign, even more when dealing with handheld analytical instrumentations. Devices such as portable spectrophotometers, portable XRF or portable XRD are usually characterized by small analytical slits (e.g., 2-5 mm diameter in case of circular slits). In the case of contact analyses, the area to be analysed is equal to the device slit; in the case of non-contact analysis that must be performed very close to the surface (e.g., 1-10 mm), the analysed area will slightly vary according to the distance between the detector and the surface. In both cases, knowing the spatial coordinates of a point to be analysed is not always a simple task, and hitting the same area manually can be very tricky. For example, in a painting the boundary between two different, small painted areas can be very blurred; if an analyst needs to track over the time a specific and tiny pigment spot (e.g., to assess the reliability of a conservation treatment), manual positioning of the analyser can lead to a mismatch that might undermine any data comparison.
The use of positioning systems can improve the ability to hit the right spot, so to collect reliable data. This work focuses on the development of an open hardware XYZ positioning system based on 3D printers' architecture and specifically designed to be equipped with sensors and instrumentations typically used for Cultural Heritage material characterization and data collection. Being an open-source project, the axes dimensions, as well as the sensor and/or instrumentation holder, can be easily tailored according to the user needs. The main electronics and mechanics components of our positioning system are a microcontroller Arduino Mega, three bipolar stepper motor Nema17, a customised shield to hold the three motor drivers DRV8825. The * Corresponding author open-source firmware 'Marlin' is uploaded into the microcontroller in order to define the functionalities of the system. This firmware also interprets each XYZ movement and, for each command, generates code linesthe G-code -that can be stored and subsequently uploaded into the system controlling app, the software Repetier-Host, to reproduce the same sequences of movements.
To improve spatial precision during analytical campaigns, a method has been developed based on the combination of a micro camera mounted on the head of the positioning system and the G-code generated during the movements of the XY axes. The implementation of a Python script allows to check misalignment of the object to be analysed in case of multiple analyses on the same points over the time. The XYZ positioning system and the positioning calibration method were tested on Modernist hydraulic tiles from Barcelona (Catalunya, Spain). Notwithstanding their great artistic and historical value, these decorative and functional elements of the 19 th century Modernism architecture are suffering from the estate speculation that is affecting the architectonic identity of the Catalan capital.

The XYZ positioning system
The XYZ positioning system used to document and analyse the Catalan Modernist hydraulic tiles is a customized replica of the open-source system originally presented at the 'Mechatronics meets Cultural heritage' international workshop which took place on 27 June 2017 at the University of Vic-Central University of Catalonia and adapted according to the analytical campaign on the Catalan hydraulic tiles [REFER] (Figure 1). ). The overall system design is that of the typical open-source desktop 3D printers, whose architecture is mainly based on the popular RepRap, the first and most-widely used self-replicating rapid prototyping machine (Pearce, 2013). However, none of the movements of our positioning system was implemented on the base of the machine, contrarily to typical 3D printers that have the Y movement on the base. This feature allows avoid unnecessary movements of the artwork to be analysed, as well as to implement a reliable sub-system for the improvement of spatial precision during analysis.
Main specification of the system axes and movement features are shown in Table 1 Another significant modification compared to desktop 3D printers relates to the head located at the bottom side of the Z axis. In 3D printers, the head is used to fix the hotend extruder, while in our positioning system the head has been designed to follow the so called 'brick-ability' rule, a standard within the open-source hardware makers' community, that is the ability to design, use and recycling parts according to potential future adaptations and modifications (Gaudenzi Asinelli et al., 2019). Thanks to its design based on dovetail joints, the head can host different carriers designed with the same joint type and size ( Figure 2).

Figure 2.
The head of the system can be easily adapted thanks to the dovetails joints.
As for the colorimetric campaign on the Modernist hydraulic tails, we designed a carrier to host specifically both the mini spectrophotometer, the lighting system, and the optical system for the XY positioning calibration process. Other adaptations of the original system included the height of the overall structure and the length of the Z axis, both reduced to obtain a lighter, portable machine. Thanks to the modular design of the original system, the base can now be left to perform laboratory analysis or removed to perform in site analysis on still installed hydraulic tiled floors.

Recording the XYZ position: the G-code
The open-source Marlin firmware is uploaded into the microcontroller to manage XYZ movements, proximity sensors, and the lighting system, among other functionalities. The Marlin firmware is a universal G-code interpreter capable to translate code lines into specific and precise movements (along the XYZ axes) or into other actions such as checking the distance between analyser and surface by means of a proximity sensor. The controlling software used in this work is the Repetier-Host, a free, cross-platform programme compatible with the Marlin firmware. Thanks to its user-friendly Graphical User Interface the user can control the positioning system in a very precise way by using the control menu or by programming a sequence of actions. Each action corresponds to a specific G-code, e.g. the G-code G28 will send all axes X, Y, and Z to the home position that has been settled by the user through the Repetier-Host software (e.g., X0, Y0, Z0). Thus, each movement generates a G-code that can be stored in a sequence that can be used to repeat the same set of movements.

Positioning calibration
Mechatronics 2D and 3D positioning systems are largely used to support documentation and analytical campaigns of artworks. These systems are often used to perform automatic or semiautomatic scanning of surfaces by adapting their mounting heads to specific analytical instrumentations such as handheld devices The International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences, Volume XLVI-M-1-2021 28th CIPA Symposium "Great Learning & Digital Emotion", 28 August-1 September 2021, Beijing, China and imaging systems (i.e., Hocquet et al., 2011;Karaszewski et al., 2014). According to the type of analysis or documentation needs, 2D and 3D systems are used to perform point-to-point or area scan. Whilst the efforts are usually focused on the calibration of the analytical instrumentation, the calibration of the starting position of the XYZ axes of the system is often disregarded.
However, knowing the position of the object to be analysed with respect to the XYZ axes of the mechatronic system is crucial to obtain analytical spatial precision, that is to improve analytical repeatability. Along with the creation of G-code sequences, the positioning calibration system is the core of our method to improve spatial precision in analysis.
The core of this study is the implementation of a method to improve the position precision of the system axes with respect to the object to be examined. Considering the flat surface of the hydraulic tiles covered in this research, the Z axis is not taken into account because its position can always remain the same after the definition of the optimal distance instrumentation/surface defined by the end user. For instance, giving the mini spectrophotometer sensor we used, we defined a maximum Z distance from the surface to be analysed of 5 mm. This distance can be measured manually or by means of a distance sensor. As for the latter option, it is worth to remind that the open-source Marlin firmware uploaded into the microcontroller unit of the positioning system allows to specify the Z axis distance from the surface. This Z offset can be then used by the firmware to automatically move the Z axis so to always maintain the same distance from non-flat surfaces. The positioning calibration system makes use of a mini camera controlled by a microcontroller unit and the application of computer vision scripts executed with the open-source programming language Python. The system is connected to a computer via serial bus. The method is simple, easy to execute, and easy to improve according to the morphology of the object to be analysed. Mini camera and microcontroller unit (MCU) can be chosen according to the preferences of the end user. As for our tests, we used both an Arducam mini camera (both OV2640 2MP and OV5642 5MP cameras) coupled with an Arduino Nano MCU, and a modified Raspberry Pi mini camera (Sony IMX219 8MP type from Arducam) coupled to a Raspberry Pi Zero MCU. Specific carriers were designed to host the camera and the MCU of both configurations, and the analytical instrumentation that is the mini spectrophotometer nanoLambda NSP32m. Mini camera and analytical instrumentation are mounted in parallel, so that the center of the camera optic and the center of the detection slit of the analytical device are aligned at a defined distance.
The use of the mini camera has twofold objectives. On the one side, it helps in defining the correct alignment of the object to be analysed, that is a crucial factor to ensure analytical precision over the time. On the other side, it allows to visualize points of interest and record their position into the XY space for precise analysis.
As for the correct alignment of the object, the calibration process has the scope to avoid parallel, angular and combined misalignment of the analysed object with respect to XY plane ( Figure 3). Three calibration steps are needed to avoid object misalignment and allow spatial precision for a more robust data comparison over the time, e.g. when a colorimetric analysis campaign is performed to check colour perception before and after a conservative treatment, so that the object analysed need to be replaced correctly on the XY positioning system.
Step 1 occurs after placing the object to analyse on the XY positioning system for the first time, and consists of acquiring a first reference image taken form a known region of interest of the surface to be analysed. In the case of geometrically defined surfaces, such as the 20x20 cm hydraulic tiles, it is rather convenient to take the reference image from a specified corner of the tile. This image is used as the reference positioning image, that means that is used as the touchstone to verify the correct spatial positioning of an object with respect to the XYZ positioning system. According to the morphological complexity of the surface to be analysed, more than one reference image can be utilised.
After acquiring the reference image, the analytical campaign over the surface can be performed. When there is the need to reanalyse the same points of interest, a comparison step is required.
Step 2 consists of acquiring a second reference image taken form the same known region of interest of the surface to be analysed after replacing the object on the XY positioning system. It is important to bear in mind that both images need to be took by respecting the following conditions: same lighting, same camera angle with respect to the surface, same camera distance with respect to the surface, same resolution and size of the images.
A third step is needed to check if the object was correctly replaced in the same position.
Step 3 consists of comparing the two references images by means of computational methods executed in Python and mostly developed by using the OpenCV library, a widely used open-source tools to perform computer vision and image processing (Bradski and Kaehler, 2008). The code we use to test the alignment of the object is mostly derived from (OpenCV Development Team, 2021) and from (Rosebrock, 2017 and it basically uses the structural similarity index measure (SSIM) to compute differences between two images. The SSIM method explores changes in structural information based on the interdependencies between spatially closed pixels (Dushepa 2020, Karami 2017, Nag 2017, Wang et al. 2004). The main steps of the script are: i) convert the two reference images to grayscale, ii) compute structural similarities, and iii) calculate and show the SSIM index, expressed as a decimal value in the range 0-1. The closer the value is to 1, the stronger the similarities between the two images. The Python script is freely available at the open repository Open Science Framework at https://osf.io/94yaz/, while an example of the 3 steps alignment calibration process carried using a real object is given in the next section. Once obtained the SSIM, additional computational and image processing methods can be executed to check the differences between the reference image and the re-positioning image. In this work, we opted for the image overlay method, that allows the end-user to visually explore image translation along the XY axes as well as rotation. Although resulting in a semi-automatic method for a correct alignment, this method leaves room for additional implementations, e.g. by enhancing differences based on edge and contours comparisons.
As for the visualization and position recording of the surface spots to be analysed, the process is definitively simpler and can be performed automatically or semi-automatically. It takes advantage from the G-code generated by each movement of the XYZ positioning system head and is based on the knowledge of the distance between the center of the camera optic and the center of the detection slit of the analytical device. Obviously, if the analytical campaign is carried once and there is no need to perform additional analysis on the same spots over time, for example to check a conservation treatment, this process can be done avoiding the spatial calibration steps described previously. But in most cases, it is advisable to first perform the XY calibration for future, unpredictable analysis. Figure 4 show a graphical example of the visualization and recording of potential analysed points of a surface. Figure 4. Graphical example of G-code generated by XY axes movements, with example of the drift on the X axis that is generated by the distance between the center of the camera optic (red dot) and the center of the analytical device slit (blue square).
The position Home is always equivalent to the X0/Y0 position and is defined by the user according to the overall size of the stage. In our system, we settled the Home position in the upper left corner of the XYZ positioning system's stage. The camera needs to be fixed always on the head so that the center of its optic is equivalent to the center of the head. The analytical device is fixed on the head close to the camera so that the center of the camera optic and its center result aligned at a fixed distance. As for the graphical example, we assumed a theoretical distance between camera and device detectors of 5 mm. So that if we move the head of the system from the Home position X0/Y0 by 25 mm in both directions, for example, the Point A will result in X25/Y25 for both the center of the head and the center of the camera optic, and X30/Y30 for the center of device detection slit. When moving the positioning system head, the resulting G-code will always report the central position of head and camera.
Assuming that the center of the images is always equivalent to the point to be analysed, to carry on the analysis on point A a 5mm shift on the X axes need to be applied so that the correct position of the head will be X20/Y25 rather than X25/Y25. Indeed, as for this configuration, if the task is limited to the visualization of the the analysable points of interest, the G-code generated by moving the head of the system from Home to points A and B can be uploaded into the Repetier-Host software as it is. While, if the task is to perform analysis on these points of interests, the XY movements recorded into the G-code need to be modified by subtracting 5 mm from the X axis movements.

The conservation project
The positioning system is now used within a research project focused on cataloguing more than 2000 20x20cm Modernist hydraulic tiles from Barcelona (Spain), each showing a different design. Once an iconic decorative element of the second half of the 19th century Catalan Modernism architecture, during the last years the hydraulic tiles become one of the main symbols of the estate speculation that affects the city of Barcelona. Every day, entire pavements are dumped because of building refurbishments. In the absence of a municipal, regional, and state regulation to preserve this kind of cultural assets, it is very usual to come across bags full of refurbishment debris and of Modernist hydraulic tiles ( Figure 5). The cataloguing includes the collection of historical-artistic and scientific data, and our system is used to perform colorimetric analysis on the hydraulic tiles. The aim is to provide a chart of colours of the Modernist hydraulic tiles of Barcelona useful to document the state of the art, to check conservation treatments, and to provide a guideline for replica making.

Results and discussion
As for this work, we prepared a set up consisting of the modified Raspberry Pi mini camera, model Sony IMX219 from Arducam, and the mini spectrophotometer nanoLambda NSP32m ((390-760nm). These, along with the MCU Raspberry Pi Zero, were mounted on a carrier that can be easily fixed on the head of the positioning system so that the center of the camera optic is equivalent to the center of the head of the positioning system ( Figure 6). The distance between the center of the camera optic and the center of the detector slit of the spectrophotometric device is of 8 mm. Figure 6. MCU (left), camera (center) and sensor (right) mounted on a tailored carrier to be inserted into the head of the system. The arm mounted on the far right hosts the lighting subsystem (not shown).
The spectrophotometric results achieved by analysing the surface colours are not provided here, as these are out of the scope of this article. Conversely, the discussion is focused on the validity of the method proposed to enhance spatial precision in measurements by means of 3d printers-based systems.
After positioning a hydraulic tile on the upper left corner of the XYZ positioning system base, five images were taken: two images without moving the tile (named 'RefImage' and 'Im01', respectively), and three images by slightly moving the tile from the original position (named 'Im02', 'Im03' and 'Im04', respectively). These images were taken by maintaining the same distance of the camera optic under the same lighting conditions, the same camera angle with respect to the surface, the same camera distance with respect to the surface, and the same resolution and size of the images (Figure 7). The indexes mirrored the alignment of the images with respect to the camera optic, indicating a 100% similarity to the 'RefImage' in the case of the 'Image01', that is the image taken without moving the tile. As observable, the similarity decrease depending on the displacement of the tile on the XYZ positioning system, with lower values indicating higher displacement. Figure 8 shows the visual comparison between the reference image 'RefImage' and the most dissimilar image 'Im04' respectively. The images are quite significative, with green rectangles indicating the location of the most significative dissimilarities between the two images. Indeed, these rectangles, along with the images overlay technique, can be especially useful to determine the misalignment of the tile with respect to the original position of the reference image, thus to the original position of the tile on base of the XYZ positioning system.

CONCLUSIONS
The results obtained are encouraging and demonstrated that the use of 3D printers-based systems, along with image processing, allows to improve the measurements' spatial precision and strengthen analytical strategy over the time. This represents a crucial factor in comparative analysis. However, further implementations of the method based on image processing are needed to make images comparison more robust, and to allow a more automatic detection of misalignament of the object on the stage. Next efforts, for instance, will be dedicated in find a method to compare the reference image to video streaming rather to another image. It is expected that this option would speed up the entire positioning calibration process. The open-source mechatronics prototype and positioning calibration method we proposed is now successfully used to perform colorimetric analysis on Modernist hydraulic tiles. Notwithstanding, some improvements in the mechanical design and assemblage are needed, i.e., to avoid the micrometric deviations observed after prolonged use. The implementation of a second prototype, already ongoing, includes a novel design to allow analysis on vertical surfaces, and to improve the portability of the system. Finally, this work also demonstrates how focusing research efforts towards open-source solutions can accelerate knowledge exchange and improve innovation in research.