Block generation method and system based on freehand sketch
By extracting the closed contours and metric anchor points of hand-drawn sketches, constructing a spatial scale field, and extracting height-hinting features, the problem of quantifying the scale and height of hand-drawn sketches in 3D modeling is solved, and the automated generation of 3D models and data consistency are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHENGDU IND VOCATIONAL TECHN COLLEGE
- Filing Date
- 2026-04-08
- Publication Date
- 2026-05-12
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In existing technologies, hand-drawn sketches cannot provide consistent scale information, cannot quantify height representation, and cannot automatically correct spatial relationships between blocks during 3D modeling, resulting in low modeling efficiency and susceptibility to misunderstandings.
By acquiring hand-drawn sketch images, extracting closed contours and identifying metric anchor points, constructing a spatial scale field, performing polygon mapping and height suggestion feature extraction, generating three-dimensional block parameters, using spatial constraint maps for position adjustment, and finally generating a three-dimensional model.
It enables the automated conversion of hand-drawn sketches into 3D models, improves data consistency and modeling efficiency, and eliminates intersections and misalignments between blocks.
Smart Images

Figure CN122023745A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of image processing and 3D modeling technology, specifically to a method and system for generating blocks based on hand-drawn sketches. Background Technology
[0002] In the conceptual design phase, designers often use hand-drawn sketches to express spatial outlines, volumetric relationships, and variations in height. Hand-drawn sketches offer advantages such as intuitive expression and ease of modification; however, their proportions often rely on the drafter's experience, and different areas may exhibit localized enlargement or compression. Line thickness and shading are also mostly illustrative, lacking quantitative information directly usable for calculation. Current 3D modeling workflows typically require redrawing the outline in modeling software and manually setting dimensions and height parameters. Sketches are used only as reference base maps, and the modeling process relies on manual operation, resulting in low efficiency and susceptibility to misunderstandings. While some image processing methods can extract boundary lines from sketches, they usually use a single scale for overall scaling, failing to reflect scale differences between different areas within the sketch. Furthermore, they lack numerical analysis of information such as line width, overlapping lines, or fill density, meaning the height parameters of the generated blocks still require manual determination.
[0003] In complex sketch scenarios, automatically generated bottom contours are prone to overlap or misalignment, making it difficult to directly form 3D blocks with consistent spatial relationships. Therefore, a processing method is needed that can extract measurable scale information and height cues from hand-drawn sketches and complete position correction and block generation under a unified coordinate system to improve the automation and data consistency of sketch-to-3D model conversion. Summary of the Invention
[0004] The purpose of this invention is to provide a method and system for generating blocks based on hand-drawn sketches, so as to at least solve the problems of inconsistent scale information, unquantifiable height expression, and difficulty in automatically correcting spatial relationships of blocks in hand-drawn sketches.
[0005] To achieve the above objectives, a first aspect of the present invention provides a method for generating blocks based on hand-drawn sketches. The method includes: acquiring a hand-drawn sketch image and extracting a candidate set of closed contours; generating a candidate set of polygons based on the candidate set of closed contours; identifying a set of metric anchor points in the hand-drawn sketch image; constructing a spatial scale field based on the set of metric anchor points; mapping the candidate set of polygons to a set of metric base polygons; extracting a set of height implications corresponding to the set of metric base polygons; determining an absolute height value based on the set of height implications and the set of metric anchor points; generating a set of block parameters; constructing a spatial constraint graph based on the set of metric base polygons and the set of block parameters; performing position adjustment calculations; generating a three-dimensional block set; and outputting a three-dimensional model file.
[0006] Optionally, acquiring a hand-drawn sketch image and extracting a candidate set of closed contours, and generating a candidate set of polygons based on the candidate set of closed contours, includes: performing adaptive binarization processing on the hand-drawn sketch image to generate a line mask image; performing skeleton thinning processing on the line mask image to generate a skeleton image with a single pixel width, and extracting the endpoint set and intersection set in the skeleton image; performing vectorization processing on the skeleton image based on the endpoint set and the intersection set to generate a polyline set, and performing line segment merging and simplification processing on the polyline set to obtain a contour line segment set; performing closure detection and break completion calculation based on the endpoint distance and included angle relationship of adjacent line segments in the contour line segment set to generate a candidate set of closed contours, and converting the candidate set of closed contours into a candidate set of polygons.
[0007] Optionally, the polyline set is subjected to segment merging and simplification processing to obtain a contour segment set, including: calculating the endpoint distance and direction angle between adjacent polylines in the polyline set, and filtering polyline pairs whose endpoint distance is less than a preset distance threshold and whose direction angle is less than a preset angle threshold; performing endpoint connection and direction consistency adjustment on the polyline pairs to generate a merged polyline set; performing vertex redundancy detection on each polyline in the merged polyline set, deleting continuous collinear vertices and retaining endpoints and turning points to generate a simplified polyline set; and reorganizing the simplified polyline set according to spatial connectivity to obtain the contour segment set.
[0008] Optionally, identifying the set of metric anchor points in the hand-drawn sketch image includes: performing directional filtering and morphological connectivity analysis on the hand-drawn sketch image to extract a set of line segment pairs that satisfy the characteristics of parallel lines, and generating a first set of anchor point candidates based on the pixel spacing between adjacent parallel lines in the set of line segment pairs; detecting stepped line segment groups with regular repeating structures in the hand-drawn sketch image, and generating a second set of anchor point candidates based on the pixel spacing between adjacent stepped line segments; performing symbol template matching and contour shape comparison on the hand-drawn sketch image to identify facility symbol regions that satisfy a preset geometric ratio relationship, and generating a third set of anchor point candidates based on the pixel size of the facility symbol regions; performing spatial consistency verification and scale consistency filtering on the first set of anchor point candidates, the second set of anchor point candidates, and the third set of anchor point candidates, retaining anchor point data that satisfy the true spacing mapping relationship, and generating the set of metric anchor points.
[0009] Optionally, constructing a spatial scale field based on the set of metric anchor points and mapping the candidate polygon set to a metric base polygon set includes: extracting the corresponding pixel spacing value and true spacing value for each metric anchor point in the set of metric anchor points, and calculating scale sample values based on the pixel spacing value and the true spacing value to generate a scale sample set; dividing the hand-drawn sketch image into multiple scale grids according to the spatial distribution of the scale sample set in the hand-drawn sketch image, and performing statistical fusion processing on the scale sample values falling into each scale grid to generate a grid scale value set; performing spatial interpolation calculation based on the grid scale value set to generate a spatial scale field covering the hand-drawn sketch image; reading the scale value of the corresponding position in the spatial scale field for each vertex pixel coordinate in the candidate polygon set, and performing coordinate transformation calculation on each vertex pixel coordinate based on the scale value to generate the metric base polygon set.
[0010] Optionally, extracting the height hint feature set corresponding to the set of metric base polygons includes: determining the corresponding pixel region of each metric base polygon in the hand-drawn sketch image, and extracting the boundary line pixel set and the internal fill pixel set in the corresponding pixel region; calculating the line width feature value based on the boundary line pixel set, and calculating the shadow density feature value based on the internal fill pixel set; performing parallel line detection and counting the number of repeated lines in the corresponding pixel region, and calculating the overlapping line feature value; combining the line width feature value, the shadow density feature value, and the overlapping line feature value according to the correspondence relationship of the metric base polygons to generate the height hint feature set.
[0011] Optionally, determining the absolute height value based on the height suggestion feature set and the measurement anchor point set, and generating a block parameter set, includes: performing normalization processing on each height suggestion feature vector in the height suggestion feature set, and calculating the relative height level value based on a preset weight to generate a relative height level set; selecting height reference anchor points with real height attributes from the measurement anchor point set, and reading the real height value corresponding to the height reference anchor point to generate a height reference set; determining the corresponding height unit value based on the spatial adjacency relationship between each metric base polygon and the height reference set, and calculating the absolute height value set based on the relative height level set and the height unit value; and combining the absolute height value set and the metric base polygon set in a one-to-one correspondence to generate a block parameter set.
[0012] Optionally, a spatial constraint graph is constructed based on the set of metric base polygons and the set of block parameters, and position adjustment calculations are performed to generate a three-dimensional block set and output a three-dimensional model file. This includes: determining the set of adjacent edges and the set of intersecting edges based on the boundary distance and intersection relationships between any two metric base polygons in the set of metric base polygons, and constructing a spatial constraint graph using each metric base polygon as a node; setting position adjustment variables for the set of metric base polygons based on the spatial constraint graph, and using the elimination of the intersection area corresponding to the set of intersecting edges and the satisfaction of the boundary distance conditions corresponding to the set of adjacent edges as position adjustment targets, calculating each position adjustment variable and generating a set of corrected base polygons; performing extrusion generation based on the absolute height values in the set of corrected base polygons and the set of block parameters to generate a three-dimensional block set; and encapsulating the three-dimensional block set into a three-dimensional model file containing geometric data and block identification data and outputting it.
[0013] Optionally, a three-dimensional block set is generated by performing extrusion generation based on the absolute height values in the set of correction bottom polygons and the set of block parameters. This includes: performing patch construction on each correction bottom polygon in the set of correction bottom polygons to obtain a set of bottom patch faces; associating the absolute height values in the set of block parameters with the set of bottom patch faces in a one-to-one correspondence to generate a set of extrusion parameters; performing extrusion generation on the set of bottom patch faces along a preset vertical direction based on the set of extrusion parameters, and performing closure processing on the extruded sidewalls and top surface to obtain a three-dimensional block set.
[0014] A second aspect of the present invention provides a volumetric generation system based on hand-drawn sketches. The system includes: an initialization unit, configured to acquire a hand-drawn sketch image and extract a candidate set of closed contours, and generate a candidate set of polygons based on the candidate set of closed contours; a mapping unit, configured to identify a set of metric anchor points in the hand-drawn sketch image, construct a spatial scale field based on the set of metric anchor points, and map the candidate set of polygons to a set of metric base polygons; a feature extraction unit, configured to extract a set of height implications features corresponding to the set of metric base polygons, determine an absolute height value based on the set of height implications features and the set of metric anchor points, and generate a set of volumetric parameters; and a file output unit, configured to construct a spatial constraint diagram based on the set of metric base polygons and the set of volumetric parameters, perform position adjustment calculations, generate a three-dimensional volumetric set, and output a three-dimensional model file.
[0015] Through the above technical solution, the present invention extracts closed contours and generates polygons from hand-drawn sketches, constructs a spatial scale field using metric anchor points, and achieves a unified mapping of different scales within the sketch, transforming the bottom contour into a metric bottom polygon with real size attributes. Based on this, it numerically calculates height implications such as line width, shadows, and overlapping lines to determine absolute height values and generate a set of block parameters, thus providing a calculable source for block height. Furthermore, it constructs a spatial constraint diagram to perform position adjustment calculations, eliminating intersections and misalignments between blocks, ultimately generating a set of three-dimensional blocks with consistent spatial relationships and outputting a three-dimensional model file, achieving automatic conversion from hand-drawn sketches to directly usable three-dimensional block models.
[0016] Other features and advantages of the embodiments of the present invention will be described in detail in the following detailed description section. Attached Figure Description
[0017] The accompanying drawings are provided to further illustrate embodiments of the present invention and form part of the specification. They are used together with the following detailed description to explain the embodiments of the present invention, but do not constitute a limitation thereof. In the drawings: Figure 1 This is a flowchart of the steps of a block generation method based on hand-drawn sketches provided in one embodiment of the present invention; Figure 2 This is a system structure diagram of a block generation system based on hand-drawn sketches provided in one embodiment of the present invention; Figure 3 This is an internal structural diagram of a computer device provided in one embodiment of the present invention. Detailed Implementation
[0018] The specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.
[0019] like Figure 1 As shown, this invention provides a method for generating blocks based on hand-drawn sketches, the method comprising: Step S1: Obtain the hand-drawn sketch image and extract the closed contour candidate set, and generate the polygon candidate set based on the closed contour candidate set.
[0020] Specifically, adaptive binarization is performed on the hand-drawn sketch image to generate a line mask image; skeleton thinning is performed on the line mask image to generate a skeleton image with a single pixel width, and the endpoint set and intersection set in the skeleton image are extracted; vectorization is performed on the skeleton image based on the endpoint set and the intersection set to generate a polyline set, and line segment merging and simplification are performed on the polyline set to obtain a contour line segment set; based on the endpoint distance and included angle relationship of adjacent line segments in the contour line segment set, closure detection and break completion calculations are performed to generate a closed contour candidate set, and the closed contour candidate set is converted into a polygon candidate set.
[0021] Furthermore, the polyline set is subjected to segment merging and simplification processing to obtain a contour segment set, including: calculating the endpoint distance and direction angle between adjacent polylines in the polyline set, and filtering polyline pairs whose endpoint distance is less than a preset distance threshold and whose direction angle is less than a preset angle threshold; performing endpoint connection and direction consistency adjustment on the polyline pairs to generate a merged polyline set; performing vertex redundancy detection on each polyline in the merged polyline set, deleting continuous collinear vertices and retaining endpoints and turning points to generate a simplified polyline set; and reorganizing the simplified polyline set according to spatial connectivity to obtain the contour segment set.
[0022] In this embodiment of the invention, the hand-drawn sketch image is used as the original input data for subsequent geometric calculations. Its line expression has uneven thickness, local breaks, and overlapping strokes. Therefore, it is necessary to standardize the line structure to obtain a set of contour line segments that can be used for closure determination.
[0023] Specifically, when performing adaptive binarization on the hand-drawn sketch image, a threshold can be determined based on the local window's statistical grayscale mean and variance. This allows dark-colored pen strokes to be retained as foreground pixels, while the paper's base color or light-colored background is identified as background pixels, thereby generating a line mask image. This process avoids the problem of line loss caused by a fixed threshold under different lighting or scanning conditions.
[0024] Skeleton thinning is performed on the line mask image. By iteratively deleting edge pixels that satisfy neighborhood constraints, the original lines of varying widths are shrunk into a skeleton image with a single pixel width. The skeletonized structure facilitates topological analysis, allowing direct extraction of endpoint and intersection sets. The endpoint set is used to identify potential break points, while the intersection set is used to identify contour transitions and line segment connection structures.
[0025] When vectorizing the skeleton image based on the endpoint set and the intersection set, an ordered traversal can be performed along the connected paths of the skeleton pixels to convert the continuous pixel sequence into a polyline set. This polyline set contains tiny inflection points and locally redundant vertices caused by hand-drawn jitter, therefore, it is necessary to perform segment merging and simplification processing on the polyline set.
[0026] During the line segment merging stage, the endpoint distance and direction angle between adjacent polylines are calculated. When the endpoint distance is less than a preset distance threshold and the direction angle is less than a preset angle threshold, the corresponding polyline pair is treated as a segmented representation of the same geometric line segment, and endpoint connection and direction consistency adjustments are performed. The preset distance threshold can be determined according to the image resolution; for example, it can be set to a value in the range of 2 to 5 pixels under 300 dpi scanning conditions. The preset angle threshold can be set to a value in the range of 5 to 15 degrees. This processing avoids misjudging originally continuous boundaries as multiple independent line segments.
[0027] During the polyline simplification stage, vertex redundancy detection is performed on each polyline in the merged polyline set. The included angle formed by three consecutive points is calculated. When the included angle is close to 180 degrees and the deviation is less than the preset collinearity error threshold, the middle vertex is deleted, and only the endpoints and turning points are retained. This process can eliminate the fragmented folds caused by hand-drawn fluctuations, making the contour line segment set more regular.
[0028] Finally, the simplified polyline set is reorganized according to spatial connectivity to form a set of contour segments with consistent topology. Closure detection and break completion calculations are performed based on the endpoint distances and angles between adjacent segments in the contour segment set. When the distance between endpoints is less than a preset closure threshold and the direction meets the closure condition, the corresponding segments are connected to form a candidate set of closed contours. For boundaries with minor breaks, shortest path completion calculations can be performed without crossing existing segments to ensure the closed contour structure meets topological consistency requirements.
[0029] Through the above processing, hand-drawn sketches with irregular handwriting characteristics can be transformed into a set of candidate polygons with clear structure and well-defined topology, providing a stable geometric basis for subsequent scale mapping and height calculation. This method is applicable not only to scanned images but also to images drawn on a graphics tablet or sketches acquired by photography. Equivalent processing can be achieved by adjusting the threshold parameter under different image resolution conditions.
[0030] In one specific implementation, the hand-drawn sketch image is a 300 dpi scanned image with a size of 3508 × 2480 pixels. When performing adaptive binarization on the hand-drawn sketch image, the window size is used... Perform local statistics on pixels and calculate the average grayscale value within the window. with standard deviation The threshold is set as follows: ; in When the pixel grayscale value is less than When a pixel is identified as a foreground pixel, a line mask image is generated.
[0031] When performing skeleton thinning on the line mask image, an iterative deletion rule based on neighborhood constraints is used to ensure that any foreground pixel satisfies... ,in The number of foreground pixels in the 8-neighborhood. The number of transitions from 0 to 1 in the neighborhood is used to obtain a skeleton image with a single pixel width.
[0032] During the vectorization stage, the skeleton image is traversed through connected components to generate a set of polylines. For any adjacent broken lines Calculate the distance between the endpoints: ; And the directional angle: ; when pixels and Merging is performed on the same day. During the line simplification phase, three consecutive points are merged. Calculate collinearity error ; when and Delete intermediate vertices when the pixel is removed.
[0033] After merging and simplifying line segments, a closure determination is performed based on the condition that the distance between endpoints is less than 4 pixels, generating a candidate set of closed contours, and constructing a candidate set of polygons in vertex order.
[0034] Step S2: Identify the set of metric anchor points in the hand-drawn sketch image, construct a spatial scale field based on the set of metric anchor points, and map the polygon candidate set to a metric base polygon set.
[0035] Specifically, directional filtering and morphological connectivity analysis are performed on the hand-drawn sketch image to extract a set of line segment pairs that satisfy the characteristics of parallel lines, and a first anchor point candidate set is generated based on the pixel spacing between adjacent parallel lines in the line segment pair set; stepped line segment groups with regular repeating structures are detected in the hand-drawn sketch image, and a second anchor point candidate set is generated based on the pixel spacing between adjacent stepped line segments; symbol template matching and contour shape comparison are performed on the hand-drawn sketch image to identify facility symbol regions that satisfy preset geometric proportions, and a third anchor point candidate set is generated based on the pixel size of the facility symbol regions; spatial consistency verification and scale consistency filtering are performed on the first anchor point candidate set, the second anchor point candidate set, and the third anchor point candidate set, retaining anchor point data that satisfy the true spacing mapping relationship to generate the measurement anchor point set.
[0036] Furthermore, constructing a spatial scale field based on the set of metric anchor points and mapping the candidate polygon set to a set of metric base polygons includes: extracting the corresponding pixel spacing value and true spacing value (the labeled spacing value input by the user for the corresponding anchor point in the input interface) for each metric anchor point in the set of metric anchor points, and calculating scale sample values based on the pixel spacing value and the true spacing value to generate a scale sample set; dividing the hand-drawn sketch image into multiple scale grids according to the spatial distribution of the scale sample set in the hand-drawn sketch image, and performing statistical fusion processing on the scale sample values falling into each scale grid to generate a grid scale value set; performing spatial interpolation calculation based on the grid scale value set to generate a spatial scale field covering the hand-drawn sketch image; reading the scale value of the corresponding position in the spatial scale field for each vertex pixel coordinate in the candidate polygon set, and performing coordinate transformation calculation on each vertex pixel coordinate based on the scale value to generate the set of metric base polygons.
[0037] In this embodiment of the invention, hand-drawn sketches typically lack uniform scale annotations, and different areas may be locally enlarged or compressed. If a single scale factor is directly used for overall scaling, it can easily lead to distortion of the base dimensions. Therefore, it is necessary to identify metric anchor points in the image that can be used to derive the true scale, and construct a spatial scale field accordingly.
[0038] In the anchor point identification stage, directional filtering is performed on the hand-drawn sketch image. Line segments with stable directional features are extracted using convolutional kernels with multiple directional angles. Then, combined with morphological connected component analysis, line segments exceeding a preset pixel threshold and exhibiting parallel distribution are grouped. For pairs of parallel line segments in the same direction with similar spacing, their pixel spacing values are calculated to form the first anchor point candidate set. These pairs of parallel line segments are commonly used in actual drawing to represent paved grids or regularly separated structures, possessing stable spacing characteristics.
[0039] For the detection of stepped line segment groups, a second anchor point candidate set can be generated by identifying sets of short line segments arranged in equidistant broken lines and calculating the horizontal or vertical pixel spacing between adjacent short line segments. This type of structure is often used in sketches to express hierarchical changes or hierarchical structures, and its spacing has strong consistency.
[0040] In symbol recognition, facility symbol regions that meet preset geometric proportions are identified through symbol template matching and contour shape comparison. These include rectangular symbols with fixed aspect ratios or specific circular combinations. A third set of anchor point candidates is then generated based on the pixel dimensions of the facility symbol regions. Normalized correlation coefficients or shape context matching methods can be used during template matching to ensure the geometric stability of the recognition results.
[0041] After obtaining the first, second, and third anchor point candidate sets, spatial consistency verification and scale consistency screening are performed on these candidate sets. Specifically, statistical analysis is conducted on the pixel spacing values in different candidate sets, data samples that deviate from the mean by more than a preset proportion threshold are removed, and anchor point data that satisfy the true spacing mapping relationship are retained, thereby generating the measurement anchor point set.
[0042] In the spatial scale field construction stage, the corresponding pixel spacing value and true spacing value are extracted for each metric anchor point in the metric anchor point set, and scale sample values are calculated. The scale sample value is the ratio of the true spacing value to the pixel spacing value, used to represent the conversion relationship between pixels and actual length in a local region. All scale sample values are used to form a scale sample set.
[0043] Based on the spatial distribution of the scale sample set in the hand-drawn sketch image, the hand-drawn sketch image is divided into multiple scale grids. The number of scale grids can be determined according to the image resolution, for example, it can be divided into a uniform grid structure of 10×10 or 20×20. Within each scale grid, statistical fusion processing is performed on the scale sample values falling into that scale grid, and the grid scale value set can be generated using the median or weighted average method.
[0044] Subsequently, spatial interpolation is performed on the set of grid scale values to generate a continuous spatial scale field covering the hand-drawn sketch image. The interpolation method can employ bilinear interpolation or inverse distance weighted interpolation to ensure a smooth transition between different regions of the scale field.
[0045] After constructing the spatial scale field, the scale value of the corresponding position in the spatial scale field is read for the pixel coordinates of each vertex in the candidate polygon set. Based on the scale value, coordinate transformation calculation is performed on the pixel coordinates of each vertex to convert them into metric coordinates, generating the metric base polygon set. Through this process, the candidate polygon sets of different regions can be expressed under a unified physical scale, providing a consistent metric basis for subsequent height calculation and spatial constraint optimization.
[0046] In one specific implementation, to identify the set of metric anchor points, directional filtering is first performed on the hand-drawn sketch image. Let the input grayscale image be... Using directional convolution kernels Convolutional processing of the image: ; in, The response results are segmented using a threshold to extract line segment regions with consistent orientation, and morphological connected component analysis is used to filter line segments with a length greater than 20 pixels. Parallel line segments are then processed. Calculate the normal distance: ; in For line segments The normal vector is used to generate the first set of anchor point candidates.
[0047] In the identification of stepped line segment groups, the horizontal or vertical projection spacing of the equidistant broken line groups is statistically analyzed. ,when When a sample is considered valid, a second set of anchor point candidates is generated.
[0048] During the symbol recognition stage, normalized correlation matching is performed on the image: ; when If a match is deemed successful, the pixel size of the corresponding region is recorded to form a third anchor point candidate set.
[0049] Pixel spacing samples for all candidate sets Perform statistical filtering and remove those that meet the criteria. Outliers are identified to obtain a set of metric anchor points. When constructing the spatial scale field, scale sample values are calculated for each metric anchor point: ; in, To correspond to the actual spacing values, the image is divided into a 20×20 grid. Sample set within grid Calculate the median: ; Generate a set of grid-scale values. Perform bilinear interpolation on the set of grid-scale values to obtain a continuous spatial scale field. .
[0050] For any vertex pixel coordinate in the candidate polygon set Read scale value Perform coordinate transformation: ; This generates a set of metric base polygons. This implementation method achieves unified physical coordinate mapping under conditions of local scale differences.
[0051] Step S3: Extract the height suggestion feature set corresponding to the metric base polygon set, determine the absolute height value based on the height suggestion feature set and the metric anchor point set, and generate the block parameter set.
[0052] Specifically, extracting the height hint feature set corresponding to the set of metric base polygons includes: determining the corresponding pixel region of each metric base polygon in the hand-drawn sketch image, and extracting the boundary line pixel set and the internal fill pixel set in the corresponding pixel region; calculating the line width feature value based on the boundary line pixel set, and calculating the shadow density feature value based on the internal fill pixel set; performing parallel line detection and counting the number of repeated lines in the corresponding pixel region, and calculating the overlapping line feature value; combining the line width feature value, the shadow density feature value, and the overlapping line feature value according to the correspondence relationship of the metric base polygons to generate the height hint feature set.
[0053] Furthermore, determining the absolute height value based on the height suggestion feature set and the measurement anchor point set, and generating a volume parameter set, includes: performing normalization processing on each height suggestion feature vector in the height suggestion feature set, and calculating the relative height level value based on a preset weight to generate a relative height level set; selecting height reference anchor points with real height attributes from the measurement anchor point set, and reading the real height value corresponding to the height reference anchor point to generate a height reference set; determining the corresponding height unit value based on the spatial adjacency relationship between each metric base polygon and the height reference set, and calculating the absolute height value set based on the relative height level set and the height unit value; and combining the absolute height value set and the metric base polygon set in a one-to-one correspondence to generate a volume parameter set.
[0054] In this embodiment of the invention, after the construction of the metric base polygon set is completed, each base polygon already has unified planar dimension information, but its corresponding height parameter still needs to be extracted from the hand-drawn sketch image. The hand-drawn sketch usually expresses the height relationship of the volume through changes in line thickness, shading density, or the number of overlapping lines. This type of information is not explicitly given in numerical form, so it is necessary to convert the above expression methods into calculable height hint features.
[0055] In the highly suggestive feature extraction stage, the corresponding pixel region of each metric base polygon in the original hand-drawn sketch image is first determined based on the mapping relationship between the metric base polygon set and the original hand-drawn sketch image. This corresponding pixel region can be obtained by recording the mapping relationship between the candidate polygon set and pixel coordinates. Subsequently, the boundary line pixel set and the internal fill pixel set are separated within the corresponding pixel region. The boundary line pixel set is used to reflect the contour expression intensity, and the internal fill pixel set is used to reflect the shadow or hierarchy expression.
[0056] For the boundary line pixel set, multi-point sampling can be performed along the contour normal direction to statistically analyze the pixel width of the line's black-and-white transition and calculate the line width feature value. This line width feature value can be represented by the mean or median to reduce the impact of local handwriting jitter. For the internal fill pixel set, the shadow density feature value is obtained by statistically analyzing the proportion of non-background pixels per unit area. When the sketch uses diagonal lines or dotted fills to represent height, the shadow density feature value can reflect the fill intensity.
[0057] Parallel line detection is further performed within the corresponding pixel region. Repeating lines consistent with the main direction of the contour are identified using Hough transform or direction consistency statistics, and the number of repeating lines is counted to calculate the overlapping line feature value. Overlapping line feature values are commonly used in sketch representations to indicate facades or hierarchical repeating structures.
[0058] The line width feature value, shadow density feature value and overlapping line feature value are combined according to the correspondence of the metric base polygon to form a height suggestive feature vector, and thus form a height suggestive feature set.
[0059] In the absolute height value determination stage, normalization is performed on each height-hinting feature vector in the height-hinting feature set, mapping feature values of different dimensions to a unified numerical range. Based on preset weights, the normalized features are linearly combined to calculate relative height level values, generating a relative height level set. The preset weights can be set to a fixed proportion based on experience, and example values are provided in the specification to ensure sufficient disclosure.
[0060] Furthermore, height reference anchors with true height attributes are selected from the set of measurement anchors, such as standard component symbols recognizable in the image or structures with known height expressions, and their corresponding true height values are read to generate a height reference set. Based on the spatial adjacency relationship between each metric base polygon and the height reference set, the corresponding height unit value is determined for each metric base polygon.
[0061] After obtaining the height unit values, the relative height level set is multiplied by the height unit values to generate the absolute height value set. Finally, the absolute height value set is combined with the metric base polygon set in a one-to-one correspondence to form the block parameter set. This block parameter set contains the base geometry information and the corresponding absolute height values, providing a complete geometric parameter foundation for subsequent 3D block generation.
[0062] In one specific implementation, the set of metric base polygons has already been mapped from pixels to physical coordinates through a spatial scale field. Therefore, the mapping relationship between polygon vertices and original pixel coordinates can be used to reverse locate the corresponding pixel region of each metric base polygon in the hand-drawn sketch image. Let the pixel region corresponding to a certain metric base polygon be... Its boundary pixel set is denoted as The set of internally filled pixels is denoted as .
[0063] In the online wide feature calculation stage, for Grayscale samples are taken from each boundary pixel along the normal direction, and the width of the black-and-white transition is calculated. The line width characteristic value is taken as: ; in This refers to the number of sampling times. During the shadow density calculation phase, the number of foreground pixels in the inner filling pixel set is counted. Total number of pixels in the region The shadow density feature values are obtained as follows: ; During the overlap detection stage, Perform the Hough transform and count the number of lines that align with the principal direction of the boundary. This is used as the feature value of the overlapping line.
[0064] Will , , Combining to form highly suggestive feature vectors This constitutes a set of highly suggestive features.
[0065] Perform min-max normalization on each highly suggestive feature vector to obtain Based on a preset weight vector Calculate the relative height level value: ; in .
[0066] Filter the height reference anchor points with true height attributes from the set of measurement anchor points, and read their true height values. The nearest reference relationship is determined based on the Euclidean distance between the centroid of the metric base polygon and the height reference anchor point, and the unit height value is calculated: ; The final absolute height value is: ; Will By associating the data with the corresponding metric base polygon, a set of volumetric parameters is generated. Through this calculation process, a continuous transformation from planar representation features to quantifiable absolute height values is achieved, maintaining a physical coordinate system consistent with the aforementioned spatial scale field.
[0067] Step S4: Construct a spatial constraint diagram based on the set of metric base polygons and the set of block parameters, perform position adjustment calculations, generate a three-dimensional block set, and output a three-dimensional model file.
[0068] Specifically, based on the boundary distance and intersection relationships between any two metric base polygons in the metric base polygon set, the adjacent edge set and the intersecting edge set are determined, and a spatial constraint graph is constructed using each metric base polygon as a node; based on the spatial constraint graph, position adjustment variables are set for the metric base polygon set, and the position adjustment targets are to eliminate the intersection area corresponding to the intersecting edge set and to satisfy the boundary distance condition corresponding to the adjacent edge set, and each position adjustment variable is calculated to generate a corrected base polygon set; based on the corrected base polygon set and the absolute height value in the block parameter set, an extrusion generation is performed to generate a three-dimensional block set; the three-dimensional block set is encapsulated into a three-dimensional model file containing geometric data and block identification data and output.
[0069] Furthermore, based on the absolute height values in the set of correction-based bottom polygons and the set of block parameters, an extrusion generation is performed to generate a three-dimensional block set, including: performing patch construction on each correction-based bottom polygon in the set of correction-based bottom polygons to obtain a set of bottom patch faces; associating the absolute height values in the set of block parameters with the set of bottom patch faces in a one-to-one correspondence to generate an extrusion parameter set; performing extrusion generation on the set of bottom patch faces along a preset vertical direction based on the extrusion parameter set, and performing closure processing on the extruded sidewalls and top surface to obtain a three-dimensional block set.
[0070] In this embodiment of the invention, after constructing the set of metric base polygons and the set of block parameters, each base polygon has a real scale and a corresponding absolute height value. However, due to local scale drift and slight boundary offsets during the hand-drawn sketching process, overlapping boundaries, abnormal spacing, or alignment deviations may occur between different base polygons. Therefore, it is necessary to uniformly adjust the planar geometric relationships before 3D generation.
[0071] During the spatial constraint graph construction phase, boundary distance and intersection area calculations are performed on any two metric base polygons in the set of metric base polygons. For polygon pairs with a boundary distance less than a preset adjacency threshold, their relationship is recorded as an adjacent edge; for polygon pairs with a non-zero intersection area, their relationship is recorded as an intersection edge. Using each metric base polygon as a node and adjacent and intersection edges as edge structures, a spatial constraint graph is constructed. This spatial constraint graph is used to describe the structural relationships between planar geometries.
[0072] In the position adjustment calculation stage, planar position adjustment variables are set for each metric base polygon, including translation and rotation components. An objective function is constructed, using the intersection area corresponding to the set of intersection edges as a penalty term and the boundary distance deviation corresponding to the set of adjacent edges as a constraint term. Each position adjustment variable is calculated by minimizing the objective function. An iterative optimization algorithm can be used during the calculation, stopping when the intersection area converges to zero or is less than a preset tolerance value. This process generates a set of corrected base polygons, ensuring that the base polygons satisfy predetermined spatial relationship conditions.
[0073] In the 3D volume generation stage, extrusion generation is performed based on the absolute height values in the set of corrected bottom polygons and the set of volume parameters. Specifically, each corrected bottom polygon in the set of corrected bottom polygons is constructed as a patch, representing it as a closed planar patch structure to obtain a set of bottom patches. Subsequently, the absolute height values in the set of volume parameters are associated with the set of bottom patches in a one-to-one correspondence to generate an extrusion parameter set.
[0074] During the stretching process, the normal direction of the bottom surface is used as the preset vertical direction. A linear displacement along the vertical direction is performed on the bottom surface to generate the sidewall surface, and a top surface is constructed, so that the bottom, sidewall, and top surfaces form a closed volume. During the closure process, topological connections are made between the vertices of the sidewalls and the vertices of the top surface to ensure that the generated set of three-dimensional blocks satisfies the geometric closure condition.
[0075] The 3D block set is encapsulated according to a 3D model data structure. The 3D model file contains geometric vertex data, face index data, and block identifier data. The block identifier data records the corresponding metric base polygon index and absolute height value. Through the above steps, a structured transformation from planar geometry to 3D blocks is completed, generating a directly loadable 3D model file.
[0076] In one specific implementation, the set of metric base polygons is denoted as... The absolute height value corresponding to the block parameter set is denoted as Since the scale mapping and height calculation have been completed in the aforementioned steps, all bottom polygons are now in a unified physical coordinate system. However, there may still be intersection or spacing issues, so geometric consistency adjustments are necessary.
[0077] During the spatial constraint diagram construction phase, for any two-meter base polygon Calculate the minimum boundary distance Intersecting area The intersecting area can be obtained through polygon Boolean operations. When At that time, Add to the set of intersecting edges; when and At that time, Add to the set of adjacent edges, where This is the adjacency threshold. A graph structure is then constructed based on this. Node set edge set It consists of adjacent edges and intersecting edges.
[0078] During the position adjustment phase, for each Set plane adjustment variable Construct the objective function: ; in, Let be the set of intersecting edges. Let be the set of adjacent edges. These are the weighting coefficients. Updated iteratively. make smallest, when The calculation stops when the correction base polygon set is obtained. .
[0079] In the 3D generation stage, for each correction base polygon Perform patch construction to obtain the bottom patch. The absolute height value Associated with the corresponding bottom surface patch, a set of stretching parameters is generated. .
[0080] Along a uniform vertical direction Perform linear displacement on the bottom surface patch to generate sidewall vertices: ; The top and sidewall patches are then constructed to form a closed polyhedron for each block. Finally, the generated set of 3D blocks is written into a 3D model file, which contains vertex coordinate arrays. Face index array and block identification data Through the above calculation process, the transformation from corrective planar geometry to a complete three-dimensional block set is achieved, and the model data is output under a unified physical scale and topological relationship.
[0081] In another possible implementation, the set of adjacent edges in the spatial constraint graph is grouped according to connected components to form a set of volume block subgroups, and the overall envelope boundary of each volume block subgroup is calculated. For a 3D volume block within the same volume block subgroup, when the absolute height value of any 3D volume block is adjusted, a synchronous proportional correction is performed on the remaining 3D volume blocks based on the envelope boundary of the volume block subgroup, so that the overall proportional relationship of the volume block subgroup remains unchanged.
[0082] During the scaling process, the geometric center of the set of volumetric subgroups is used as the scaling reference point, and the vertex coordinates of each 3D volume are scaled. ; in, The geometric center of the set of bulk subgroups. A proportionality coefficient introduced for changes in height.
[0083] This extended implementation method enables the linkage adjustment between changes in block height and group shape while maintaining the stability of the overall spatial structure relationship, so that the generated three-dimensional block set has a consistent spatial hierarchy expression capability in complex scenes.
[0084] In another possible implementation, after generating the set of three-dimensional blocks, stability verification and local reconstruction processing are performed on the set of three-dimensional blocks. Specifically, for each three-dimensional block, its base area is calculated. with absolute height value The ratio: ; when When the preset morphological stability threshold is exceeded, the three-dimensional block is marked as a slender and abnormal block.
[0085] For slender, anomalous volumes, their corresponding height-hint feature set is re-read, and the weight of linewidth feature values in the relative height level calculation is reduced. The relative height level value and absolute height value are then recalculated to obtain the corrected height parameters. Subsequently, only this 3D volume is re-extruded and regenerated, without changing the position and scale of other 3D volumes.
[0086] This implementation method performs a secondary check on the geometric proportions of the blocks, enabling abnormally proportioned blocks to be locally corrected without disrupting the overall spatial constraint diagram structure, thereby improving the geometric rationality and structural consistency of the generated results under complex sketch expression conditions.
[0087] like Figure 2 As shown, this invention provides a volumetric generation system based on hand-drawn sketches. The system includes: an initialization unit, used to acquire a hand-drawn sketch image and extract a candidate set of closed contours, and generate a candidate set of polygons based on the candidate set of closed contours; a mapping unit, used to identify a set of metric anchor points in the hand-drawn sketch image, construct a spatial scale field based on the set of metric anchor points, and map the candidate set of polygons to a set of metric base polygons; a feature extraction unit, used to extract a set of height implications features corresponding to the set of metric base polygons, determine an absolute height value based on the set of height implications features and the set of metric anchor points, and generate a set of volumetric parameters; and a file output unit, used to construct a spatial constraint map based on the set of metric base polygons and the set of volumetric parameters, perform position adjustment calculations, generate a three-dimensional volumetric set, and output a three-dimensional model file.
[0088] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 3 As shown. The computer device includes a processor A01, a network interface A02, memory (not shown), and a database (not shown) connected via a system bus. The processor A01 provides computing and control capabilities. The memory includes internal memory A03 and a non-volatile storage medium A06. The non-volatile storage medium A06 stores an operating system B01, a computer program B02, and a database (not shown). The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 stored in the non-volatile storage medium A06. The network interface A02 is used for communication with external terminals via a network connection. When the computer program B02 is executed by the processor A01, it implements a block generation method based on hand-drawn sketches.
[0089] Those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a program instructing related hardware. This program is stored in a storage medium and includes several instructions to cause a microcontroller, chip, or processor to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0090] The optional embodiments of the present invention have been described in detail above with reference to the accompanying drawings. However, the embodiments of the present invention are not limited to the specific details described above. Within the scope of the technical concept of the embodiments of the present invention, various simple modifications can be made to the technical solutions of the embodiments of the present invention, and these simple modifications all fall within the protection scope of the embodiments of the present invention. It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. To avoid unnecessary repetition, the embodiments of the present invention will not further describe the various possible combinations.
[0091] Furthermore, various different embodiments of the present invention can be combined in any way, as long as they do not violate the spirit of the embodiments of the present invention, they should also be regarded as the content disclosed by the embodiments of the present invention.
Claims
1. A method for generating volumes based on hand-drawn sketches, characterized in that, The method includes: Acquire a hand-drawn sketch image and extract a candidate set of closed contours, and generate a candidate set of polygons based on the candidate set of closed contours; Identify the set of metric anchor points in the hand-drawn sketch image, construct a spatial scale field based on the set of metric anchor points, and map the polygon candidate set to a metric base polygon set; Extract the height suggestion feature set corresponding to the metric base polygon set, determine the absolute height value based on the height suggestion feature set and the metric anchor point set, and generate a block parameter set; Based on the set of metric base polygons and the set of block parameters, a spatial constraint diagram is constructed and a position adjustment calculation is performed to generate a three-dimensional block set and output a three-dimensional model file.
2. The method for generating blocks based on hand-drawn sketches according to claim 1, characterized in that, Acquire a hand-drawn sketch image and extract a candidate set of closed contours. Generate a candidate set of polygons based on the candidate set of closed contours, including: Adaptive binarization is performed on the hand-drawn sketch image to generate a line mask image; The line mask image is subjected to skeleton thinning processing to generate a skeleton image with a single pixel width, and the endpoint set and intersection set in the skeleton image are extracted. Based on the endpoint set and the intersection set, the skeleton image is vectorized to generate a polyline set, and the polyline set is then merged and simplified to obtain a contour line segment set. Based on the endpoint distance and included angle relationship between adjacent line segments in the contour line segment set, closure detection and break completion calculations are performed to generate a closed contour candidate set, and the closed contour candidate set is converted into a polygon candidate set.
3. The method for generating blocks based on hand-drawn sketches according to claim 2, characterized in that, Perform line segment merging and simplification processing on the polyline set to obtain a contour line segment set, including: Calculate the endpoint distance and direction angle between adjacent polylines in the polyline set, and filter polyline pairs whose endpoint distance is less than a preset distance threshold and whose direction angle is less than a preset angle threshold; The endpoint connections and direction consistency of the polyline pairs are adjusted to generate a merged polyline set; Perform vertex redundancy detection on each polyline in the merged polyline set, delete consecutive collinear vertices and retain endpoints and turning points to generate a simplified polyline set; The simplified polyline set is reorganized according to spatial connectivity to obtain the contour line segment set.
4. The method for generating blocks based on hand-drawn sketches according to claim 1, characterized in that, Identifying the set of metric anchor points in the hand-drawn sketch image includes: Directional filtering and morphological connected component analysis are performed on the hand-drawn sketch image to extract a set of line segment pairs that satisfy the parallel line features, and a first anchor point candidate set is generated based on the pixel spacing between adjacent parallel lines in the set of line segment pairs. In the hand-drawn sketch image, a group of stepped line segments with a regular repeating structure is detected, and a second anchor point candidate set is generated based on the pixel spacing between adjacent stepped line segments. The hand-drawn sketch image is subjected to symbol template matching and contour shape comparison to identify facility symbol regions that meet the preset geometric proportions, and a third anchor point candidate set is generated based on the pixel size of the facility symbol regions. Spatial consistency verification and scale consistency screening are performed on the first anchor point candidate set, the second anchor point candidate set, and the third anchor point candidate set. Anchor point data that satisfies the true spacing mapping relationship are retained to generate the metric anchor point set.
5. The method for generating blocks based on hand-drawn sketches according to claim 4, characterized in that, A spatial scale field is constructed based on the set of metric anchor points, and the candidate polygon set is mapped to a set of metric base polygons, including: Extract the corresponding pixel spacing value and true spacing value for each metric anchor point in the metric anchor point set, and calculate the scale sample value based on the pixel spacing value and the true spacing value to generate a scale sample set; Based on the spatial distribution of the scale sample set in the hand-drawn sketch image, the hand-drawn sketch image is divided into multiple scale grids, and statistical fusion processing is performed on the scale sample values falling into each scale grid to generate a grid scale value set. Spatial interpolation calculations are performed based on the set of grid scale values to generate a spatial scale field covering the hand-drawn sketch image; For each vertex pixel coordinate in the candidate polygon set, the scale value of the corresponding position in the spatial scale field is read, and coordinate transformation calculation is performed on each vertex pixel coordinate based on the scale value to generate the metric base polygon set.
6. The method for generating blocks based on hand-drawn sketches according to claim 1, characterized in that, Extracting the set of height-hinting features corresponding to the set of metric base polygons, including: Determine the corresponding pixel region of each metric base polygon in the hand-drawn sketch image, and extract the boundary line pixel set and the internal fill pixel set in the corresponding pixel region; The line width feature value is calculated based on the set of pixels of the boundary line, and the shadow density feature value is calculated based on the set of pixels of the inner filling. Parallel line detection is performed within the corresponding pixel area, the number of repeating lines is counted, and the overlapping line feature value is calculated. The line width feature value, the shadow density feature value, and the overlapping line feature value are combined according to the correspondence between the metric base polygons to generate a height hint feature set.
7. The method for generating blocks based on hand-drawn sketches according to claim 6, characterized in that, The absolute height value is determined based on the height-hinting feature set and the measurement anchor point set, and a block parameter set is generated, including: Normalization is performed on each height implication feature vector in the height implication feature set, and relative height level values are calculated based on preset weights to generate a relative height level set; In the set of measurement anchor points, select height reference anchor points with real height attributes, and read the real height values corresponding to the height reference anchor points to generate a height reference set; Based on the spatial adjacency relationship between each metric base polygon and the height reference set, the corresponding height unit value is determined, and the absolute height value set is calculated according to the relative height level set and the height unit value. The set of absolute height values and the set of metric base polygons are combined in a one-to-one correspondence to generate a set of block parameters.
8. The method for generating blocks based on hand-drawn sketches according to claim 7, characterized in that, Based on the set of metric base polygons and the set of block parameters, a spatial constraint diagram is constructed, and position adjustment calculations are performed to generate a three-dimensional block set and output a three-dimensional model file, including: Based on the boundary distance relationship and intersection relationship between any two metric base polygons in the set of metric base polygons, determine the set of adjacent relationship edges and the set of intersection relationship edges, and construct a spatial constraint graph using each metric base polygon as a node; Based on the spatial constraint diagram, position adjustment variables are set for the metric base polygon set, and the position adjustment targets are the intersection area corresponding to the set of intersecting edges that eliminates the intersection relationship and the boundary distance condition corresponding to the set of adjacent edges that satisfy the adjacent relationship. Each position adjustment variable is calculated and a correction base polygon set is generated. Based on the absolute height values in the set of correction bottom polygons and the set of block parameters, an extrusion generation is performed to generate a three-dimensional block set. The three-dimensional block set is encapsulated into a three-dimensional model file containing geometric data and block identification data, and then output.
9. The method for generating blocks based on hand-drawn sketches according to claim 8, characterized in that, Based on the set of polygons on the correction base and the absolute height values in the set of block parameters, an extrusion generation is performed to generate a three-dimensional block set, including: Perform patch construction on each of the correction base polygons in the correction base polygon set to obtain a base patch set; The absolute height values in the block parameter set are associated with the bottom surface patch set in a one-to-one correspondence relationship to generate a stretching parameter set; Based on the set of stretching parameters, the bottom surface patch set is stretched along a preset vertical direction to generate the sample, and the stretched sidewalls and top surface are closed to obtain a three-dimensional block set.
10. A volumetric generation system based on hand-drawn sketches, characterized in that, The system includes: An initialization unit is used to acquire a hand-drawn sketch image and extract a candidate set of closed contours, and generate a candidate set of polygons based on the candidate set of closed contours. The mapping unit is used to identify the set of metric anchor points in the hand-drawn sketch image, construct a spatial scale field based on the set of metric anchor points, and map the polygon candidate set to a metric base polygon set. The feature extraction unit is used to extract the height implication feature set corresponding to the metric base polygon set, determine the absolute height value based on the height implication feature set and the metric anchor point set, and generate a block parameter set. The file output unit is used to construct a spatial constraint diagram based on the metric base polygon set and the block parameter set, perform position adjustment calculations, generate a three-dimensional block set, and output a three-dimensional model file.