An interactive tourism image vectorization method and device
By employing geometric correction, diffraction mapping, grayscale conversion, and multi-scale enhancement processing, combined with an attention mechanism and a conditional random field-based deep segmentation model, the problem of uneven image quality in cultural and tourism image acquisition environments was solved, generating high-quality semantic vector graphics and improving the structural expressiveness and semantic readability of the images.
Patent Information
- Application Number
- CN202511280548.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-09
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2045-09-09
AI Technical Summary
In the current technology for cultural and tourism image acquisition, the image quality varies due to the influence of the image acquisition environment. Directly vectorizing the entire image results in unsatisfactory effects and reduces the usability of the materials in the material library.
Coordinate mapping relationships are constructed through geometric correction and diffraction mapping. Combined with grayscale conversion, texture entropy calculation and multi-scale enhancement processing, the image structure fidelity and texture clarity are improved. Interactive semantic segmentation is performed using a depth segmentation model that incorporates attention mechanism and conditional random field to extract connected regions and optimize boundary structure. Edges are fitted using Bézier curves and color-calibrated images are generated in combination with user interaction. Finally, a semantic vector image conforming to the SVG standard is constructed.
It significantly improves the structural fidelity and texture clarity of images, generates segmented images with continuous structure and clear semantics, and outputs color-calibrated images with realism and consistency, thus comprehensively enhancing the structural expressiveness and semantic readability of images.
Smart Images

