An automobile film AI color changing recommendation method and system based on vehicle body region segmentation and color mapping
Patent Information
- Application Number
- CN202610629680.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-09
- Publication Date
- 2026-08-18
AI Technical Summary
现有技术中当原始车身颜色为白色、黑色或灰色等低饱和度消色时,直接替换目标饱和度会导致换色后色彩暗淡,无法达到用户预期的鲜艳程度
本发明通过对于被指定换色的车身部件蒙版区域内每一像素,保持其原始明度分量不变,将其色相与饱和度替换为目标值后,以该像素局部梯度幅值与局部标准差之比构造S型函数计算高光保护权重,并依据该权重将换色像素值与原始像素值进行混合;在高光反射边缘处权重趋近于1,保留原始高光信息,在平坦漆面区域权重趋近于0,充分应用目标颜色,从而在换色过程中自适应地保护了原始光影纹理,预览图像的光学真实感显著提升;
Smart Images

Figure CN122597542A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer vision and image processing, specifically a method and system for recommending car wrap colors using AI based on vehicle body region segmentation and color mapping. Background Technology
[0002] Car wrapping, with its short installation period, low cost, rich color options, and high reversibility, has become a mainstream personalized service in the automotive aftermarket. Consumers typically rely on color swatches when making their decisions, but due to limitations such as the curved shape of the car body, the reflective properties of the paint, and changes in ambient lighting, small color swatches cannot accurately reflect the actual effect after wrapping the entire vehicle. Therefore, digital color change preview technology is used to simulate a color-change appearance on car photos to assist in consumer decision-making.
[0003] Existing digital color-changing preview solutions mainly fall into two categories. One type relies on manual image editing software, requiring operators to manually cut out and adjust colors, which is inefficient, depends on professional experience, and makes it difficult to guarantee color accuracy and consistency. The other type is an automatic color-changing solution based on mobile or web platforms, which uses deep learning semantic segmentation models to identify vehicle body areas and apply color filters or color mapping, achieving process automation, but still has significant shortcomings in terms of visual realism.
[0004] Existing automatic color-changing methods lack physical modeling of the optical properties of the paint surface. After color changing, the image loses highlight reflections, environmental reflections, and the gradual changes in light and shadow on curved surfaces, resulting in a flat, filled appearance. Secondly, they cannot differentiate the texture of different materials such as matte, metallic, and electroplated finishes, leading to significant discrepancies between the preview and the actual product. Thirdly, the semantic segmentation mask edges have jagged edges or positioning errors, causing color overflow or residual old color lines at boundaries such as door gaps and window frames. Furthermore, existing solutions only process the main body of the vehicle, neglecting the color matching of accessories such as wheels, rearview mirror housings, and door handles, making it difficult for users to obtain a complete preview of the entire vehicle.
[0005] The following problems exist in the existing technology: Existing automatic color-changing methods treat the car body area as a uniform color block for overall color filling. They lack physical modeling of the optical properties of the paint surface, resulting in the removal of highlight reflections, environmental reflections, and surface light and dark gradients in the original image after color changing. The preview image presents a flat filling feel and lacks the real texture of the paint surface. Existing color-changing methods use the same color overlay method for different materials, which cannot differentiate the texture of different material types such as matte paint, metallic paint, and electroplated paint, resulting in a large gap between the preview effect and the actual visual experience. In existing technologies, the vehicle body mask output by semantic segmentation algorithms has pixel-level jagged edges or positioning deviations at the edges. Direct color replacement will result in color overflow or residual old color lines at the boundaries of components such as door gaps and window frames, which will destroy the realism of the preview image. In existing technologies, when the original car body color is a low-saturation achromatic color such as white, black, or gray, directly replacing the target saturation will result in a dull color after the color change, failing to achieve the vividness expected by the user. Summary of the Invention
[0006] The present invention aims to solve at least one of the technical problems existing in the prior art; to this end, the present invention proposes an AI-based method and system for recommending car wrap colors based on vehicle body region segmentation and color mapping, in order to solve the above-mentioned technical problem.
[0007] The first aspect of this invention provides an AI-powered car wrap color-changing recommendation method based on vehicle body region segmentation and color mapping, comprising the following steps: S1: Acquire the car image to be processed and perform pixel-level semantic segmentation using a pre-trained semantic segmentation model to generate a hierarchical mask set containing semantic labels of multiple car body parts; at the same time, acquire the target hue, target saturation and target brightness mean of the target color specified by the user, acquire the diffuse reflection adjustment index and highlight enhancement coefficient according to the target paint material type specified by the user, and acquire the brightness mean of the original car body area. S2: For each pixel within the mask area of the specified color-changing body part, replace its hue and saturation components with the target hue and saturation to obtain the color-changing pixel value; construct an S-shaped function based on the ratio of the local gradient magnitude to the local standard deviation of the pixel to calculate the highlight protection weight, and mix the color-changing pixel value with the original pixel value in the car image to be processed according to the highlight protection weight to generate a preliminary color-changing image; S3: Calculate the original average saturation value of the mask area of the body part to be specified for color change, and use the original average saturation value to apply nonlinear compensation to the target saturation to obtain the compensated target saturation. In this way, the saturation of the preliminary color change image is corrected to generate an intermediate color change image. S4: Extract the local surface reflection intensity factor of the car image to be processed, and adjust the brightness component of the intermediate color-changing image based on the diffuse reflection adjustment index and the specular enhancement coefficient to generate the color-changing image after material adjustment. S5: Calculate the symbolic distance field of each body part mask in the hierarchical mask set. For each pixel whose absolute value of the symbolic distance field is less than a preset distance threshold, use the symbolic distance field value of the pixel as a variable, introduce the cumulative distribution function of positive offset to calculate the asymmetric blending weight, and blend the material-adjusted color-changing image with the car image to be processed according to the asymmetric blending weight. Then, superimpose the virtual crease shadow generated by the Gaussian Laplacian response of the symbolic distance field on the inner side of the body part in the blending area to obtain the body part image after edge blending. S6: Combine the edge-blended vehicle body component image, the associated accessory vehicle body component image automatically derived and color-changed according to preset hue coordination rules, and the remaining layers in the vehicle image to be processed that did not participate in the color change according to preset occlusion relationships, and output the final color-changed preview image.
[0008] Preferably, in step S2, for each pixel within the mask area of the specified color-changing body component, an S-shaped function is constructed using the ratio of the pixel's local gradient magnitude to its local standard deviation to calculate the highlight protection weight, including the following steps: Centered on the current pixel in the car image to be processed, a local neighborhood window of a preset size is extracted, and the local standard deviation of the brightness values within the local neighborhood window is calculated. And calculate the brightness gradient magnitude of the current pixel using edge detection operators. The highlight protection weight W(x) is calculated by constructing an S-shaped function according to the formula: Where k is a parameter controlling the steepness of the S-curve, and τ is a parameter controlling the high-light protection response threshold. It is a very small constant.
[0009] Preferably, in step S2, the hue and saturation components are replaced with the target hue and target saturation to obtain the color-changing pixel values; the color-changing pixel values are then mixed with the original pixel values in the car image to be processed according to the highlight protection weight to generate a preliminary color-changing image, including the following steps: The hue and saturation components of the current pixel in the car image to be processed are replaced with the target hue and the target saturation, respectively, while keeping its original brightness component unchanged, to obtain the color-changed pixel value; The color-changing pixel values are mixed with the original pixel values in the car image to be processed, using the highlight protection weight W(x) as the weighting coefficient, to obtain the pixel values at the corresponding positions in the preliminary color-changing image.
[0010] Preferably, step S3 includes the following steps: The arithmetic mean of the original saturation values of all pixels within the masked area of the specified color-changing body part in the image of the car to be processed is calculated and used as the original saturation mean. ; For the target saturation Apply nonlinear compensation to obtain the target saturation after compensation. The calculation formula is: Where η is the compensation strength coefficient, These are the attenuation control parameters; Calculate the saturation correction factor For each pixel in the initial color-changing image located within the mask area of the specified color-changing body part, its saturation component is multiplied by a saturation correction factor to obtain a saturation-corrected intermediate color-changing image.
[0011] Preferably, in step S4, extracting the local surface reflection intensity factor of the vehicle image to be processed includes the following steps: For each pixel within the mask area of the specified color-changing body component, the brightness gradient magnitude in the vehicle image to be processed is calculated using an edge detection operator. And obtain the brightness value I(x) of that pixel; The cosine of the angle between the surface normal at the pixel and the light source direction is calculated using the inner product of the direction of the brightness gradient and the preset main light source direction vector. The local surface reflection intensity factor R(x) is calculated using the following formula: , where max(0.01, I(x)) means taking the larger value between 0.01 and I(x).
[0012] Preferably, in step S4, adjusting the luminance component of the intermediate color-changing image based on the diffuse reflection adjustment index and the specular enhancement coefficient to generate a color-changing image after material adjustment includes the following steps: For each pixel in the intermediate color-changing image located within the mask area of the specified color-changing body component, extract its brightness component. And calculate the output lightness component. The calculation formula is: in, The target brightness mean, The average brightness value of the original vehicle body area. It is a very small constant. The diffuse reflection modulation index is... R(x) is the specular enhancement coefficient, R(x) is the local surface reflection intensity factor, and Clip(x) is the local surface reflection intensity factor. This means that the result is constrained to the interval [0,1].
[0013] Preferably, in step S5, the symbolic distance field of each vehicle body component mask in the hierarchical mask set is calculated. For each pixel whose absolute value of the symbolic distance field is less than a preset distance threshold, the symbolic distance field value of that pixel is used as a variable, and an asymmetric blending weight is calculated by introducing a cumulative distribution function of positive offset. Based on the asymmetric blending weight, the material-adjusted color-changing image is blended with the vehicle image to be processed, including the following steps: Calculate the signed distance field d(p) of the mask for each body part, where the distance inside the mask is positive and the distance outside is negative; For the symbolic distance field, satisfying The pixel position p, where Calculate the asymmetric mixing weight λ(p) based on the preset distance threshold; if d(p) ≥ 0, then λ(p) = Where μ is the positive offset, σ is the transition bandwidth control parameter, and Φ( λ(p) is the cumulative distribution function of the standard normal distribution; if d(p) < 0, then λ(p) = 0. The corresponding pixel values in the color-changing image after material adjustment are mixed with the corresponding pixel values in the car image to be processed, using an asymmetric mixing weight λ(p) as the interpolation coefficient, to obtain the mixed pixel values. .
[0014] Preferably, in step S5, superimposing a virtual crease shadow generated by the Gaussian Laplace response of the symbolic distance field on the inner side of the body component in the mixed region includes the following steps: The Gaussian Laplace response of the symbolic distance field d(p) was calculated. ; The virtual crease shadow is superimposed onto the blended pixel value. The calculation formula is: Where γ is the shadow intensity coefficient, max(0, ) indicates taking the larger of 0 and the input value.
[0015] A second aspect of the present invention provides an AI-powered car wrapping color-changing recommendation system based on vehicle body region segmentation and color mapping, comprising the following modules: The semantic segmentation and parameter acquisition module is used to acquire the car image to be processed and perform pixel-level semantic segmentation using a pre-trained semantic segmentation model to generate a hierarchical mask set containing semantic labels of multiple car body parts; at the same time, it acquires the target hue, target saturation and target brightness mean of the target color specified by the user, acquires the diffuse reflection adjustment index and highlight enhancement coefficient according to the target paint material type specified by the user, and acquires the brightness mean of the original car body area. The preliminary color-changing module is used to replace the hue and saturation components of each pixel in the mask area of the specified color-changing body part with the target hue and saturation, thereby obtaining the color-changing pixel value; construct an S-shaped function based on the ratio of the local gradient magnitude to the local standard deviation of the pixel to calculate the highlight protection weight, and mix the color-changing pixel value with the original pixel value in the car image to be processed according to the highlight protection weight to generate a preliminary color-changing image; The saturation compensation module is used to calculate the original average saturation value of the mask area of the specified color-changing body part, and to apply nonlinear compensation to the target saturation using the original average saturation value to obtain the compensated target saturation. This is used to correct the saturation of the initial color-changing image and generate an intermediate color-changing image. The material adjustment module is used to extract the local surface reflection intensity factor of the car image to be processed, and adjust the brightness component of the intermediate color-changing image based on the diffuse reflection adjustment index and the highlight enhancement coefficient to generate the color-changing image after material adjustment. The edge blending module calculates the symbolic distance field of each body part mask in the hierarchical mask set. For each pixel whose absolute value of the symbolic distance field is less than a preset distance threshold, the symbolic distance field value of that pixel is used as a variable. An asymmetric blending weight is calculated by introducing the cumulative distribution function of the positive offset. Based on the asymmetric blending weight, the color-changing image after material adjustment is blended with the car image to be processed. A virtual crease shadow generated by the Gaussian Laplacian response of the symbolic distance field is superimposed on the inner side of the body part in the blending area to obtain the edge-blended body part image. The layer compositing module is used to combine the edge-blended car body component image, the associated accessory car body component image that has been automatically deduced and color-changed according to preset hue coordination rules, and the remaining layers in the car image to be processed that have not participated in the color change according to preset occlusion relationships, and output the final color-changed preview image.
[0016] Compared with the prior art, the beneficial effects of the present invention are: This invention preserves the original lightness component of each pixel within the mask area of the specified color-changing body part, replaces its hue and saturation with the target value, constructs an S-shaped function based on the ratio of the local gradient magnitude to the local standard deviation of the pixel to calculate the highlight protection weight, and mixes the color-changing pixel value with the original pixel value according to the weight; the weight approaches 1 at the edge of the highlight reflection to retain the original highlight information, and the weight approaches 0 in the flat paint area to fully utilize the target color, thereby adaptively protecting the original light and shadow texture during the color-changing process, and significantly improving the optical realism of the preview image; This invention extracts the local surface reflection intensity factor of the car image to be processed, uses the diffuse reflection adjustment index obtained according to the target paint material type to perform a power law transformation on the brightness component of the intermediate color-changing image, and superimposes a specular reflection enhancement term that works together with the highlight enhancement coefficient and the local surface reflection intensity factor; sets corresponding parameter combinations for different materials, so that the same target color presents a brightness distribution and highlight intensity that conforms to its real optical characteristics under matte, metallic, electroplated and other materials, and realizes differentiated simulation of different paint textures; This invention calculates the symbolic distance field of each body panel mask. For pixels within the boundary transition zone, the symbolic distance field value is used as a variable, and an asymmetric blending weight is calculated by introducing a cumulative distribution function of positive offset. This weight is directly zeroed outside the mask and smoothly transitions along the body direction inside the mask, so that the blending of new and old colors only diffuses towards the inside of the body, while the outside remains sharp. At the same time, a virtual crease shadow generated by the Gaussian Laplace response of the symbolic distance field is superimposed on the inside of the boundary, simulating the crease shadow of the film at the sheet metal joint, eliminating the incongruity of the segmentation edge, and enhancing the three-dimensional realism at the part boundary. This invention calculates the average original saturation value of the mask area of the specified color-changing body part, and uses this average value to apply nonlinear compensation in the form of exponential decay to the target saturation. The lower the original saturation, the greater the compensation magnitude, and the target saturation is significantly improved after compensation, ensuring that the color of the decolorized body is full and bright after color change. When the original saturation is high, the compensation approaches zero, maintaining the accuracy of color mapping. Attached Figure Description
[0017] Figure 1 This is a schematic diagram of the method flow of the present invention.
[0018] Figure 2 This is a schematic diagram of the module flow of the present invention. Detailed Implementation
[0019] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0020] Please see Figure 1 This invention is an AI-powered method for recommending car wrap colors based on vehicle body region segmentation and color mapping, comprising the following steps: S1: Acquire the car image to be processed and perform pixel-level semantic segmentation using a pre-trained semantic segmentation model to generate a hierarchical mask set containing semantic labels of multiple car body parts; at the same time, acquire the target hue, target saturation and target brightness mean of the target color specified by the user, acquire the diffuse reflection adjustment index and highlight enhancement coefficient according to the target paint material type specified by the user, and acquire the brightness mean of the original car body area. S2: For each pixel within the mask area of the specified color-changing body part, replace its hue and saturation components with the target hue and saturation to obtain the color-changing pixel value; construct an S-shaped function based on the ratio of the local gradient magnitude to the local standard deviation of the pixel to calculate the highlight protection weight, and mix the color-changing pixel value with the original pixel value in the car image to be processed according to the highlight protection weight to generate a preliminary color-changing image; S3: Calculate the original average saturation value of the mask area of the body part to be specified for color change, and use the original average saturation value to apply nonlinear compensation to the target saturation to obtain the compensated target saturation. In this way, the saturation of the preliminary color change image is corrected to generate an intermediate color change image. S4: Extract the local surface reflection intensity factor of the car image to be processed, and adjust the brightness component of the intermediate color-changing image based on the diffuse reflection adjustment index and the specular enhancement coefficient to generate the color-changing image after material adjustment. S5: Calculate the symbolic distance field of each body part mask in the hierarchical mask set. For each pixel whose absolute value of the symbolic distance field is less than a preset distance threshold, use the symbolic distance field value of the pixel as a variable, introduce the cumulative distribution function of positive offset to calculate the asymmetric blending weight, and blend the material-adjusted color-changing image with the car image to be processed according to the asymmetric blending weight. Then, superimpose the virtual crease shadow generated by the Gaussian Laplacian response of the symbolic distance field on the inner side of the body part in the blending area to obtain the body part image after edge blending. S6: Combine the edge-blended vehicle body component image, the associated accessory vehicle body component image automatically derived and color-changed according to preset hue coordination rules, and the remaining layers in the vehicle image to be processed that did not participate in the color change according to preset occlusion relationships, and output the final color-changed preview image.
[0021] Specifically, in S1, an image of the car to be processed, containing the complete exterior of the vehicle, is acquired through an image acquisition unit (e.g., a smartphone camera, a tablet camera, etc.). If the input is a video stream, the keyframe with the highest clarity is extracted from the video stream as the car image to be processed. The color space of the car image to be processed is RGB, and the size is denoted as height H pixels and width W pixels. For example, the resolution of a common mobile phone image is 1920×1080 pixels. The software implementation of the method described in this embodiment is based on Python 3.8 and the OpenCV 4.5 computer vision library. The hardware environment is a personal computer configured with an Intel Core i7-10700 processor, 16GB of memory, and an NVIDIA GeForce RTX 3060 graphics processor. The test image set used for parameter verification and effect evaluation contains 500 real-shot car exterior images, sourced from public automotive information platforms such as Autohome, covering mainstream models such as sedans, SUVs, and MPVs, as well as common original paint colors such as red, white, black, silver, and blue. The shooting lighting conditions include various scenarios such as front lighting, side lighting, backlighting, and indoor showroom lighting. All test images were uniformly scaled to a resolution of 1280×720 pixels before processing to simulate the actual input specifications of mobile applications.
[0022] The car images to be processed are input into a pre-trained semantic segmentation model. This model employs a DeepLabV3+ network architecture with a MobileNetV3 backbone and is fine-tuned on a dataset containing 50,000 labeled car images. Each car image in this dataset contains pixel-level semantic annotations, covering various independent sheet metal parts and accessories on the car's exterior surface. During training, a cross-entropy loss function and an Adam optimizer are used, with an initial learning rate of 0.001 and 50 training epochs. After training, the semantic segmentation model is capable of performing pixel-level semantic classification on input car images.
[0023] After the semantic segmentation model infers the car image to be processed, it outputs a pixel-level semantic label map with the same resolution as the car image to be processed. The value of each pixel position in the label map is a preset semantic category identifier. Each semantic category identifier and its corresponding body part name can be defined as identifier 1 representing the hood, identifier 2 representing the front bumper, identifier 0 representing the background and other unclassified areas, etc.
[0024] A hierarchical mask set is constructed based on pixel-level semantic label maps. This hierarchical mask set is a tree-like data structure, with the root node corresponding to the entire vehicle's outer surface. The first-level child nodes under the root node are divided into functional areas such as body panel groups, roof and pillar groups, and exterior accessory groups. Each leaf node corresponds to a specific semantic category identifier and stores the binary mask image corresponding to that body component. The identifier `id` is the semantic category identifier mentioned above. The size of the binary mask image is the same as the car image to be processed, where pixels belonging to the car body parts are set to 1, and the remaining pixels are set to 0. For example, the binary mask image corresponding to the hood. In the image, the pixel value in the hood area is 1, and the pixel value in the rest of the area is 0.
[0025] Simultaneously, the system receives user specifications for the target color and target paint material type via a graphical user interface. The target color can be specified by selecting from a preset color chart library, extracting color values from a reference image using a color picker, or directly inputting a color code (such as hexadecimal HEX code or RGB values). The system then converts the user-specified target color from the current color representation to the HSV color space and extracts the target hue. (range of values) to and target saturation (Value range 0 to 1). Simultaneously, the target color is converted to the Lab color space, and the normalized mean of its lightness channel is extracted as the target lightness mean. (Value range 0 to 1). For example, if a user specifies racing yellow as the target color, its typical RGB value is (255, 200, 0), which, after conversion to the HSV color space, yields... = , =1.0, obtained after conversion to Lab color space =0.82.
[0026] The target paint finish material type is specified through the material options in the graphical user interface. Selectable material types include matte paint, high-gloss clear coat, metallic paint, and electroplated mirror finish. Based on the user-selected target paint finish material type, the corresponding diffuse reflection adjustment index is read from the preset material parameter table. and specular enhancement factor The values in the preset material parameter table were determined through optical property measurements and visual comparison experiments on real vehicle samples of different materials. For example, the specific correspondences can be summarized as follows: matte paint corresponds to... =0.45 and =0; High-gloss clear coat corresponds to =1.0 and =0.15.
[0027] Iterate through all binary mask images belonging to the vehicle body panel group in the hierarchical mask set. For each pixel position covered by the mask, read its RGB pixel value from the car image to be processed, convert it to the Lab color space, and extract the L channel value. Sum all the extracted L channel values and divide by the total number of pixels to obtain the original vehicle body area brightness mean value normalized to the [0,1] interval. .
[0028] In S6, the edge-blended image of the car body components includes the complete image area of all car body components that the user has specified to be recolored, after color transfer, material adjustment, and edge blending. In this image, the areas of the components that have been specified to be recolored have presented the target color and material texture selected by the user, and virtual crease shadows have been superimposed on the seams of the components.
[0029] Simultaneously, the system automatically derives and changes the color scheme of associated accessory body parts based on preset color coordination rules. Associated accessory body parts include wheels, brake calipers, rearview mirror housings, and door handles. For each associated accessory, the system reads the corresponding color offset from the preset color coordination rule library. The color matching rule library is based on the classic matching principles of the color wheel in color theory. The specific rules are as follows: Brake calipers correspond to... = That is, using complementary colors to create a dynamic color-blocking effect; the rearview mirror housing corresponds to... = This means using the same color as the body to maintain a cohesive look; the door handles correspond to... = This involves using adjacent colors to create subtle contrast; the wheel rims are dynamically determined based on the brightness of the main body of the vehicle, if the average brightness of the main body of the vehicle is... If the brightness is greater than 0.5, an achromatic scheme is used (saturation is set below 0.1). If the average brightness of the main body of the vehicle... If the value is ≤0.5, then the high-gloss silver solution (saturation 0, brightness 0.85 or higher) is adopted.
[0030] Taking brake calipers as an example, their target hue If the target color of the main vehicle body is = Therefore, the target hue of the brake caliper is 227, corresponding to the blue family. (Attachment target saturation) ,in The average brightness of the main body area; The preset brightness reference value for the accessory under standard lighting is used, for example, 0.7 for brake calipers. Based on the calculation results, the same color migration and edge blending processing is performed on the mask area of the associated accessory using the methods described in steps S2 to S5 to obtain an image of the recolored associated accessory body part.
[0031] The image of the car body parts after edge blending, the associated attached car body parts image after color replacement according to preset hue coordination rules, and the remaining layers of the car image to be processed that were not color-replaced are composited according to preset occlusion relationships. The preset occlusion relationships are determined based on the actual physical stacking order of the car body parts, and the stacking order from bottom to top is as follows: background layer, tire layer, window glass layer, body panel layer (in the order of rear bumper, trunk lid, rear fender, rear door, front door, front fender, hood, and front bumper from bottom to top), roof and pillar layer, exterior accessory layer (door handles are located above the doors, and rearview mirror housings are located above the front door triangle area), wheel hub layer, and brake caliper layer. During compositing, for any pixel position, the layers are stacked sequentially from bottom to top, with the upper layer's non-transparent pixels covering the lower layer's pixels, and finally retaining the value of the topmost non-background pixel. If a pixel position has no valid color-replaced pixel value in all layers (i.e., all masks have a value of 0 at that location), then the original pixel value in the car image to be processed is retained. Finally, the synthesized image is output as the final color-changing preview image to the graphical user interface.
[0032] In one embodiment of the present invention, in step S2, for each pixel within the mask area of the specified color-changing body component, an S-shaped function is constructed using the ratio of the pixel's local gradient magnitude to its local standard deviation to calculate the highlight protection weight, including the following steps: Centered on the current pixel in the car image to be processed, a local neighborhood window of a preset size is extracted, and the local standard deviation of the brightness values within the local neighborhood window is calculated. And calculate the brightness gradient magnitude of the current pixel using edge detection operators. The highlight protection weight W(x) is calculated by constructing an S-shaped function according to the formula: Where k is a parameter controlling the steepness of the S-curve, and τ is a parameter controlling the high-light protection response threshold. It is a very small constant.
[0033] Specifically, the original red component corresponding to each pixel position x within the mask area of the body part to be recolored in the image of the car to be processed is read. Original green component and the original blue component The brightness value I(x) at this pixel location is 0.299. +0.587 +0.114 Centered on x, a square region with sides of 5 pixels is defined on the luminance channel of the car image to be processed as a local neighborhood window N(x). N(x) contains all pixel positions covered by extending 2 pixels in each row and column direction from x, for a total of 25 pixel positions. If x is located at the edge or corner of the car image to be processed, causing the local neighborhood window to extend beyond the image boundary, the pixel values extending beyond the boundary are filled using a mirror-symmetric method. The arithmetic mean of all luminance values within this local neighborhood window is used. Where y is the position of each pixel in N(x), and I(y) is the brightness value at that pixel position; then the local standard deviation is obtained. The local standard deviation characterizes the degree of dispersion of the brightness distribution within N(x). This value is smaller in flat areas of the paint surface and larger in areas containing texture or edges.
[0034] At the same time, a square region with a side length of 3 pixels is defined on the luminance channel of the car image to be processed, centered at x, as the luminance neighborhood. This neighborhood contains 9 pixel locations. The nine luminance values within this 3×3 luminance neighborhood are arranged in a matrix according to their spatial positions, denoted as follows from left to right and top to bottom: ,in Let I(x) be the brightness value at the current pixel position x. Then, apply this 3×3 brightness neighborhood to the horizontal Sobel operator. The horizontal gradient component is obtained by summing the elements-by-element multiplications. The 3×3 brightness neighborhood and the vertical Sobel operator The vertical gradient component is obtained by summing the elements-by-element multiplications. The Sobel operator is a first-order discrete differential operator used to approximate the gradient of an image brightness function. The magnitude of the brightness gradient is then calculated. This value represents the overall drastic degree of brightness change at point x.
[0035] After obtaining the brightness gradient magnitude and local standard deviation at the current pixel location, a ratio is constructed. This ratio distinguishes between brightness abrupt changes caused by specular reflection and brightness fluctuations caused by inherent paint texture. In flat areas of the paint surface, the gradient amplitude and local standard deviation are both small and close in value, with the ratio around 1.0 or lower. At the edges of specular reflection, the gradient amplitude is much larger than the local standard deviation, and the ratio increases significantly. In the formula for calculating the specular protection weight W(x), To prevent extremely small constants from being divided by zero, in this embodiment, the value is taken as [value missing]. k is a parameter controlling the steepness of the S-curve within the transition region. Verification on multiple real-vehicle images shows that for images with normal contrast, k=10.0 results in a smooth and natural transition between the highlight protection and non-protected areas. If the overall image is grayish or dark, the k value can be appropriately reduced to expand the transition range. τ is the threshold parameter for the highlight protection response. Its physical meaning is the critical ratio for determining whether a pixel location belongs to the highlight reflection edge. When the value is less than τ, the output W(x) is biased towards 0 (tends to change color). When the value is greater than τ, the output W(x) is biased towards 1 (preferring to retain the original highlights). In this embodiment, τ is set to 1.2, which can effectively distinguish between the inherent texture fluctuations of the paint surface and the brightness abrupt changes caused by specular reflection.
[0036] In one embodiment of the present invention, in step S2, the hue component and saturation component are replaced with the target hue and the target saturation to obtain the color-changing pixel value; the color-changing pixel value is then mixed with the original pixel value in the car image to be processed according to the highlight protection weight to generate a preliminary color-changing image, including the following steps: The hue and saturation components of the current pixel in the car image to be processed are replaced with the target hue and the target saturation, respectively, while keeping its original brightness component unchanged, to obtain the color-changed pixel value; The color-changing pixel values are mixed with the original pixel values in the car image to be processed, using the highlight protection weight W(x) as the weighting coefficient, to obtain the pixel values at the corresponding positions in the preliminary color-changing image.
[0037] Specifically, the original pixel value in the car image to be processed is the x-value of each pixel position within the mask area of the body part to be recolored. Convert from RGB color space to HSV color space and extract its original lightness component. Keeping the original lightness component unchanged, replace the hue component with the target hue. Replace the saturation component with the target saturation. A new HSV triple was constructed. Convert the HSV triple back to the RGB color space to obtain the color-changing pixel value corresponding to that pixel location. .
[0038] Using the highlight protection weight W(x) as the blending factor, the color-replaced pixel value and the original pixel value are linearly weighted and blended according to their respective color channels to generate the pixel value at that location in the preliminary color-replaced image. The blending operation is performed separately for the red, green, and blue channels; taking the red channel as an example, the blended red component... ,in The red component of the color-changing pixel value. The red component represents the original pixel value; the green and blue components are mixed in the same way. The complete three-channel blending can be uniformly represented as... .
[0039] For example, considering the highlight reflection edge of the front fender in a car body, the highlight protection weight W(x) at a certain pixel location is 0.999, and its original pixel value is (248, 248, 248). After replacement with the same target color, the resulting color-changed pixel value is (247, 210, 25). According to the mixing formula, the red component mixing result is 247.75, the green component mixing result is 247.96, and the blue component mixing result is 247.75. The results of each channel are almost exactly equal to the original pixel value, and the original highlight information is completely preserved, avoiding the situation of incorrectly coloring the highlight reflection.
[0040] After performing color-changing pixel value generation and weighted mixing operations on each pixel position within the mask area of the specified color-changing body part, the calculation results of all pixel positions within the mask area are combined with the original pixel values outside the mask area, which remain unchanged, to generate a complete preliminary color-changing image.
[0041] In one embodiment of the present invention, step S3 includes the following steps: The arithmetic mean of the original saturation values of all pixels within the masked area of the specified color-changing body part in the image of the car to be processed is calculated and used as the original saturation mean. ; For the target saturation Apply nonlinear compensation to obtain the target saturation after compensation. The calculation formula is: Where η is the compensation strength coefficient, These are the attenuation control parameters; Calculate the saturation correction factor For each pixel in the initial color-changing image located within the mask area of the specified color-changing body part, its saturation component is multiplied by a saturation correction factor to obtain a saturation-corrected intermediate color-changing image.
[0042] Specifically, iterate through each pixel position x with a pixel value of 1 within the mask area of the specified car body part to be recolored, read the original RGB pixel value corresponding to that pixel position from the car image to be processed, convert it to the HSV color space, and then extract the original saturation component. Sum all the extracted raw saturation components to obtain the total saturation. Where M represents the set of pixel positions within the mask area of the specified color-changing body part. Dividing the sum of this saturation by the total number of pixels N within the mask area yields the original average saturation value. The original saturation mean reflects the vibrancy of the original color of the body part area before the color change. The higher the value, the more vibrant the original paint color, and the lower the value, the closer the original paint is to achromatic, i.e., white, black or gray.
[0043] Target saturation (Values range [0,1]) Apply nonlinear compensation to obtain the compensated target saturation. In its calculation formula, the compensation intensity coefficient η is used to control the maximum amplitude of saturation compensation. Considering that low-saturation background colors (such as white and silver) tend to appear dull after color replacement, the value of η should be able to compensate for this deficiency. Through comparison of color replacement effects on multiple real-world vehicle images with different background colors, setting η=0.45 makes the color vibrancy after color replacement nearly consistent with the effect of directly shooting the original high-saturation vehicle body. Attenuation control parameters. The rate at which the compensation amount decays as the mean of the original saturation increases determines the steepness of the exponential decay curve; in this embodiment, A value of 0.15 is used. When the original saturation reaches approximately 0.3 or higher, the compensation amplitude decreases significantly to avoid oversaturating the already vibrant car body. The value range can be [0.1, 0.3]. The physical meaning of its calculation formula is that when the original car body color saturation is low, Smaller, exponential term Approaching 1, Will be significantly higher than This compensates for the lack of vibrancy in the color change due to a dull base color; while when the original car body color is already quite vibrant, The value is relatively large, and the exponential term approaches 0. Basically equal to Avoid oversaturation.
[0044] For example, when the original color of a car body part is white, the average original saturation value within its mask area... The value is 0.08; the user-specified target saturation is the racing yellow. =0.95; take η=0.45, =0.15, then the compensated target saturation ≈1.20; After truncation, the actual value is 1.0 (effective upper limit of saturation). It can be seen that the low saturation of the original white body causes the target saturation to be significantly increased to the upper limit, and the racing yellow will present a full and bright effect after the color change.
[0045] Calculate the saturation correction factor This factor represents the ratio of the compensated target saturation to the original target saturation, where ϵ is a minimal constant to prevent division by zero, and in this embodiment, it takes the value of . For each pixel position x in the preliminary color-change image located within the mask area of the specified color-changeable body part, its corresponding preliminary color-change pixel value is read, converted from the RGB color space to the HSV color space, and its saturation component is extracted. Then the corrected saturation components are calculated. Clip ( The calculation result is constrained to the interval [0,1]. Values exceeding the upper limit are taken as 1.0, and values below the lower limit are taken as 0. The hue and lightness components at pixel position x are kept unchanged. Replace the original saturation component to construct a corrected HSV triplet, then convert it back to the RGB color space to obtain the saturation-corrected pixel values. After performing the above operation on all pixel positions within the mask area, combine the saturation-corrected pixel values with the original pixel values that remain unchanged outside the mask area to generate the complete intermediate color-change image.
[0046] In one embodiment of the present invention, step S4, extracting the local surface reflection intensity factor of the vehicle image to be processed, includes the following steps: For each pixel within the mask area of the specified color-changing body component, the brightness gradient magnitude in the vehicle image to be processed is calculated using an edge detection operator. And obtain the brightness value I(x) of that pixel; The cosine of the angle between the surface normal at the pixel and the light source direction is calculated using the inner product of the direction of the brightness gradient and the preset main light source direction vector. The local surface reflection intensity factor R(x) is calculated using the following formula: , where max(0.01, I(x)) means taking the larger value between 0.01 and I(x).
[0047] Specifically, firstly, the brightness gradient magnitude and brightness value of each pixel position x in the mask area of the specified color-changing body part are calculated in the car image to be processed, and the calculation method is consistent with the method described in claim 2.
[0048] Based on the geometric relationship between image brightness gradient and surface orientation, the cosine of the angle between the surface normal at the pixel location and the preset main light source direction, cosθ(x), is calculated. The projection of the surface normal onto the imaging plane is approximated using the image brightness gradient direction. In this embodiment, a computationally feasible and physically reasonable approximation method is employed: the horizontal gradient component at pixel location x... and vertical gradient components This is considered as the projection components of the surface normal vector onto the two coordinate axes within the image plane, and a third component perpendicular to the image plane and pointing towards the observer is introduced on top of this. Specifically, a three-dimensional vector is constructed. Its three components are defined as follows: , , , where δ is a preset minimum positive number used to ensure that the vector does not degenerate into a zero vector even in a flat region where the gradient is zero. In this embodiment, δ = 0.01 is taken. This vector serves as an approximate representation of the local surface normal at pixel location x. It is then normalized to obtain a normal vector of unit length. .
[0049] Preset main light source direction vector This is a predefined three-dimensional unit vector used to simulate the incident direction of the main light source in the shooting environment. In this embodiment, based on common lighting conditions in automotive photography, the default setting for the main light source direction is obliquely shining from the upper left of the image onto the car body, and the corresponding three-dimensional vector is... =(−1,−1,1), and normalize it so that its magnitude is equal to 1. The normalized light source direction vector is denoted as . For images whose lighting conditions significantly deviate from the default settings (e.g., backlighting, side-backlighting), the main light source direction vector can be automatically obtained by dynamically parsing the image content. First, pixels in the image to be processed with brightness values higher than the normalization threshold of 0.85 and located within any body panel area in the hierarchical mask set are selected. Second, the brightness-weighted centroid coordinates of the aforementioned pixels are calculated. Simultaneously, the geometric center coordinates of the vehicle body panel area in the image plane are calculated. Then, using the offset vector of the centroid relative to the geometric center ( - , - As a projection of the image plane, and with the introduction of a preset depth constant. (For example, take) =1.0), construct a three-dimensional vector Finally, Normalization yields a unit vector, which serves as the direction vector of the main light source. If there are insufficient specular pixels or the offset is too small, it reverts to the aforementioned default vector; alternatively, it can receive the two-dimensional coordinates (u,v) dragged by the user on the image through a graphical user interface and map them according to a preset mapping relationship. The vector is converted into a 3D vector and normalized to serve as the main light source direction vector, where W and H are the image width and height, and f is the preset focal length parameter.
[0050] Through calculation and The inner product yields the cosine of the included angle. The result of this inner product operation is mathematically equal to the cosine of the angle between the two vectors. When the angle between the surface normal and the light source direction is less than... When the inner product is positive, the surface faces the light source; when the included angle is greater than or equal to... When the inner product is negative or zero, the surface faces away from the light source. In this embodiment, the negative inner product result is directly set to 0, that is, when... When, let cosθ(x) = 0. For the car image to be processed, the gradient is minimal (e.g., In the flat region (<0.01), the gradient direction is unreliable, so a default cosine value of 0.5 is directly assigned, which corresponds to cosθ(x) being approximately The typical state.
[0051] The local surface reflection intensity factor R(x) is calculated. In its calculation formula, max(0.01, I(x)) prevents the denominator from being too small and causing abnormal amplification of the calculation result when the brightness value I(x) is extremely low (e.g., close to 0). In the normalized brightness space [0,1], the human eye can hardly distinguish details and colors in areas with brightness below 0.01, which belong to the extremely dark areas of the image. The gradient calculation signal-to-noise ratio in such areas is low. By limiting the minimum value of the denominator, excessive amplification of noise can be avoided. Therefore, the lower limit value is 0.01. R(x) integrates three types of information: gradient magnitude, brightness level, and surface orientation. It is used to characterize the specular reflection intensity at the pixel location caused by surface geometric undulations and illumination direction, and this characterization is independent of the specific paint material type.
[0052] In one embodiment of the present invention, step S4 involves adjusting the luminance component of the intermediate color-changing image based on the diffuse reflection adjustment index and the specular enhancement coefficient to generate a color-changing image after material adjustment, including the following steps: For each pixel in the intermediate color-changing image located within the mask area of the specified color-changing body component, extract its brightness component. And calculate the output lightness component. The calculation formula is: in, The target brightness mean, The average brightness value of the original vehicle body area. It is a very small constant. The diffuse reflection modulation index is... R(x) is the specular enhancement coefficient, R(x) is the local surface reflection intensity factor, and Clip(x) is the local surface reflection intensity factor. This means that the result is constrained to the interval [0,1].
[0053] Specifically, the pixel value corresponding to each pixel position x in the mask area of the body part to be recolored is read from the intermediate color-changing image, and then converted from the RGB color space to the HSV color space to obtain the hue component of that pixel position. saturation component and brightness components The lightness component This is the brightness value after saturation correction but before material optical response adjustment, and its value range is the normalized interval [0,1].
[0054] Output brightness component after material adjustment In the calculation formula, To prevent extremely small constants from being divided by zero, in this embodiment, the value is taken as [value missing]. Clip( The expression ,0,1) indicates that the calculation result is constrained within the interval [0,1].
[0055] For example, suppose a pixel is located in the illuminated area of the curved surface of the front fender, and its luminance component is extracted from the intermediate color-changing image. =0.72; The target color is racing yellow, and its average target brightness is... =0.85. The original car body area is white, and its average brightness value is... =0.80; the local surface reflection intensity factor R(x) at this pixel location is 0.185; if the target material is matte paint, the diffuse reflection adjustment index is obtained according to the material type. =0.45, specular enhancement factor =0; calculate the output brightness component. =0.740.
[0056] After obtaining the output brightness component Then, it is compared with the hue components extracted from the intermediate color-swapped image. and saturation component Combining to construct new HSV triples The triplet is converted from the HSV color space back to the RGB color space to obtain the material-adjusted color-change pixel value at that pixel location. This process is repeated for every pixel location within the mask area of the specified color-changeable body part. The calculated results for all pixel locations within the mask area are then combined with the pixel values outside the mask area, which remain unchanged, to generate the complete material-adjusted color-change image.
[0057] In one embodiment of the present invention, in step S5, the symbolic distance field of each vehicle body component mask in the hierarchical mask set is calculated. For each pixel whose absolute value of the symbolic distance field is less than a preset distance threshold, the symbolic distance field value of that pixel is used as a variable, and an asymmetric blending weight is calculated by introducing a cumulative distribution function of positive offset. Based on the asymmetric blending weight, the color-changing image after material adjustment is blended with the vehicle image to be processed, including the following steps: Calculate the signed distance field d(p) of the mask for each body part, where the distance inside the mask is positive and the distance outside is negative; For the symbolic distance field, satisfying The pixel position p, where Calculate the asymmetric mixing weight λ(p) based on the preset distance threshold; if d(p) ≥ 0, then λ(p) = Where μ is the positive offset, σ is the transition bandwidth control parameter, and Φ( λ(p) is the cumulative distribution function of the standard normal distribution; if d(p) < 0, then λ(p) = 0. The corresponding pixel values in the color-changing image after material adjustment are mixed with the corresponding pixel values in the car image to be processed, using an asymmetric mixing weight λ(p) as the interpolation coefficient, to obtain the mixed pixel values. .
[0058] Specifically, for each car body component mask designated for color change in the hierarchical mask set, the signed distance field d(p) of the mask is calculated. The signed distance field is a single-channel image of the same size as the car image to be processed. If the pixel position p is inside the mask, i.e., within the area of the car body component, then d(p) takes a positive value, which is equal to the shortest Euclidean distance from the pixel to the mask boundary; if p is outside the mask, then d(p) takes a negative value, whose absolute value is the shortest Euclidean distance from the pixel to the mask boundary, and the distance value corresponding to the boundary pixel itself is zero. This embodiment uses an eight-way sequential Euclidean distance transform algorithm to calculate the signed distance field. This algorithm traverses the image pixels through two raster scans to complete the calculation of the signed distance field in linear time complexity. The first scan starts from the upper left corner of the image and traverses row by row to the lower right corner. For each pixel, the distance value is updated using its calculated neighbors to the left and above. The second scan traverses in reverse from the lower right corner to the upper left corner, using its neighbors to the right and below to further correct the distance value, finally obtaining the signed distance of each pixel to the nearest boundary. During the calculation, the distance value is in pixels, and its theoretical range is determined by the image size. The maximum possible distance value is the length of the image diagonal. For example, if the resolution of the car image to be processed is 1920 pixels wide by 1080 pixels high, its diagonal pixel length is approximately 2203 pixels. Therefore, the range of d(p) is [−2203, 2203] pixels.
[0059] For the mask of this body part, a distance threshold is preset. This is used to define the width of the transition band that needs edge blending. At common mobile phone shooting distances, the seams between automotive sheet metal parts typically occupy 2 to 5 pixels in the image. This embodiment uses... =3.0 pixels, to match this visual width.
[0060] For the symbolic distance field, the condition is satisfied For each pixel position p, an asymmetric blending weight λ(p) is calculated. If d(p) ≥ 0, meaning p is located inside or on the boundary of the mask, then λ(p) = If d(p) < 0, meaning p is outside the mask, then λ(p) = 0. Where Φ( The cumulative distribution function is the standard normal distribution. The positive offset μ is used to shift the transition center of the asymmetric blending weight towards the inside of the vehicle body components, causing the fusion area of the old and new colors to fall more on the inside of the components rather than at the seam center, thus simulating the visual effect of the film edge being obscured by adjacent components during actual film application. Observations of seam structures on different vehicle models show that μ=1.5 pixels can reproduce this feature well. The transition bandwidth control parameter σ determines the smoothness of the asymmetric blending weight increase from 0 to 1. When σ is 0.8, the transition band edge feathering is soft and no obvious double shadow phenomenon is produced.
[0061] After obtaining the asymmetric mixing weight λ(p), the pixel value at the corresponding pixel position is read from the material-adjusted color-changing image, denoted as... Read the raw pixel values from the car image to be processed, and denot them as follows: The two values are then blended using standard linear interpolation to obtain the blended pixel value. The blending operation is performed separately for the red, green, and blue channels. The complete three-channel blending formula is: .
[0062] For pixel locations in the symbolic distance field that do not satisfy the transition band condition, i.e., d(p)≥ The inner area of the mask directly uses the pixel values of the recolored image after material adjustment. For d(p)≤− The mask is located far from the boundary area, and the pixel values of the car image to be processed are used directly. Using the above method, a width of 2 is only applied near the mask boundary. The fusion calculation is performed within the narrow band region, while the rest of the region remains unchanged.
[0063] For each designated body part mask undergoing color change, the aforementioned symbolic distance field calculation, asymmetric blending weight calculation, and pixel blending operation are performed to obtain the blended image region corresponding to each part. For overlapping areas between different parts, such as the junction of the door and the fender, the final display pixels are determined according to a preset occlusion order. In this embodiment, an outside-to-inside order is adopted, i.e., the outer cover is superimposed on the inner cover. Thus, the blended pixel values are obtained.
[0064] In one embodiment of the present invention, step S5, which involves superimposing a virtual crease shadow generated by the Gaussian Laplace response of the symbolic distance field on the inner side of the body component in the mixed region, includes the following steps: The Gaussian Laplace response of the symbolic distance field d(p) was calculated. ; The virtual crease shadow is superimposed onto the blended pixel value. The calculation formula is: Where γ is the shadow intensity coefficient, max(0, ) indicates taking the larger of 0 and the input value.
[0065] Specifically, based on the mixed pixel values, for each pixel position p located within the transition zone of the mask boundary of the vehicle body component, a virtual crease shadow generated by the Gaussian Laplace response of the signed distance field is further superimposed; this operation only occurs when the following conditions are met. The pixel position is executed, and for areas outside the transition zone, the blended pixel values are retained without shadow overlay processing.
[0066] The Laplacian response of the symbolic distance field d(p) is calculated. The Laplacian operator is a type of bandpass filter whose mathematical form is the second derivative of the Gaussian function, used to detect ridges or valleys in images. In the two-dimensional discrete implementation, a Laplacian convolution kernel of size K×K is constructed. In this embodiment, K=7, meaning the kernel side length is 7 pixels. The kernel size K is based on the standard deviation of the Gaussian kernel. Determined, usually greater than 6 The smallest odd number. The element values of the convolution kernel are obtained by sampling and discretization from continuous form: , where u and v are coordinate offsets relative to the center of the convolution kernel, in pixels, and their values are integers within the range [−⌊K / 2⌋, ⌊K / 2⌋]. Laplace-Gaussian operator. The standard deviation of the value determines the width of the virtual crease shadow. To ensure that the shadow width matches the visual width of the actual sheet metal seam in the image, this embodiment uses... =1.0 pixels.
[0067] Perform a two-dimensional convolution operation between the symbolic distance field d(p) and the Laplacian Gaussian convolution kernel to obtain the Laplacian Gaussian response value at each pixel location. The specific method of convolution operation is as follows: A K×K convolution kernel is placed over the signed distance field, centered at pixel position p. The distance values of each element within the kernel and their corresponding pixels are multiplied and summed to obtain the response output for that pixel position. Because the signed distance field exhibits a "ridge" structure at the mask boundary (positive inside, negative outside), the Laplacian of Gaussian operator produces a strong negative response at the boundary, with a negative response in the adjacent region inside the boundary and a positive response in the adjacent region outside the boundary.
[0068] After obtaining the Gaussian Laplacian response, the virtual crease shadow is superimposed onto the blended pixel values to obtain the final pixel values after edge blending. In its calculation formula, the shadow intensity coefficient γ is used to control the depth of the virtual crease shadow. Considering that the shadow at the seam after the actual film is applied usually shows a decrease in brightness of about 30% to 40%, taking γ=0.35 can simulate this natural attenuation effect. Indicates taking 0 and The larger of the two values is used to extract only the negative portion of the Gaussian Laplace response and reverse its sign to positive. This means that positive shading coefficients are generated only inside the boundary, while outside the boundary, the response is positive. The value is negative, and after maximization, it is set to 0 to ensure that the shadow is only superimposed on the inner area of the body parts. The physical meaning of the formula for calculating this final pixel value is that at the sheet metal joints, due to the folds and mutual occlusion of the metal sheets, the light after the film is applied will produce a self-shadow at the gap, which appears as a narrow dark strip. This step simulates this physical shadow effect by multiplying the original pixel value at the negative Laplacian response position of the signed distance field by a decay factor less than 1, thereby reducing the pixel brightness at that location.
[0069] The virtual crease shadow overlay operation is performed on each pixel within the mask boundary transition zone to obtain a complete edge-blended image of the vehicle body component. Finally, the edge-blended image regions corresponding to each vehicle body component are combined according to their original image positions, and the overlap between masks of different components is processed. For overlapping pixels, the final display pixel value is determined according to a preset occlusion order. This embodiment adopts a priority occlusion order for exterior vehicle body panels, that is, layering them sequentially from the outside to the inside, such as rearview mirror housings, door handles, doors, fenders, and hoods. After this synthesis, an edge-blended image of the vehicle body component is obtained.
[0070] Please see Figure 2 As shown, this invention is an AI-powered car wrapping color-changing recommendation system based on vehicle body region segmentation and color mapping, comprising the following modules: The semantic segmentation and parameter acquisition module is used to acquire the car image to be processed, and to perform pixel-level semantic segmentation on the car image using a pre-trained semantic segmentation model to generate a hierarchical mask set containing semantic labels of multiple body parts. At the same time, it acquires the target hue, target saturation and target brightness mean of the target color specified by the user, and acquires the diffuse reflection adjustment index and highlight enhancement coefficient according to the target paint material type specified by the user, as well as the brightness mean of the original body area. The preliminary color-changing module is used to take each pixel in the mask area of the specified car body part to be color-changed, keep its original lightness component unchanged, and replace its hue component and saturation component with the target hue and the target saturation respectively to obtain the color-changed pixel value; construct an S-shaped function based on the ratio of the local gradient magnitude to the local standard deviation of the pixel to calculate the highlight protection weight, and mix the color-changed pixel value with the original pixel value in the car image to be processed according to the highlight protection weight to generate a preliminary color-changed image; The saturation compensation module is used to calculate the original average saturation value of the mask area of the specified color-changing body part, apply nonlinear compensation to the target saturation using the original average saturation value to obtain the compensated target saturation, and use the compensated target saturation to correct the saturation of the preliminary color-changing image to generate an intermediate color-changing image. The material adjustment module is used to extract the local surface reflection intensity factor of the car image to be processed, and adjust the brightness component of the intermediate color-changing image based on the diffuse reflection adjustment index and the highlight enhancement coefficient to generate the color-changing image after material adjustment. The edge blending module is used to calculate the symbolic distance field of each body part mask in the hierarchical mask set. For each pixel whose absolute value of the symbolic distance field is less than a preset distance threshold, the symbolic distance field value of the pixel is used as a variable, and an asymmetric blending weight is calculated by introducing a cumulative distribution function of positive offset. Based on the asymmetric blending weight, the color-changing image after material adjustment is blended with the car image to be processed, and a virtual crease shadow generated by the Gaussian Laplace response of the symbolic distance field is superimposed on the inner side of the body part in the blending area to obtain the edge-blended body part image. The layer compositing module is used to combine the edge-blended car body component image, the associated attachment car body component image automatically derived and applied with color change according to preset hue coordination rules, and the remaining layers in the car image to be processed that did not participate in color change according to preset occlusion relationships, and output the final color-change preview image.
[0071] The above embodiments are only used to illustrate the technical methods of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical methods of the present invention without departing from the spirit and scope of the technical methods of the present invention.
Claims
1. A method for recommending car wrap colors based on vehicle body region segmentation and color mapping using AI, characterized in that, Includes the following steps: S1: Acquire the car image to be processed and perform pixel-level semantic segmentation using a pre-trained semantic segmentation model to generate a hierarchical mask set containing semantic labels of multiple car body parts; at the same time, acquire the target hue, target saturation and target brightness mean of the target color specified by the user, acquire the diffuse reflection adjustment index and highlight enhancement coefficient according to the target paint material type specified by the user, and acquire the brightness mean of the original car body area. S2: For each pixel in the mask area of the body part to be recolored, replace its hue component and saturation component with the target hue and the target saturation to obtain the recolored pixel value; An S-shaped function is constructed using the ratio of the local gradient magnitude to the local standard deviation of the pixel to calculate the highlight protection weight. Based on the highlight protection weight, the color-changing pixel value is mixed with the original pixel value in the car image to be processed to generate a preliminary color-changing image. S3: Calculate the original average saturation value of the mask area of the body part to be specified for color change, and use the original average saturation value to apply nonlinear compensation to the target saturation to obtain the compensated target saturation. In this way, the saturation of the preliminary color change image is corrected to generate an intermediate color change image. S4: Extract the local surface reflection intensity factor of the car image to be processed, and adjust the brightness component of the intermediate color-changing image based on the diffuse reflection adjustment index and the specular enhancement coefficient to generate the color-changing image after material adjustment. S5: Calculate the symbolic distance field of each body part mask in the hierarchical mask set. For each pixel whose absolute value of the symbolic distance field is less than a preset distance threshold, use the symbolic distance field value of the pixel as a variable, introduce the cumulative distribution function of positive offset to calculate the asymmetric blending weight, and blend the material-adjusted color-changing image with the car image to be processed according to the asymmetric blending weight. Then, superimpose the virtual crease shadow generated by the Gaussian Laplacian response of the symbolic distance field on the inner side of the body part in the blending area to obtain the body part image after edge blending. S6: Combine the edge-blended vehicle body component image, the associated accessory vehicle body component image automatically derived and color-changed according to preset hue coordination rules, and the remaining layers in the vehicle image to be processed that did not participate in the color change according to preset occlusion relationships, and output the final color-changed preview image.
2. The AI-based car wrapping color recommendation method based on vehicle body region segmentation and color mapping according to claim 1, characterized in that, In step S2, for each pixel within the mask area of the specified color-changing body part, an S-shaped function is constructed using the ratio of the pixel's local gradient magnitude to its local standard deviation to calculate the highlight protection weight. This includes the following steps: Centered on the current pixel in the car image to be processed, a local neighborhood window of a preset size is extracted, and the local standard deviation of the brightness values within the local neighborhood window is calculated. And calculate the brightness gradient magnitude of the current pixel using edge detection operators. The highlight protection weight W(x) is calculated by constructing an S-shaped function according to the formula: Where k is a parameter controlling the steepness of the S-curve, and τ is a parameter controlling the high-light protection response threshold. It is a very small constant.
3. The AI-based color-changing recommendation method for automotive wrapping based on vehicle body region segmentation and color mapping according to claim 2, characterized in that, In step S2, the hue and saturation components are replaced with the target hue and target saturation to obtain the color-changing pixel values. Based on the highlight protection weight, the color-changing pixel values are mixed with the original pixel values in the car image to be processed to generate a preliminary color-changing image, including the following steps: The hue and saturation components of the current pixel in the car image to be processed are replaced with the target hue and the target saturation, respectively, while keeping its original brightness component unchanged, to obtain the color-changed pixel value; The color-changing pixel values are mixed with the original pixel values in the car image to be processed, using the highlight protection weight W(x) as the weighting coefficient, to obtain the pixel values at the corresponding positions in the preliminary color-changing image.
4. The AI-based color-changing recommendation method for automotive wrapping based on vehicle body region segmentation and color mapping as described in claim 1, characterized in that, S3 includes the following steps: The arithmetic mean of the original saturation values of all pixels within the masked area of the specified color-changing body part in the image of the car to be processed is calculated and used as the original saturation mean. ; For the target saturation Apply nonlinear compensation to obtain the target saturation after compensation. The calculation formula is: Where η is the compensation strength coefficient, These are the attenuation control parameters; Calculate the saturation correction factor For each pixel in the initial color-changing image located within the mask area of the specified color-changing body part, its saturation component is multiplied by a saturation correction factor to obtain a saturation-corrected intermediate color-changing image.
5. The AI-powered car wrapping color-changing recommendation method based on vehicle body region segmentation and color mapping according to claim 1, characterized in that, In step S4, extracting the local surface reflection intensity factor of the vehicle image to be processed includes the following steps: For each pixel within the mask area of the specified color-changing body component, the brightness gradient magnitude in the vehicle image to be processed is calculated using an edge detection operator. And obtain the brightness value I(x) of that pixel; The cosine of the angle between the surface normal at the pixel and the light source direction is calculated using the inner product of the direction of the brightness gradient and the preset main light source direction vector. The local surface reflection intensity factor R(x) is calculated using the following formula: , where max(0.01, I(x)) means taking the larger value between 0.01 and I(x).
6. The AI-based color-changing recommendation method for automotive wrapping based on vehicle body region segmentation and color mapping according to claim 1, characterized in that, In step S4, the brightness component of the intermediate color-changing image is adjusted based on the diffuse reflection adjustment index and the specular enhancement coefficient to generate a color-changing image after material adjustment, including the following steps: For each pixel in the intermediate color-changing image located within the mask area of the specified color-changing body component, extract its brightness component. And calculate the output lightness component. The calculation formula is: in, The target brightness mean, The average brightness value of the original vehicle body area. It is a very small constant. The diffuse reflection modulation index is... R(x) is the specular enhancement coefficient, R(x) is the local surface reflection intensity factor, and Clip(x) is the local surface reflection intensity factor. This means that the result is constrained to the interval [0,1].
7. The AI-powered car wrapping color-changing recommendation method based on vehicle body region segmentation and color mapping according to claim 1, characterized in that, In step S5, the symbolic distance field of each vehicle body component mask in the hierarchical mask set is calculated. For each pixel whose absolute value of the symbolic distance field is less than a preset distance threshold, the symbolic distance field value of that pixel is used as a variable, and an asymmetric blending weight is calculated by introducing a cumulative distribution function of positive offset. Based on the asymmetric blending weight, the color-changing image after material adjustment is blended with the vehicle image to be processed, including the following steps: Calculate the signed distance field d(p) of the mask for each body part, where the distance inside the mask is positive and the distance outside is negative; For the symbolic distance field, satisfying The pixel position p, where Calculate the asymmetric mixing weight λ(p) based on the preset distance threshold; if d(p) ≥ 0, then λ(p) = Where μ is the positive offset, σ is the transition bandwidth control parameter, and Φ( λ(p) is the cumulative distribution function of the standard normal distribution; if d(p) < 0, then λ(p) = 0. The corresponding pixel values in the material-adjusted color-changing image and the corresponding pixel values in the car image to be processed are mixed using an asymmetric mixing weight λ(p) as the interpolation coefficient to obtain the mixed pixel values. .
8. The AI-based color-changing recommendation method for automotive wrapping based on vehicle body region segmentation and color mapping according to claim 7, characterized in that, In step S5, the virtual crease shadow generated by the Gaussian Laplace response of the symbolic distance field is superimposed on the inner side of the body component in the mixed region, including the following steps: The Gaussian Laplace response of the symbolic distance field d(p) was calculated. ; The virtual crease shadow is superimposed onto the blended pixel value. The calculation formula is: Where γ is the shadow intensity coefficient, max(0, ) indicates taking the larger of 0 and the input value.
9. A car wrapping AI color-changing recommendation system based on vehicle body region segmentation and color mapping, characterized in that, Includes the following modules: The semantic segmentation and parameter acquisition module is used to acquire the car image to be processed and perform pixel-level semantic segmentation using a pre-trained semantic segmentation model to generate a hierarchical mask set containing semantic labels of multiple car body parts; at the same time, it acquires the target hue, target saturation and target brightness mean of the target color specified by the user, acquires the diffuse reflection adjustment index and highlight enhancement coefficient according to the target paint material type specified by the user, and acquires the brightness mean of the original car body area. The preliminary color-changing module is used to replace the hue and saturation components of each pixel in the mask area of the specified color-changing body part with the target hue and saturation, thereby obtaining the color-changing pixel value; construct an S-shaped function based on the ratio of the local gradient magnitude to the local standard deviation of the pixel to calculate the highlight protection weight, and mix the color-changing pixel value with the original pixel value in the car image to be processed according to the highlight protection weight to generate a preliminary color-changing image; The saturation compensation module is used to calculate the original average saturation value of the mask area of the specified color-changing body part, and to apply nonlinear compensation to the target saturation using the original average saturation value to obtain the compensated target saturation. This is used to correct the saturation of the initial color-changing image and generate an intermediate color-changing image. The material adjustment module is used to extract the local surface reflection intensity factor of the car image to be processed, and adjust the brightness component of the intermediate color-changing image based on the diffuse reflection adjustment index and the highlight enhancement coefficient to generate the color-changing image after material adjustment. The edge blending module calculates the symbolic distance field of each body part mask in the hierarchical mask set. For each pixel whose absolute value of the symbolic distance field is less than a preset distance threshold, the symbolic distance field value of that pixel is used as a variable. An asymmetric blending weight is calculated by introducing the cumulative distribution function of the positive offset. Based on the asymmetric blending weight, the color-changing image after material adjustment is blended with the car image to be processed. A virtual crease shadow generated by the Gaussian Laplacian response of the symbolic distance field is superimposed on the inner side of the body part in the blending area to obtain the edge-blended body part image. The layer compositing module is used to combine the edge-blended car body component image, the associated accessory car body component image that has been automatically deduced and color-changed according to preset hue coordination rules, and the remaining layers in the car image to be processed that have not participated in the color change according to preset occlusion relationships, and output the final color-changed preview image.