The present invention relates to a contour line processing method an electronic device, and more particularly, to a contour line processing method and an electronic device capable of effectively extracting closed contour.
Computer-aided design (CAD) technology has been widely used in manufacturing design for various products. In general, it is necessary to estimate the area or weight of product objects during the product development stage. A product object in the CAD file may be formed by a plurality of discrete line segments. In order to estimate the area or weight of the product object, the sequence order relationship between the line segments is usually determined first, and end points of the line segments are found to connect according to the order of the line segments, such that the combination of the line segments may be converted to a contour block for facilitating estimation of area ratio or weight of the product object. However, if the end points of multiple line segments are too close, it is easy to make a misjudgment, so that the head and tail end points of the line segments cannot be correctly determined. Please refer to
It is therefore a primary objective of the present invention to provide a contour line processing method and an electronic device capable of effectively extracting closed contour, in order to resolve the aforementioned problems.
The present invention discloses a contour line processing method, comprising obtaining a computer-aided design (CAD) image file and detecting a plurality of line segments from the CAD image file; performing a first morphological operation on the plurality of line segments to generate a plurality of blocks; performing a union operation on the plurality of blocks to generate a union block; performing a second morphological operation on the union block to generate a processed block; and determining a target contour block according to the processed block.
The present invention further discloses an electronic system, comprising: a storage device, configured to store instructions; a processor circuit, configured to execute the instructions of: obtaining a CAD image file and detecting a plurality of line segments from the CAD image file; performing a first morphological operation on the plurality of line segments to generate a plurality of blocks; performing a union operation on the plurality of blocks to generate a union block; performing a second morphological operation on the union block to generate a processed block; and determining a target contour block according to the processed block.
These and other objectives of the present invention will no doubt become obvious to those of ordinary skill in the art after reading the following detailed description of the preferred embodiment that is illustrated in the various figures and drawings.
Certain terms are used throughout the description and following claims to refer to particular components. As one skilled in the art will appreciate, hardware manufacturers may refer to a component by different names. This document does not intend to distinguish between components that differ in name but not function. In the following description and in the claims, the terms “include” and “comprise” are utilized in an open-ended fashion, and thus should be interpreted to mean “include, but not limited to”. Also, the term “couple” is intended to mean either an indirect or direct electrical connection. Accordingly, if one device is coupled to another device, that connection may be through a direct electrical connection, or through an indirect electrical connection via other devices and connections.
The embodiments of the present invention may be applied to the product design process using the computer-aided design (CAD), and the embodiments of the present invention may provide the conversion of the combination of line segments into the closed contour block during the design process. Please refer to
According to the procedure 20, in Step S202, the embodiments of the present invention may be executed on CAD software of an electronic device. The electronic device may include a computer device, and the computer device is equipped with CAD software. The CAD software may include AutoCAD, Pro/Engineer, SolidWorks, but not limited thereto. The embodiments of the present invention may generate a CAD image file through CAD software. The embodiments of the present invention may detect, identify and extract a plurality of line segments from the CAD image file by analyzing the CAD image file. The CAD image file may be a drawing interchange format (DXF) file or a AutoCAD drawing database (DWG) file, but not limited thereto. For example, please refer to
In step S204, a first morphological operation may be performed on the plurality of detected line segments to generate a plurality of blocks. For example, the first morphological operation may be a dilation operation. A dilation operation may be performed on the plurality of detected line segments to generate a plurality of blocks. Please refer to
In step S206, a union operation may be performed on the blocks generated in step S204 to generate a union block (a single block). Please refer to
In step S208, a second morphological operation may be performed on the union block UB to generate a processed block. For example, the second morphological operation may be an erosion operation. An erosion operation may be performed on the union block to generate a processed block. Please refer to
In step S210, a target contour block may be determined according to the processed block generated in Step S208. An outer contour of the processed block generated in Step S208 may be detected and extracted, and the detected outer contour of the processed block may be determining as a target contour block, such that the target contour block may be outputted for following estimation of the area ratio or weight of the object. Please refer to
Conventional processing method typically determines object contour lines by detecting and connecting head and tail endpoints, which may cause misjudgment at the intersection of multiple similar line segments. Compared with conventional processing method, the embodiments of the present invention utilize image morphology operations to effectively and accurately convert discrete line segments into closed contours, thus greatly improving the accuracy of the subsequent estimation of area or weight of the product object. For example, please refer to
Those skilled in the art should readily make combinations, modifications and/or alterations on the abovementioned description and examples. The abovementioned description, steps, procedures and/or processes including suggested steps can be realized by means that could be hardware, software, firmware (known as a combination of a hardware device and computer instructions and data that reside as read-only software on the hardware device), an electronic system or combination thereof. Examples of hardware can include analog, digital and/or mixed circuits known as microcircuit, microchip, or silicon chip. For example, the hardware may include application-specific integrated circuit (ASIC), field programmable gate array (FPGA), programmable logic device, coupled hardware components or combination thereof. In another example, the hardware may include general-purpose processor, microprocessor, controller, digital signal processor (DSP) or combination thereof. Examples of the software may include set (s) of codes, set (s) of instructions and/or set (s) of functions retained (e.g., stored) in a storage device, e.g., a non-transitory computer-readable medium. The non-transitory computer-readable storage medium may include read-only memory (ROM), flash memory, random access memory (RAM), subscriber identity module (SIM), hard disk, floppy diskette, or CD-ROM/DVD-ROM/BD-ROM, but not limited thereto. The embodiments of the invention may include an electronic system, and the electronic system may include a processing circuit and a storage device. Any of the abovementioned procedures and examples above may be compiled into program codes or instructions that are stored in the storage device or a computer-readable medium. The processing circuit may read and execute the program codes or the instructions stored in the storage device storage device or computer-readable medium for realizing the abovementioned functions.
To sum up, conventional processing method typically determines object contour lines by detecting and connecting head and tail endpoints, which may cause misjudgment at the intersection of multiple similar line segments. Compared with conventional processing method, the embodiments of the present invention utilize image morphology operations to effectively and accurately convert discrete line segments into closed contours, thus greatly improving the accuracy of the subsequent estimation of area or weight of the product object.
Those skilled in the art will readily observe that numerous modifications and alterations of the device and method may be made while retaining the teachings of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims.
Number | Date | Country | Kind |
---|---|---|---|
202310246254.0 | Mar 2023 | CN | national |