Figure CN120765796B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of image processing, in particular to an interactive cultural and travel image vectorization method and device. BACKGROUND
[0002] In the field of cultural and travel, the application of vectorization technology has been upgraded from the early "image digitization tool" to "cultural heritage data infrastructure". Compared with raster images, vectorized cultural and travel images have many advantages, such as image quality and resolution independent, can be scaled without distortion; compact storage, small file size, efficient storage and transmission; support for editing and modifying geometric primitives, and can highly meet the scene needs of cultural relic protection, cultural and creative development, digital display, etc.
[0003] However, the existing technology still has bottlenecks in natural texture processing, semantic understanding, real-time calculation, etc. In the image collection of cultural and travel, the image quality is uneven due to the influence of the image collection environment. The effect of the vector image obtained by directly vectorizing the whole image of the image with unsatisfactory effect is greatly reduced, which cannot fully play its cultural value, and further reduces the use value of the materials in the material library.
[0004] Therefore, an interactive cultural and travel image vectorization method and device are needed. SUMMARY
[0005] The present application provides an interactive cultural and travel image vectorization method and device, which solves the problem that the effect of the vector image obtained by directly vectorizing the whole image of the image with unsatisfactory effect is greatly reduced.
[0006] In a first aspect of the present application, an interactive cultural and travel image vectorization method is provided, the method comprising: obtaining a cultural and travel image, and pre-processing the cultural and travel image to obtain a pre-processed image; segmenting the pre-processed image to obtain a segmented image; performing edge extraction operation and fitting operation on the segmented image to obtain image edge features; performing color attribute assignment operation based on the image edge features to obtain a color calibrated image; performing semantic encoding operation based on the color calibrated image to obtain a vector image corresponding to the cultural and travel image.
[0007] Optionally, the cultural and travel image is obtained, specifically including: obtaining the cultural and travel image through a preset acquisition device, the preset acquisition device including a digital camera and a scanner; obtaining an image type of the cultural and travel image, and setting differential acquisition parameters based on the image type, the image type including a cultural relic image type, a building image type and a landscape image type; based on the differential acquisition parameters, constructing a coordinate mapping relationship corresponding to the cultural and travel image through geometric correction operation and diffraction mapping operation.
[0008] Optionally, the travel image is preprocessed to obtain a preprocessed image, specifically including: converting the travel image into a gray image by a weighted average method; determining a texture entropy of the travel image based on the gray image, and performing hierarchical noise reduction on the travel image through the texture entropy; performing image enhancement processing on the travel image after noise reduction, the image enhancement processing including Retinex processing and CLAHE enhancement processing; performing an evaluation operation on the travel image after enhancement based on a peak signal-to-noise ratio and a structural similarity of the travel image after image enhancement; if the evaluation operation confirms a first evaluation result, returning the original travel image and marking a noise area in the travel image; if the evaluation operation confirms a second evaluation result, adjusting a filter kernel size in the travel image and increasing an iteration number; if the evaluation operation confirms a third evaluation result, outputting the travel image after image enhancement as the preprocessed image.
[0009] Optionally, the preprocessed image is segmented to obtain a segmented image, specifically including: constructing an image segmentation model based on a neural network structure with an attention mechanism and a conditional random field, and interactively marking the preprocessed image through the image segmentation model; performing a segmentation operation on the marked preprocessed image based on the image segmentation model to segment the marked preprocessed image into a plurality of connected regions; performing a corresponding kernel erosion or expansion operation on the connected regions based on feature parameters of each connected region, and obtaining high-uncertainty regions in the plurality of connected regions through a preset evaluation operation, the feature parameters including an area parameter, a perimeter parameter, an aspect ratio parameter, and an edge complexity parameter; performing an optimization iteration on the high-uncertainty regions to complete the image segmentation operation, and outputting the segmented image.
[0010] Optionally, an edge extraction operation and a fitting operation are performed on the segmented image to obtain image edge features, specifically including: performing an edge extraction operation on each sub-element in the segmented image to obtain sub-element information; performing a fitting operation on the sub-element information using a cubic Bezier curve to obtain the image edge features.
[0011] Optionally, a color attribute allocation operation is performed based on the image edge features to obtain a color calibration image, specifically including: extracting pixel values of each connected region in the sub-element based on coordinates of the image edge and a mapping relationship between the coordinates and color values, and calculating an average color as a fill color; performing color filling on the travel image based on the fill color, and determining whether the image color after color filling meets a preset requirement; if the image color does not meet the preset requirement, increasing or decreasing the color through a preset interactive mode; if the image color meets the preset requirement, taking the image after color filling as the color calibration image.
[0012] Optionally, the semantic coding operation is performed based on the color calibration image to obtain a vector diagram corresponding to the travel image, and specifically includes: encoding color attributes of the color calibration image into an XML format, and adding corresponding semantic labels in the XML format; outputting the color calibration image with the added semantic labels into an SVG vector diagram file to obtain the vector diagram corresponding to the travel image.
[0013] In a second aspect of the present application, an interactive travel image vectorization device is provided, the device comprising an acquisition module and a processing module, wherein,
[0014] The acquisition module is configured to acquire a travel image and pre-process the travel image to obtain a pre-processed image.
[0015] The processing module is configured to segment the pre-processed image to obtain a segmented image, perform edge extraction and fitting operations on the segmented image to obtain image edge features, perform color attribute allocation based on the image edge features to obtain a color calibration image, and perform semantic coding based on the color calibration image to obtain a vector diagram corresponding to the travel image.
[0016] In a third aspect of the present application, an electronic device is provided, comprising a processor, a memory, a user interface and a network interface, the memory is configured to store instructions, the user interface and the network interface are configured to communicate with other devices, and the processor is configured to execute the instructions stored in the memory to enable the electronic device to perform the method of any one of the above aspects.
[0017] In a fourth aspect of the present application, a computer-readable storage medium is provided, the computer-readable storage medium stores a computer program, and the computer program is executed by a processor to perform the method of any one of the above aspects.
[0018] The one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:
[0019] 1An image of a travel and tourism is obtained, and the image is preprocessed through geometric correction, size mapping, and multi-stage enhancement, thereby significantly improving the structural fidelity and texture clarity of the image, and outputting a preprocessed image with uniform scale and high contrast; based on a deep segmentation model introducing an attention mechanism and a conditional random field, interactive semantic segmentation is performed on the preprocessed image, connected regions are extracted, and the boundary structure is optimized through high-uncertainty screening and active learning mechanism, thereby obtaining a segmented image with continuous structure and clear semantics; gradient perception and connected domain labeling are performed on the segmented image to extract edges, and a Bezier curve is used to fit the edges with high precision, thereby generating image edge features with accurate shape and editability; color statistics and compression are performed on each region according to the edge structure, and differential processing is performed on the fill color and the outline color, thereby generating a color calibration image with realistic and consistent color; finally, based on the fusion of edges, colors, and semantics, a vector structure conforming to the SVG standard is constructed, semantic labels are embedded, and a semantic vector image is output, thereby comprehensively improving the image structure expressiveness, semantic readability, and later usability.
[0020] 2An adaptive preprocessing process based on dynamic feedback of image quality is constructed to perform gray scale conversion, noise identification, hierarchical noise reduction, and brightness enhancement on the obtained travel and tourism image, and an image quality evaluation mechanism is introduced to realize hierarchical judgment and processing strategy regulation, thereby realizing balanced improvement of image quality in complex lighting and noise interference environment.
[0021] 3An image segmentation model with attention mechanism and edge optimization capability is constructed, and key semantic region labeling is completed under the guidance of user interaction to generate an initial segmentation image; based on the model prediction result, multiple connected regions in the image are extracted, and differential structure correction processing is performed in combination with region geometry and boundary features; an evaluation mechanism is introduced to quantitatively identify the uncertainty of each connected region, thereby performing key iterative optimization on the region with fuzzy boundary or unstable semantics; finally, a segmentation image with clear boundary, complete structure, and accurate semantics is output, thereby improving the adaptability and expression accuracy of complex travel and tourism images in structural analysis through the combination of full-process semantic driving and local structure regulation, and laying a stable foundation for subsequent edge fitting and semantic vector expression. BRIEF DESCRIPTION OF DRAWINGS
[0022] Figure 1 is a flowchart of an interactive travel and tourism image vectorization method provided by an embodiment of the present application;
[0023] Figure 2 is a module diagram of an interactive travel and tourism image vectorization device provided by an embodiment of the present application;
[0024] Figure 3 is a structural diagram of an electronic device provided by an embodiment of the present application.
[0025] Explanation of reference signs: 21, acquisition module; 22, processing module; 301, processor; 302, communication bus; 303, user interface; 304, network interface; 305, memory. DETAILED DESCRIPTION
[0026] In order for those skilled in the art to better understand the technical solutions in the specification, the technical solutions in the specification will be clearly and completely described below in combination with the drawings in the embodiments of the specification. Obviously, the described embodiments are only some of the embodiments of the present application, not all.
[0027] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments and are not intended to be limiting to the present application. As used in the specification, the singular forms "a," "an," and "the" are intended to include plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "and / or" used in the present application means and includes any or all possible combinations of one or more listed items.
[0028] Hereinafter, the terms "first" and "second" are used only for the purpose of description, and cannot be understood as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined with "first" and "second" can explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, the meaning of "a plurality of" is two or more, unless otherwise specified.
[0029] In order for those skilled in the art to better understand the technical solutions of the present application, the present application will be further described in combination with the drawings.
[0030] Reference is made to Figure 1 which shows a flowchart of an interactive tourism image vectorization method provided by an embodiment of the present application. The flowchart mainly includes the following steps: S101 to S105.
[0031] Step S101, acquiring a tourism image and pre-processing the tourism image to obtain a pre-processed image.
[0032] Specifically, multiple types of tourism images are acquired and a unified processing framework is constructed. By collecting parameter configurations and physical scene modeling for different image types, combined with image distortion correction, size mapping construction and color mapping generation, spatial geometric consistency and color consistency of the images are realized. Then, the images are subjected to gray conversion, hierarchical adaptive noise reduction driven by texture entropy calculation, multi-scale Retinex enhancement and local contrast optimization fusion, a multi-stage collaborative mechanism is established between image structure preservation, noise suppression and detail enhancement, and finally the preprocessed images meeting the accuracy requirements of subsequent segmentation and feature extraction are output
[0033] In this possible implementation, step S101 includes the following sub-steps: S111 to S113.
[0034] In step S111, tourism images are acquired by a preset acquisition device, which includes a digital camera and a scanner.
[0035] Specifically, tourism images are acquired by a preset acquisition device such as a digital camera and a scanner. During the acquisition process, the image sensor in the preset acquisition device can convert the acquired light signals into RAW data, which is processed by the processor into standard format images such as JPEG, PNG, etc., while retaining the original color information.
[0036] In step S112, the image types of the tourism images are acquired, and differential acquisition parameters are set based on the image types. The image types include artifact image types, building image types and landscape image types.
[0037] Specifically, differential acquisition parameters are set for different types of images, including but not limited to artifact image types, building image types, landscape image types, etc. For example, for artifact image types, multiple light sources arranged in a ring (interval ≤10°) are used to irradiate the surface of the measured object from different angles, and a polarizer is installed in front of the ring-shaped light source to generate linearly polarized light. Then, the resolution is set to ≥600 dpi, and the polarized images under different incident angles are acquired by ring scanning, which can effectively eliminate surface reflection and improve image contrast and feature detection accuracy. For building image types, a combination of unmanned aerial vehicle oblique photography (to acquire panoramic structures) and close-range scanner scanning (to acquire local details such as doors, windows and carvings) is used, and the SIFT (Scale-Invariant Feature Transform) algorithm is used to match feature points and generate complete images, ensuring that the geometric structure is not distorted.
[0038] In step S113, based on the differential acquisition parameters, the coordinate mapping relationship corresponding to the tourism images is constructed through geometric correction operation and diffraction mapping operation.
[0039] Specifically, the geometric correction operation: in the distortion correction, a standard checkerboard calibration plate (such as 10x7 corner points) is used, and it is ensured that the actual size is known (such as each square edge length of 20mm); by detecting the checkerboard corner points in the image, the pixel coordinates are obtained; the function (cv2 calibrated) is called to calculate the camera intrinsic matrix and the distortion coefficient (dist_coeffs), and the barrel or pillow distortion is eliminated. In the size mapping, the pixel coordinates and the actual physical coordinates (such as the physical size coordinates of the edge corners of the checkerboard) of the four corner points of the calibration plate are selected, and the function (cv2.getPerspectiveTransform) is used to generate a 3x3 transformation matrix M to map the pixel coordinates to the physical coordinate system; the function (cv2.warpPerspective) is used to perform perspective correction on the image, and the pixel-to-physical size ratio (such as 1 pixel = 0.1mm) is calculated in combination with the calibration plate size.
[0040] Diffractive mapping operation: by traversing the pixels, the coordinates (i,j) and the corresponding RGB values of the corrected image are recorded pixel by pixel to generate a color mapping table, and the color mapping table is saved as a JSON or CSV file for subsequent vectorization tool (such as AutoCAD) calling. For example, in three-dimensional modeling, the RGB value of the pixel point (i,j) is inversely queried according to the physical coordinates (x,y) to realize accurate assignment of material mapping.
[0041] In one possible implementation, step S101 further includes the following sub-steps: S121 to S127.
[0042] Step S121, the travel image is converted into a gray image by the weighted average method.
[0043] Specifically, using the weighted average method, , the color image is converted into a single-channel gray image, which can reduce color interference and facilitate subsequent texture analysis.
[0044] Step S122, the texture entropy of the travel image is determined based on the gray image, and the travel image is hierarchically denoised by the texture entropy.
[0045] Specifically, the image texture entropy is calculated by the gray level co-occurrence matrix (GLCM) to distinguish Gaussian noise and salt and pepper noise; for Gaussian noise, a 5x5 Gaussian kernel is used; for salt and pepper noise: median filtering is used.
[0046] In the embodiment, the entropy value of Gaussian noise is low, the pixel gray scale changes gently, and the entropy value of salt and pepper noise is high, containing discrete black and white noise points. According to the characteristics of Gaussian noise and salt and pepper noise, adaptive filtering can be performed; for Gaussian noise, a 5*5 Gaussian kernel is used, and the sigma value is adaptively adjusted according to the noise intensity (the more serious the noise, the larger the sigma, such as sigma = 1.5-2.5), to suppress the noise in the smooth area; for salt and pepper noise, median filtering is used, and the kernel size (3*3 or 5*5) is dynamically selected according to the noise density (the higher the density, the larger the kernel size), to protect the edge details.
[0047] In step S123, image enhancement processing is performed on the travel image after noise reduction. The image enhancement processing includes Retinex processing and CLAHE enhancement processing.
[0048] Specifically, a multi-scale Retine algorithm (MSRCR) is used to separate the illumination component and the reflection component of the image, to restore color constancy; dark area detection is performed on the image after Retinex processing, and CLAHE (Contrast Limited Adaptive Histogram Equalization) is applied to the detected dark area, while the original contrast of other areas is preserved; the dark area enhanced by CLAHE is fused with the global image processed by Retinex, and bilinear interpolation or Poisson fusion is used to eliminate boundary artifacts.
[0049] In the embodiment, multi-stage enhancement is performed on the image after noise reduction, which can avoid loss of image details. Through MSRCR (Multi-Scale Retinal Model), the illumination component (uneven illumination) and the reflection component (true texture) of the image are separated, color constancy is restored (such as eliminating the influence of glass reflection and shadow on color), and dark area positioning is performed on the image processed by the MSRCR model through threshold segmentation or gradient analysis. CLAHE (Contrast Limited Adaptive Histogram Equalization) is applied only to this area to avoid overexposure caused by global enhancement, preserve bright details, and finally use bilinear interpolation or Poisson fusion algorithm to seamlessly splice the enhanced dark area and the global image to eliminate edge brightness mutation.
[0050] In step S124, the travel image after enhancement is evaluated based on the peak signal-to-noise ratio and the structural similarity of the travel image after image enhancement.
[0051] Specifically, the processed image is evaluated based on the PSNR (Peak Signal-to-Noise Ratio) and SSIM (Structural Similarity) of the travel image.
[0052] In step S125, if the evaluation operation confirms the first evaluation result, the original travel image is returned and the noise area in the travel image is marked.
[0053] Specifically, the first evaluation result is PSNR < 22 dB and SSIM < 0.6, and if the first evaluation result is confirmed, the original travel image is returned, and the noise area is manually marked. The image in the first evaluation result has serious noise, blur or compression distortion, and it is difficult to distinguish the real details and noise by direct denoising and enhancement, which may misdelete the cultural relic texture (such as the historical marks of bronze rust) or over-repair the architectural lines (such as the wear details of ancient building carvings), resulting in irreversible damage, therefore, the original travel image needs to be returned, and the noise area (such as the dirt on the surface of cultural relics and the blurred area of building images) is manually marked, and then a repair strategy is selected according to the noise type and the marking result.
[0054] In step S126, if the evaluation operation confirms the second evaluation result, the filter kernel size in the travel image is adjusted and the iteration number is increased. The image in the second evaluation result has a certain degree of noise, blur or insufficient contrast, but the overall structure and details have not been seriously damaged, so adjusting the filter kernel size or increasing the iteration number (such as increasing the Gaussian kernel σ value) can optimize the local quality while preserving the existing details.
[0055] Specifically, the second evaluation result is 22 dB ≤ PSNR < 32 dB and 0.6 ≤ SSIM < 0.8, and if the second evaluation result is confirmed, the filter kernel size is adjusted and the iteration number is increased.
[0056] In step S127, if the evaluation operation confirms the third evaluation result, the travel image after image enhancement is output as a preprocessed image.
[0057] Specifically, the third evaluation result is PSNR ≥ 32 dB and SSIM ≥ 0.8, and if the third evaluation result is confirmed, the travel image after image enhancement is output as a preprocessed image. The image in the third evaluation result has small pixel distortion and complete structure details, which belongs to a high-quality image. At this time, the preprocessed image can be directly output and enter the image segmentation operation.
[0058] In step S102, the preprocessed image is segmented to obtain a segmented image.
[0059] Specifically, based on the image segmentation model introducing the attention mechanism and the conditional random field structure, the image is interactively semantically labeled under the guidance of user labeling, and the initial segmentation of multi-class target regions is completed; then the geometric and boundary feature parameters of each connected region are extracted, and the structure repair and boundary smoothing are realized by adaptively configuring the erosion or dilation kernel size according to the features; high-uncertainty areas are identified by combining entropy evaluation or edge overlap indicators, and iterative optimization is performed through pseudo-label generation and consistency regularization mechanism, so as to obtain a high-quality segmented image with complete structure, continuous semantics and clear boundary.
[0060] In a possible implementation, step S102 further includes the following sub-steps: S211 to S214.
[0061] Step S211, an image segmentation model is constructed based on a neural network structure with an introduced attention mechanism and a conditional random field, and the preprocessed image is interactively labeled through the image segmentation model.
[0062] Specifically, a U-Net++ neural network is adopted, an attention mechanism (such as SENet channel attention) is added in the encoder, and a conditional random field (CRF) is introduced in the decoder; the key areas (such as cultural relic outlines and architectural lines) of the travel and tourism images are focused on, and the edge continuity of the segmentation result is optimized; based on the sample complexity, different weights w are assigned to each type of image in the training sample; the weight of the cultural relic image w1=0.5, the weight of the architectural image w2=0.3, and the weight of the landscape image w3=0.2; the total loss function is the cross-entropy loss + Dice coefficient loss, which improves the segmentation accuracy of detailed images.
[0063] Among them, the encoder is composed of 4 down-sampling blocks, each block contains 2 3x3 convolution (padding value padding=1), BN layer, ReLU activation, followed by 2x2 max pooling (stride=2), and SENet channel attention (compression ratio r=16) is inserted after the last convolution layer of each encoder block, the feature map is weighted by channel, and the channel response of the cultural relic outline and architectural line is enhanced. The decoder is composed of 4 up-sampling blocks, which are fused with the corresponding encoder jump connection features through deconvolution (2x2, stride=2) or bilinear interpolation up-sampling, and after the output of the last decoder block, a fully connected CRF (DenseCRF) is connected, which is realized by using the PyTorch-CRF library and parameter related configuration. Gaussian kernel standard deviation: sigma_space=5 (control spatial proximity); bilateral kernel standard deviation: sigma_color=30, sigma_space=10 (balance color and spatial similarity, protect edges); iteration number: 5 times for inference and 2 times for training (reduce computation).
[0064] In the sample weight allocation stage, the complexity is valued according to the user's requirements. The cultural relic image c1=5 (the most complex in detail and the highest in cultural value), the architectural image c2=3 (the geometric structure is complex), and the landscape image c3=2 (the outline level is relatively simple), the weight formula is: , that is, the cultural relic image , the cultural relic image , and the cultural relic image ; the weight of each sample is directly assigned according to its type (such as the weight is 0.5 as long as the label contains the category of cultural relic image).
[0065] Among them, the total loss function Two parts: weighted cross-entropy loss and weighted Dice loss weighted cross-entropy loss Class imbalance problem is handled by assigning different weights to different samples, and difficult samples can be focused on; weighted Dice loss The similarity between the predicted result and the true label is calculated to optimize the boundary continuity and small region segmentation accuracy. The combination of the two loss functions can effectively improve the performance of the image segmentation task, and the formula is as follows:
[0066] ;
[0067] ;
[0068] where N is the total number of samples, is the weight of the nth sample, which is used to handle class imbalance, is the true label (one-hot encoding) of the nth sample in the cth class at position (i,j), is the prediction probability of the nth sample in the cth class at position (i,j);
[0069] ; where, is the weight of the nth sample, is the true label of the nth sample in the cth class at position (i,j), is the prediction probability of the nth sample in the cth class at position (i,j).
[0070] The user labels the key region, and the image segmentation model generates the initial segmentation result according to the label; the marked region is diffused using the graph cut algorithm, pseudo-labels are generated and added to the training samples; combine the supervised loss and consistency regularization loss to optimize the model parameters; calculate the entropy value of the unmarked region, select the region with the highest entropy value for the user to label, and form a closed loop iteration.
[0071] In key region annotation, for cultural relic images, only the main body contour (such as the outer edge of bronze ware or the rim of ceramic ware) is labeled without refining the inscription or decoration, thereby reducing the labor cost; for building images, the main structure line (such as the intersection of beam and column or the outline of dougong) is labeled to form a "skeleton" type of labeling; during labeling, the polygon tool or brush can be used to quickly sketch and generate a binary mask (labeled region = 1, unlabeled = 0, background = 2). In initial segmentation prediction, the image with labeled mask is input, and a pre-trained U-Net++ neural network (including SENet and CRF) is used to generate an initial segmentation probability map (covering the whole image); for the unlabeled region, the model predicts the category (such as cultural relics, buildings, landscapes, and backgrounds) according to the context information (such as color and texture similarity).
[0072] A graph cut model is constructed to define the pixels of an image (including labeled region S and unlabeled region U), the pixels of the labeled region S are forced to belong to the labeled category, and the weight of the pixels of the unlabeled region U is determined by the initial model prediction probability (such as P(cultural relic / background). The color similarity (RGB Euclidean distance) and position distance of adjacent pixels are constructed into bilateral weights, which can balance the spatial and color similarity; the specific formula is as follows:
[0073] ;
[0074] wherein, , , represents the bilateral weight between pixels and ; and represent the position coordinates of pixels and , respectively; and represent the RGB color values of pixels and , respectively; is the spatial difference, which can control the influence degree of position distance on the weight; is the color standard deviation, which can control the influence degree of color similarity on the weight.
[0075] A pseudo label is generated to minimize the energy function, and the formula is as follows: wherein, represents the energy function, which represents the total energy or cost of the entire model; f represents the pseudo label, which is the label predicted by the model; S represents the set of all samples in the data set; represents the i-th sample in the data set; For data items, representing individual samples The data cost of a sample is related to the difference between the true label and the predicted label; N represents the neighborhood set, representing the adjacency relationship between samples; Indicates that there is an adjacency relationship between samples And . Indicates a smoothing term, indicating the smoothing cost between adjacent samples And , to ensure that the predicted labels of adjacent samples are as consistent as possible. In addition, the pixels in the unlabeled region U are diffused by graph cut, inheriting the class of the labeled region (such as the pixels inside the cultural relic contour diffusing to “cultural relic”, and the pixels near the building structure diffusing to “building”), generating a full-image pseudo-label As a weakly supervised signal.
[0076] Construct a hybrid training data, through the key area of artificial labeling (high confidence, weight set to 1.0), the pseudo-label area generated by graph cut (need to filter the low confidence part, such as keeping the pixels with model prediction probability > 0.7, weight set to 0.5), in the loss function, total loss = supervision loss + 0.3 consistency regularization loss. Update the model, generate 50 pseudo-label images every time, merge with the original manually labeled data, fine-tune the model (freeze the first two layers of the encoder, only update the decoder and CRF parameters), use AdamW optimizer (learning rate set to 1e-5), training period set to 5, avoid overfitting to pseudo-label noise.
[0077] Through entropy-guided active learning, for each pixel in the unlabeled region U, calculate the entropy value H(p) of the class probability distribution, the high-entropy region (such as H(p)> 0.8), represents that the model prediction uncertainty is large (such as the fuzzy area of cultural relic inscription, the structure in the shadow of building); the low-entropy region (such as (H(p)< 0.3), indicates that the model prediction is accurate, and the pseudo-label can be directly used. When selecting regions, arrange in descending order of entropy value, extract the top 20% high-entropy regions, generate rectangular boxes or polygon masks, and prompt the user to label (“Please confirm whether the fuzzy area is cultural relic inscription”), for continuous high-entropy regions (such as large fuzzy areas on the surface of cultural relics), the user only needs to label the boundary or key points, and the inside is automatically filled by graph cut.
[0078] For connected region feature extraction, the following features are extracted from the segmented binary mask using OpenCV: Area: number of pixels A (distinguish small areas such as inscriptions spots (A < 100), large areas such as building walls A > 1000). Perimeter: number of contour pixels P (evaluate edge complexity). Eccentricity: eccentricity of ellipse fitting (judge whether the region shape is regular. Select the appropriate kernel size, small area (A < 200): use 3x3 kernel erosion or dilation (protect details, avoid excessive smoothing). Large area (A ≥ 200): use 5x5 kernel or Gaussian kernel (smooth large area edge, such as noise spots on building walls), where erosion can remove small noise blocks (such as isolated pixels outside the artifact contour), and dilation can connect adjacent regions (such as broken lines of building structures).
[0079] For effect evaluation and iteration, the entropy value reduction rate of the processed region (target: high entropy region entropy value reduction ≥ 30%), ensure the completeness of the edge detected contour (Canny edge detection, calculate the overlap rate of the predicted contour and the manually labeled contour), the regions with high entropy or discontinuous contours after processing are added to the active learning queue again, and the labeling-training-processing process is repeated.
[0080] In step S212, based on the image segmentation model, the marked preprocessed image is segmented to divide the marked preprocessed image into multiple connected regions.
[0081] Specifically, based on the image segmentation model, the marked preprocessed image is segmented to divide the marked preprocessed image into multiple connected regions. Specifically, first, a U-Net++ neural network with SENet channel attention mechanism is used to perform full-image prediction on the preprocessed image with key region annotation, to generate a semantic probability map; then, a fully connected conditional random field is introduced based on the probability map to optimize edge continuity and improve the structural consistency of the detail contour; a binary mask map is constructed according to the segmentation result, and different semantic class regions in the mask map are segmented by a connected component labeling algorithm, and all connected regions are extracted; and based on the spatial adjacency relationship of the pixel points, each connected region is numbered and contour traced to form an independent structural unit for subsequent structural feature analysis, kernel size regulation and uncertainty screening processing. This process combines deep semantic modeling and spatial topology recognition to not only ensure the complete expression of semantic boundaries, but also lay a precise partition foundation for subsequent adaptive processing based on region granularity.
[0082] In step S213, based on the feature parameters of each connected region, a corresponding kernel erosion or dilation operation is performed on the connected region, and a plurality of high-uncertainty regions in the connected regions are obtained through a preset evaluation operation. The feature parameters include area parameters, perimeter parameters, aspect ratio parameters and edge complexity parameters.
[0083] Specifically, first, geometric feature extraction is performed on each connected region in the image segmentation result, including counting the number of pixels in the region as an area parameter, counting the pixels along the contour path to obtain a perimeter parameter, calculating the aspect ratio of the minimum circumscribed rectangle to obtain an aspect ratio parameter, and constructing an edge complexity parameter based on the gradient change amplitude of the contour; according to these parameters, the shape scale and structural characteristics of the region are determined, so that the appropriate morphological processing kernel size and type are selected, wherein a smaller size (such as 3x3) erosion kernel is selected for regions with an area less than a preset threshold or high edge complexity to remove isolated noise points, and a larger size (such as 5x5) dilation kernel is selected for regions with a larger area or insufficient contour continuity to connect the broken boundary structure; subsequently, based on the change in the region contour structure and the information entropy value before and after processing, combined with the edge detection accuracy and region consistency indicators, a multi-dimensional evaluation function is constructed to identify regions with unstable processing effect, fuzzy boundary, structural damage or significant semantic splitting tendency as high-uncertainty regions, and these regions are determined as the priority objects for subsequent optimization iteration, realizing the joint improvement of segmentation accuracy and structural expression integrity.
[0084] Step S214, optimization iteration is performed on the high-uncertainty regions to complete the image segmentation operation and output the segmented image.
[0085] Specifically, for all high-uncertainty regions, first, based on the initial segmentation probability map generated by the model and the user interaction labeling result, a graph cut energy minimization model is constructed, a bilateral weight is defined using the spatial position and color similarity between pixels, pseudo-label diffusion is performed on the unlabeled regions, and an initial pseudo-label map covering the entire image is generated; subsequently, based on the confidence of the pixel prediction probability in the pseudo-label, low-confidence regions are filtered, only the part with a probability higher than a set threshold (such as 0.7) is retained as a training sample, a mixed training data set is constructed combining the original manual labeling region, a supervision loss and a consistency regularization loss are introduced in the loss function, and a lower loss weight (such as 0.5) is given to the pseudo-label to suppress the propagation of pseudo-label noise; during the training process, every time a certain number of pseudo-label images (such as 50) are generated, a model fine-tuning is triggered, only the decoder and conditional random field parameters are updated, and the encoder front layer structure is frozen to control the model generalization ability and prevent overfitting; at the same time, the prediction entropy value of the pixels in the unlabeled region is calculated, the high-uncertainty regions are extracted in descending order of entropy value, and the user is preferentially guided to perform local labeling on the boundary or key points of the region, forming an active learning closed loop of "high-entropy priority and minimum interaction"; for continuous high-entropy regions, context texture, color and boundary information are combined to automatically generate complete labels through graph cut propagation and semantic guidance; through multiple rounds of interactive optimization and model adaptive update, the segmentation boundaries of all high-uncertainty regions tend to converge, and finally a segmented image with clear semantics, complete boundaries and consistent region structure is output, meeting the accuracy requirements of subsequent edge extraction and vector fitting.
[0086] Step S103, edge extraction operation and fitting operation are performed on the segmented image to obtain image edge features.
[0087] Specifically, by constructing an edge extraction mechanism based on gradient analysis and domain tracking, first, each sub-element connected region in the segmented image is identified, the gradient amplitude graph is extracted by using pixel eight-neighbor difference calculation, and the fine edge profile is extracted by non-maximum suppression and maximum entropy adaptive threshold method; then the connected domain labeling algorithm is applied to the edge profile for structure recognition and directional segmentation to extract the edge pixel coordinate sequence; on this basis, the vector data compression and curvature analysis mechanism is introduced, the cubic Bezier curve is used for curve fitting processing of the edge coordinate sequence, the contour curvature continuity and edge smoothness are ensured by control point adjustment, and a high-fidelity image edge vector expression is constructed; this processing not only improves the geometric expression accuracy and compression efficiency of the structure profile, but also establishes a high-consistency shape basis for subsequent color assignment, semantic coding and vector graph output.
[0088] In one possible implementation, step S103 further includes the following sub-steps: S311 to S312.
[0089] Step S311, edge extraction operation is performed on each sub-element in the segmented image to obtain sub-element information.
[0090] Specifically, the sub-element information includes sub-element profile; the eight-neighbor difference calculation is performed on each sub-element pixel to obtain the gradient amplitude of the sub-element, the non-maximum suppression processing is performed on the gradient amplitude of the sub-element, and the maximum entropy adaptive algorithm is used for edge detection to obtain the sub-element profile; the sub-element information further includes sub-element edge pixel point coordinates; the connected region labeling algorithm is used to label the sub-element profile to obtain eight connected regions, and the vector data compression algorithm is used to extract the sub-element edge pixel point coordinates for each labeled region.
[0091] Among them, for the extraction of the profile, eight-neighbor difference calculation gradient amplitude is performed on each sub-element (such as cultural relics fragments, building components), the edge is refined through non-maximum suppression, and the maximum entropy adaptive algorithm (automatic determination of edge detection threshold) is used to extract the accurate profile. For the extraction of the coordinates, the profile can be divided into eight connected regions (corresponding to eight-neighbor directions) by using the connected domain labeling algorithm, and the vector data compression algorithm (such as Douglas-Peucker algorithm) is used to extract the key edge pixel point coordinates to reduce data redundancy.
[0092] Step S312, cubic Bezier curve is used for fitting operation on the sub-element information to obtain image edge features.
[0093] Specifically, curve fitting is performed based on the sub-element information, and a cubic Bezier curve is used to fit the extracted sub-element edge pixel points.
[0094] In this embodiment, the cubic Bezier curve fitting can be used for the edge pixel points, the curvature of the curve is adjusted by controlling the vertex, the smooth representation of the complex contour (such as the pattern of cultural relics and the arc of ancient buildings) is ensured, and the polyline distortion is avoided.
[0095] In step S104, color attribute assignment operation is performed based on the image edge features to obtain a color calibrated image.
[0096] Specifically, for each connected region defined around the image edge, a color analysis model based on the mapping of pixel coordinates and color values is constructed. First, the RGB value distribution features are extracted by pixel statistics in the region, the average color of the region is calculated to determine the fill color, and a color clustering compression algorithm such as octree structure or K-means clustering is introduced to control the number of color types to improve the compactness of the vector graphics file. Further, the brightness of the fill color is adjusted according to the boundary structure to generate a dark version for contour outlining, and the visual separation degree of the structure boundary is enhanced. Finally, a color fine-tuning mechanism is provided in combination with user interaction operation to allow manual intervention and correction of the fill color and the outlining color to adapt to the requirements of personalized art style or real color tone restoration of cultural relics, so as to generate a color calibrated image with realistic, editable and semantically consistent color, thereby laying a visual foundation for vector graphics semantic coding and standard output.
[0097] In one possible implementation, step S104 further includes the following sub-steps: S411 to S414.
[0098] In step S411, based on the coordinates of the image edge and the mapping relationship between the coordinates and the color values, the pixel values of each connected region in the sub-element are extracted, and the average color is calculated as the fill color.
[0099] Specifically, the color attribute includes the fill color and the outlining color. Based on the coordinates of the image edge and the mapping relationship between the coordinates and the color values, the RGB values of all pixels in each connected region in the sub-element are extracted, and the average color is calculated as the fill color, which specifically includes the following contents:
[0100] ;
[0101] Wherein, N is the number of pixels in the region; octree or K-means clustering is used to compress the color table to ensure that the number of vector graphics colors is controllable.
[0102] In step S412, the image is filled with color based on the fill color, and it is judged whether the color of the image after color filling meets the preset requirement.
[0103] Specifically, a dark version of the region color (e.g., 30% lower brightness) is used for the edge outline.
[0104] In this embodiment, for the fill color, the RGB average value of all pixels in the connected region is calculated, and the color table is compressed (e.g., 24-bit true color is compressed to 256 colors) by octree or K-means clustering, to ensure the lightweight of the vector graph file. For the outline color, the fill color brightness is reduced by 30% as the outline color, which can change RGB (200, 150, 100) to RGB (140, 105, 70), to enhance the edge contrast.
[0105] Step S413: If the image color does not meet the preset requirement, the color is increased or decreased through a preset interactive mode.
[0106] Specifically, the user judges whether the image color meets the requirement, and if not, the color is increased or decreased through mouse interaction (e.g., manually adjusting the green tone of the cultural relic rust and the saturation of the ancient building color drawing), to realize personalized color calibration.
[0107] Step S414: If the image color meets the preset requirement, the image after color filling is taken as the color calibration image.
[0108] Specifically, the user judges whether the image color meets the requirement, and if yes, the image after color filling is taken as the color calibration image.
[0109] S105: Perform semantic encoding operation based on the color calibration image, to obtain the vector graph corresponding to the cultural and travel image.
[0110] Specifically, first, the edge curve of each connected region in the color calibration image is parameterized and expressed in the form of a Bezier curve, and the corresponding color attribute, structural feature, and spatial position information are uniformly encoded into an XML data structure; then a semantic label system is introduced, and according to the image content type and structure, a semantic label with cultural attributes is added to each region, such as cultural relic category, building component type, or topographic element name, to enhance the understandability and retrieval value of the graph; finally, the multi-dimensional structure containing edge geometry, color attribute, and semantic information is output as an SVG standard format vector graph, to realize high compressibility, high resolution scalability, and content-oriented structured representation, and to support subsequent efficient application in cultural heritage digital modeling, graph re-creation, and semantic search scenarios.
[0111] In one possible implementation, step S105 further includes the following sub-steps: S511 to S512.
[0112] S511, encode the color attribute corresponding to the color calibration image into XML format, and add corresponding semantic tags in the XML format.
[0113] Specifically, the Bezier curve is parameterized, the color attribute is encoded into XML format, and semantic tags are added in XML. First, each connected region after edge fitting processing in the color calibration image is parsed, and the corresponding cubic Bezier curve control point parameters are extracted, including the coordinates of the starting point, the ending point, and two control points. The curve parameters are standardized and expressed as path definition nodes in XML format. Then, the color attribute of the region is encoded, including the RGB values of the fill color and the stroke color, which are inserted into the style definition section of XML in hexadecimal format to ensure visual consistency during graphic rendering. After the structure encoding is completed, based on the classification results or user-specified tags in the previous image semantic segmentation stage, a semantic labeling layer is constructed, and semantic tag fields are added to each path node in the XML document, such as <Artifact Type> Bronze Ware < / Artifact Type>, <Building Component> Toukong < / Building Component>, thereby realizing the trinity expression of structure, vision, and semantics of graphic data. The final generated XML not only has the renderability and editability of SVG standard, but also has a semantic structure for content understanding and retrieval, supporting deep application and intelligent linkage in graphic editing software, travel database, or cultural asset management system.
[0114] S512, output the color calibration image with added semantic tags as an SVG vector graph file to obtain a vector graph corresponding to the travel image.
[0115] Specifically, after embedding the Bezier curve control points, color attributes, and semantic tags in the XML structure, all path data is converted into SVG format according to the SVG specification, and the SVG vector graph is generated. The SVG vector graph is a vector graph that can be scaled without loss of quality, and can be edited and modified in the SVG editing software. The SVG vector graph can be used for further processing and application in the travel database or cultural asset management system. <path>The node form is written in the SVG document body, and the coordinate system, view window and figure unit are uniformly set to ensure that the image geometry and color remain consistent in different rendering environments; the fill color attribute is marked by the fill parameter, the stroke color is defined by the stroke parameter, and the stroke-width is set to control the edge thickness to form a graphic style that meets the requirements of visual perception; semantic tags are implemented by attaching a custom namespace (such as xmlns:semantic) under each path element or embedding the tag field in the form of a comment to achieve semantic parsability and cross-system identifiability; in the output process, the SVG file is saved in UTF-8 encoding to ensure compatibility and internationalization support; the final generated SVG vector graph file has accurate structure boundary expression, color restoration effect and complete semantic information, and can be used for post-editing in graphic design software or directly embedded in travel application systems for cultural relic display, digital twin modeling or semantic retrieval interaction scenarios, realizing the deep integration of graphic expression and cultural semantic transmission.
[0116] In this embodiment, the Bezier curve parameters (control point coordinates) and color attributes (fill or stroke color) are encoded into XML format, and semantic tags (such as <Cultural Relic Type> Bronze Ware < / Cultural Relic Type>, <Building Component> Toukong < / Building Component>) are added to enhance the semantic information and editability of the vector graph. The output image is converted into an SVG vector graph file, supporting infinite zooming without distortion, and facilitating subsequent reuse in CAD and illustration software.
[0117] By using the above method, the application considers both automation efficiency and manual controllability through collection, preprocessing, interactive segmentation, edge fitting, color assignment and semantic encoding, solves the problems of complex details, variable lighting and irregular geometric structure of travel images, and generates a vector graph with high precision, high semanticity and high editability, providing key technical support for the digital inheritance and innovative application of cultural heritage.
[0118] Please refer to Figure 2 which shows a module schematic diagram of an interactive travel image vectorization device provided by an embodiment of the application. The device includes an acquisition module 21 and a processing module 22, wherein
[0119] The acquisition module 21 is configured to acquire a travel image and pre-process the travel image to obtain a pre-processed image.
[0120] The processing module 22 is configured to segment the pre-processed image to obtain a segmented image, perform edge extraction and fitting operations on the segmented image to obtain image edge features, perform color attribute assignment operations based on the image edge features to obtain a color calibration image, and perform semantic encoding operations based on the color calibration image to obtain a vector graph corresponding to the travel image.
[0121] In a possible implementation, the acquisition module 21 is configured to acquire the cultural and travel image, specifically including: acquiring the cultural and travel image through a preset acquisition device, the preset acquisition device including a digital camera and a scanner; acquiring an image type of the cultural and travel image, and setting a differential acquisition parameter based on the image type, the image type including a cultural relic image type, an architectural image type, and a landscape image type; and constructing a coordinate mapping relationship corresponding to the cultural and travel image based on the differential acquisition parameter through a geometric correction operation and a diffraction mapping operation.
[0122] In a possible implementation, the acquisition module 21 is configured to pre-process the cultural and travel image to obtain a pre-processed image, specifically including: converting the cultural and travel image into a gray image through a weighted average method; determining a texture entropy of the cultural and travel image based on the gray image, and performing hierarchical noise reduction on the cultural and travel image through the texture entropy; performing image enhancement processing on the noise-reduced cultural and travel image, the image enhancement processing including Retinex processing and CLAHE enhancement processing; performing an evaluation operation on the enhanced cultural and travel image based on a peak signal-to-noise ratio and a structural similarity of the image-enhanced cultural and travel image; if the evaluation operation confirms a first evaluation result, returning the original cultural and travel image and marking a noise area in the cultural and travel image; if the evaluation operation confirms a second evaluation result, adjusting a filter kernel size in the cultural and travel image and enhancing an iteration number; and if the evaluation operation confirms a third evaluation result, outputting the image-enhanced cultural and travel image as the pre-processed image.
[0123] In a possible implementation, the processing module 22 is configured to segment the pre-processed image to obtain a segmented image, specifically including: constructing an image segmentation model based on a neural network structure with an introduced attention mechanism and a conditional random field, and performing interactive labeling on the pre-processed image through the image segmentation model; performing a segmentation operation on the labeled pre-processed image based on the image segmentation model, to segment the labeled pre-processed image into a plurality of connected regions; performing a corresponding kernel erosion or dilation operation on the connected regions based on feature parameters of each connected region, and obtaining a high-uncertainty region in the plurality of connected regions through a preset evaluation operation, the feature parameters including an area parameter, a perimeter parameter, an aspect ratio parameter, and an edge complexity parameter; performing optimization iteration on the high-uncertainty region to complete the image segmentation operation, and outputting the segmented image.
[0124] In a possible implementation, the processing module 22 is configured to perform an edge extraction operation and a fitting operation on the segmented image to obtain an image edge feature, specifically including: performing an edge extraction operation on each sub-element in the segmented image to obtain sub-element information; and performing a fitting operation on the sub-element information using a cubic Bezier curve to obtain the image edge feature.
[0125] In a possible implementation, the processing module 22 is configured to perform a color attribute allocation operation based on image edge features to obtain a color calibrated image, specifically including: performing pixel value extraction on each connected region in the sub-element based on the coordinates of the image edge and the mapping relationship between the coordinates and the color values, and calculating an average color as a fill color; performing color filling on the travel image based on the fill color, and determining whether the image color after the color filling meets a preset requirement; if the image color does not meet the preset requirement, increasing or decreasing the color through a preset interaction mode; and if the image color meets the preset requirement, taking the image after the color filling as the color calibrated image.
[0126] In a possible implementation, the processing module 22 is configured to perform a semantic encoding operation based on the color calibrated image to obtain a vector graph corresponding to the travel image, specifically including: encoding the color attribute corresponding to the color calibrated image into an XML format, and adding a corresponding semantic label in the XML format; and outputting the color calibrated image after the semantic label is added into an SVG vector graph file to obtain the vector graph corresponding to the travel image.
[0127] It should be noted that, when the apparatuses provided in the above embodiments implement their functions, only the division of the above functional modules is exemplified, and in actual applications, the above functions can be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the above described functions. In addition, the apparatuses and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process is detailed in the method embodiments, which will not be repeated here.
[0128] The present application also provides an electronic device. Referring to Figure 3 , Figure 3 is a structural schematic diagram of an electronic device provided by an embodiment of the present application. The electronic device can include: at least one processor 301, at least one communication bus 302, a user interface 303, at least one network interface 304, and a memory 305.
[0129] The communication bus 302 is configured to realize the connection and communication between the components.
[0130] The user interface 303 can include a display screen (Display) and a camera (Camera), and the optional user interface 303 can further include a standard wired interface and a wireless interface.
[0131] The network interface 304 can optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).
[0132] The processor 301 can include one or more processing cores. The processor 301 connects various parts within the server through various interfaces and lines, performs various functions of the server and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 305, and calling data stored in the memory 305. Alternatively, the processor 301 can be implemented in at least one of a hardware form of a digital signal processing (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor 301 can integrate a combination of one or more of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes operating systems, user interfaces, and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; and the modem is used for processing wireless communication. It can be understood that the above-mentioned modem can also not be integrated into the processor 301, but can be realized by a separate chip.
[0133] The memory 305 can include a random access memory (RAM) and a read-only memory (ROM). Alternatively, the memory 305 includes a non-transitory computer-readable storage medium. The memory 305 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 305 can include a program storage area and a data storage area, wherein the program storage area can store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area can store data involved in the above-mentioned various method embodiments, etc. The memory 305 can also be at least one storage device located away from the aforementioned processor 301. Referring to Figure 3 The memory 305 as a computer storage medium can include an operating system, a network communication module, a user interface module, and an interactive travel image vectorization application program.
[0134] In Figure 3 In the electronic device shown, the user interface 303 is mainly used to provide an interface for the user to input, and obtain data input by the user; and the processor 301 can be used to call the interactive travel image vectorization application program stored in the memory 305, and when executed by one or more processors 301, the electronic device performs the method described in one or more of the above embodiments. It should be noted that, for the foregoing method embodiments, in order to simply describe, they are all described as a series of action combinations, but those skilled in the art should know that the present application is not limited to the action sequence described, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0135] The present application also provides a computer-readable storage medium, which stores instructions. When executed by one or more processors, the electronic device performs the method described in one or more of the above embodiments.
[0136] In the above embodiments, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.
[0137] In the several embodiments provided by the present application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only schematic. The division of the units is only a logical function division. There can be another division manner for actual implementation, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections between different units, can be indirect couplings or communication connections through some interfaces, devices or units, and can be electrical or other forms.
[0138] The units described as separate components can or can not be physically separate, and the components displayed as units can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.
[0139] In addition, each functional unit in each embodiment of the present application can be integrated into one processing unit, or each unit can exist physically, or two or more units can be integrated into one unit. The above integrated unit can be realized in the form of hardware, or in the form of software functional unit.
[0140] The integrated unit, if implemented in the form of a software function unit and sold or used as an independent product, can be stored in a computer readable memory. Based on such understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a memory and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the embodiments of the present application. The aforementioned memory includes: a U disk, a mobile hard disk, a magnetic disk or an optical disk, and various media that can store program codes.
[0141] The above is only exemplary embodiments of the present application, and cannot limit the scope of the present application. That is, any equivalent changes and modifications made in accordance with the teachings of the present application are still within the scope of the present application.
[0142] The present application is intended to cover any variations, uses or adaptive changes of the present application, which follow the general principles of the present application and include common knowledge or conventional technical means in the technical field not disclosed in the present application.< / path>
Claims
1. An interactive method for vectorizing cultural and tourism images, characterized in that, The method includes: Acquiring cultural and tourism images specifically includes: acquiring the cultural and tourism images through preset acquisition devices, including digital cameras and scanners; acquiring the image type of the cultural and tourism images, and setting differentiated acquisition parameters based on the image type, including cultural relic image type, architectural image type, and landscape image type; and constructing the coordinate mapping relationship corresponding to the cultural and tourism images through geometric correction operations and diffraction mapping operations based on the differentiated acquisition parameters. The cultural and tourism images are preprocessed to obtain preprocessed images, specifically including: The cultural and tourism images are converted into grayscale images using a weighted average method. The texture entropy of the cultural and tourism image is determined based on the grayscale image, and the cultural and tourism image is subjected to graded noise reduction through the texture entropy. The specific steps include: calculating the image texture entropy through the grayscale co-occurrence matrix to distinguish between Gaussian noise and salt-and-pepper noise, wherein a 5×5 Gaussian kernel is used for the Gaussian noise, and median filtering is used for the salt-and-pepper noise. The denoised cultural and tourism images are then subjected to image enhancement processing, which includes Retinex processing and CLAHE enhancement processing. Specific steps include: using a multi-scale Retinex algorithm to separate the illuminance and reflectance components of the cultural and tourism images to restore color constancy; performing dark region detection on the Retinex-processed images and applying the CLAHE algorithm to the detected dark regions to preserve the original contrast of other regions; fusing the CLAHE-enhanced dark regions with the Retinex-processed global image, and using bilinear interpolation or Poisson fusion to eliminate boundary artifacts. Based on the peak signal-to-noise ratio and structural similarity of the enhanced cultural and tourism images, an evaluation operation is performed on the enhanced cultural and tourism images; If the evaluation operation confirms the first evaluation result, the original cultural and tourism image is returned and the noise region in the cultural and tourism image is marked, wherein the first evaluation result is PSNR<22dB and SSIM<0.6; If the evaluation operation confirms the second evaluation result, the filter kernel size in the cultural and tourism image is adjusted and the number of iterations is increased, wherein the second evaluation result is 22dB≤PSNR<32dB and 0.6≤SSIM<0.8; If the evaluation operation confirms the third evaluation result, the enhanced cultural tourism image is output as the preprocessed image, wherein the third evaluation result is PSNR≥32dB and SSIM≥0.8; The preprocessed image is segmented to obtain a segmented image; The segmented image is subjected to edge extraction and fitting operations to obtain image edge features, specifically including: The edge extraction operation is performed on each sub-element in the segmented image to obtain sub-element information, wherein the sub-element includes cultural relic fragments and architectural components, and the sub-element information includes the sub-element contour and the coordinates of the sub-element edge pixels; the specific steps include: performing difference calculation on the 8-adjacent pixels of each sub-element to obtain the gradient magnitude of the sub-element; performing non-maximum suppression processing on the gradient magnitude of the sub-element; performing edge detection using the maximum entropy adaptive algorithm to obtain the sub-element contour; using a connected component labeling algorithm to label the sub-element contour with connected regions to obtain 8 connected regions; and using a vector data compression algorithm on each labeled connected region to extract the coordinates of the sub-element edge pixels; The image edge features are obtained by fitting the sub-element information with a cubic Bézier curve. A color attribute assignment operation is performed based on the image edge features to obtain a color-calibrated image, wherein the color attributes include fill color and stroke color, specifically including: Based on the coordinates of the image edges and the mapping relationship between coordinates and color values, pixel values are extracted for each connected region in the sub-element, and the average color is calculated as the fill color. The cultural and tourism image is filled with color based on the fill color, and it is determined whether the color of the image after color filling meets the preset requirements. The fill color brightness is reduced by 30% as the outline color of the cultural and tourism image. If the image colors do not meet the preset requirements, colors can be added or removed through a preset interactive method. If the image color meets the preset requirements, then the image after color filling will be used as the color calibration image; Based on the color calibration image, a semantic encoding operation is performed to obtain the vector image corresponding to the cultural and tourism image, specifically including: The color attributes corresponding to the color calibration image are encoded into XML format, and corresponding semantic tags are added to the XML format. Specific steps include: parsing each connected region in the color calibration image after edge fitting, extracting its corresponding cubic Bézier curve control point parameters, which include the start point, end point, and coordinate information of the two control points; standardizing the cubic Bézier curve control point parameters and organizing them into path definition nodes in the XML format; subsequently encoding the color attributes of the connected regions, including the RGB values of the fill color and the stroke color, and inserting them into the style definition section of the XML in hexadecimal format; after the structure encoding is completed, based on the classification results or user-specified tags, constructing a semantic tagging layer, and adding semantic tag fields to each path node in the XML document. The color-calibrated image with added semantic tags is output as an SVG vector file, thus obtaining the vector image corresponding to the cultural and tourism image.
2. The method according to claim 1, characterized in that, The step of segmenting the preprocessed image to obtain a segmented image specifically includes: An image segmentation model is constructed based on a neural network structure with an attention mechanism and a conditional random field, and the preprocessed image is interactively labeled using the image segmentation model. Based on the image segmentation model, the labeled preprocessed image is segmented into multiple connected regions. Based on the feature parameters of each connected region, the connected region is subjected to erosion or expansion operations corresponding to the kernel, and high uncertainty regions in multiple connected regions are obtained through a preset evaluation operation. The feature parameters include area parameters, perimeter parameters, aspect ratio parameters, and edge complexity parameters. The high-uncertainty region is optimized and iterated to complete the image segmentation operation, and the segmented image is output.
3. An interactive cultural tourism image vectorization device, characterized in that, The device includes an acquisition module and a processing module, wherein, The acquisition module is used to acquire cultural and tourism images, specifically including: acquiring the cultural and tourism images through preset acquisition devices, including digital cameras and scanners; acquiring the image type of the cultural and tourism images, and setting differentiated acquisition parameters based on the image type, including cultural relic image type, architectural image type, and landscape image type; constructing the coordinate mapping relationship corresponding to the cultural and tourism images through geometric correction operations and diffraction mapping operations based on the differentiated acquisition parameters; and preprocessing the cultural and tourism images to obtain preprocessed images, specifically including: using a weighted average method to process the cultural and tourism images... The image is converted to a grayscale image; based on the grayscale image, the texture entropy of the cultural and tourism image is determined, and the image is subjected to graded noise reduction using the texture entropy. Specific steps include: calculating the image texture entropy using the gray-level co-occurrence matrix to distinguish between Gaussian noise and salt-and-pepper noise, wherein a 5×5 Gaussian kernel is used for Gaussian noise, and median filtering is used for salt-and-pepper noise; image enhancement processing is performed on the denoised cultural and tourism image, including Retinex processing and CLAHE enhancement processing. Specific steps include: using a multi-scale Retinex algorithm to separate the illumination of the cultural and tourism image. The image is processed by the Retinex algorithm to restore color constancy by analyzing the reflection and reflection components. Dark areas are detected in the image, and the CLAHE algorithm is applied to these areas to preserve the original contrast of other areas. The CLAHE-enhanced dark areas are then fused with the global image processed by the Retinex algorithm, and bilinear interpolation or Poisson fusion is used to eliminate boundary artifacts. Based on the peak signal-to-noise ratio and structural similarity of the enhanced image, an evaluation operation is performed. If the evaluation operation confirms the first evaluation result, the original image is returned. The image is processed and the noisy regions in the cultural and tourism image are marked. The first evaluation result is PSNR < 22dB and SSIM < 0.
6. If the evaluation operation confirms a second evaluation result, the filter kernel size in the cultural and tourism image is adjusted and the number of iterations is increased. The second evaluation result is 22dB ≤ PSNR < 32dB and 0.6 ≤ SSIM < 0.
8. If the evaluation operation confirms a third evaluation result, the enhanced cultural and tourism image is output as the preprocessed image. The third evaluation result is PSNR ≥ 32dB and SSIM ≥ 0.
8. The processing module is used to segment the preprocessed image to obtain a segmented image; and to perform edge extraction and fitting operations on the segmented image to obtain image edge features. Specifically, this includes: performing the edge extraction operation on each sub-element in the segmented image to obtain sub-element information, wherein the sub-element includes cultural relic fragments and architectural components, and the sub-element information includes the sub-element contour and the coordinates of the sub-element edge pixels; the specific steps include: performing difference calculation on the 8-adjacency of each sub-element pixel to obtain the gradient magnitude of the sub-element; performing non-maximum suppression processing on the gradient magnitude of the sub-element; performing edge detection using a maximum entropy adaptive algorithm to obtain the sub-element contour; and using a connected component labeling algorithm to label the connected components of the sub-element contour. Eight connected regions were obtained. For each marked connected region, a vector data compression algorithm was used to extract the coordinates of the edge pixels of the sub-elements. A cubic Bézier curve was used to fit the sub-element information to obtain the image edge features. Based on the image edge features, a color attribute allocation operation was performed to obtain a color-calibrated image. The color attributes include fill color and stroke color. Specifically, based on the coordinates of the image edges and the mapping relationship between coordinates and color values, pixel values were extracted from each connected region in the sub-elements, and the average color was calculated as the fill color. The cultural tourism image was filled with the fill color, and it was determined whether the color of the filled image met the preset requirements, wherein the brightness of the fill color was reduced by 30%. The outline color of the cultural and tourism image is used as the outline color; if the image color does not meet the preset requirements, the color is added or removed through a preset interactive method; if the image color meets the preset requirements, the image after color filling is used as the color calibration image; based on the color calibration image, a semantic encoding operation is performed to obtain the vector image corresponding to the cultural and tourism image, specifically including: encoding the color attributes corresponding to the color calibration image into XML format, and adding corresponding semantic tags to the XML format, specifically including: parsing each connected region in the color calibration image after edge fitting processing, extracting its corresponding cubic Bézier curve control point parameters, the cubic Bézier curve control point parameters are used as the vector image. The control point parameters of the cubic Bézier curve include the starting point, the ending point, and the coordinate information of the two control points. The control point parameters of the cubic Bézier curve are standardized and organized into path definition nodes in the XML format. Subsequently, the color attributes of the connected regions are encoded, including the RGB values of the fill color and the stroke color, and uniformly inserted into the style definition section of the XML in hexadecimal format. After the structure encoding is completed, a semantic tagging layer is constructed based on the classification results or user-specified tags, and a semantic tag field is added to each path node in the XML document. The color calibration image with added semantic tags is output as an SVG vector image file, obtaining the vector image corresponding to the cultural tourism image.
4. An electronic device, characterized in that, The device includes a processor, a communication bus, a user interface, a network interface, and a memory. The memory is used to store instructions. The user interface and the network interface are used to communicate with other devices. The processor is used to execute the instructions stored in the memory to cause the electronic device to perform the method as described in any one of claims 1 to 3.
5. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed, perform the method as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Three-dimensional image segmentation method based on double-path attention coding and decoding network
CN113643303A
Pixel picture vectorization method for textiles
CN116912338A