Image segmentation method, device and equipment
By simulating the biological vision mechanism and the principle of painting perspective, multi-point perspective calculation is performed on the image, and the segmentation units are identified and corrected. This solves the problem of large demand for artificial neural network image segmentation data and high consumption of computing resources, and achieves efficient image segmentation.
Patent Information
- Application Number
- CN202410551611.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-06
- Publication Date
- 2024-08-23
AI Technical Summary
In the existing technology, artificial neural networks require a large amount of training data and computing resources when performing image segmentation, resulting in large data requirements and high computing resource consumption.
By simulating the mechanism of biological vision and drawing on the principles of painting perspective, we perform multi-point perspective calculation on the image to be processed, identify the segmentation units, and further accurately correct the spatial vector information of the object based on the identified segmentation units to achieve image segmentation and avoid relying on a large number of Training data for model training.
In the image segmentation process, there is no need to rely on a large amount of training data, and the data demand is small, which can save a lot of computing resources and achieve efficient image segmentation.
Smart Images

Figure CN118537858A
Abstract
Description
Technical Field
[0001] The present application belongs to the field of data processing, and specifically relates to an image segmentation method, device, equipment and storage medium. Background Art
[0002] Image segmentation is an important branch of image processing and machine vision. Its goal is to divide an image into several semantically or structurally consistent regions or objects. Currently, artificial neural network recognition technology has been widely used in image segmentation.
[0003] In the prior art, the basis for image segmentation by artificial neural networks is the brightness and color of pixels in the image to be processed. By training a multi-layer perceptron, a linear decision function is obtained, and then the decision function is used to classify the pixels in the image to be processed to achieve the purpose of image segmentation.
[0004] However, the training of artificial neural networks requires a large amount of training data, and the data demand is large, and the model training process consumes a lot of computing resources. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide an image segmentation method, apparatus, device and storage medium, which can solve the problem that the current method of image segmentation based on artificial neural network requires a large amount of training data for model training, the data demand is large, and the model training process requires a lot of computing resources.
[0006] In a first aspect, an embodiment of the present application provides an image segmentation method, comprising:
[0007] Acquire multiple consecutive images to be processed;
[0008] Perform boundary recognition on each image to be processed to obtain multiple boundary units;
[0009] Identify adjacent pixels with the same pixel value in each of the images to be processed to obtain a plurality of pixel clusters;
[0010] Tracking the boundary unit and the pixel group in the adjacent image to be processed respectively to obtain reference layer distances of the boundary unit and the pixel group, and dividing the boundary unit and the pixel group into at least one segmentation unit according to the reference layer distance;
[0011] Determine the direction angle between the boundary unit and a plurality of preset vanishing points, analyze the movement change characteristics of the segmentation unit, and segment the image to be processed according to the direction angle and the movement change characteristics of the boundary unit included in the segmentation unit to obtain an image segmentation result.
[0012] Optionally, the step of performing boundary recognition on each image to be processed to obtain a plurality of boundary units includes:
[0013] Traversing each image to be processed according to a preset window, and calculating the color difference between pixels in the preset window;
[0014] When the color difference satisfies a preset boundary condition, the pixel points within the preset window are used as boundary units.
[0015] Optionally, the determining the direction angle between the boundary unit and a plurality of preset vanishing points, analyzing the movement change characteristics of the segmentation unit, and segmenting the image to be processed according to the direction angle and the movement change characteristics of the boundary unit included in the segmentation unit to obtain an image segmentation result includes:
[0016] Determining the direction angle between the boundary unit and a plurality of preset vanishing points, and determining the validity weight of each segmentation unit according to the direction angle of the boundary unit included in the segmentation unit;
[0017] The movement change characteristics of the segmentation unit are analyzed, and the segmentation units whose movement change characteristics and validity weights meet the preset segmentation conditions are segmented from the image to be processed as image segmentation results.
[0018] Optionally, determining the validity weight of each segmentation unit according to the direction angle of the boundary unit included in the segmentation unit includes:
[0019] When the direction angle of the boundary unit is horizontal or vertical, increase the validity weight corresponding to the segmentation unit to which the boundary unit belongs;
[0020] Based on the direction angle, the boundary cells are divided into at least one boundary cell group;
[0021] For each boundary unit group, the angles between the boundary units whose direction angles are not horizontal or vertical are calculated pairwise, and based on the angles and the number of boundary units whose direction angles are not horizontal or vertical, the validity weights corresponding to the segmentation units to which they belong are adjusted; the validity weights are proportional to the size of the angles and the number.
[0022] Optionally, the determining the direction angle between the boundary unit and a plurality of preset vanishing points includes:
[0023] Calculating a histogram parameter of each boundary unit, and dividing the boundary unit into at least one group according to the histogram parameter;
[0024] Determine a horizon and a median line in the image to be processed, and perform sampling on the horizon and the median line at preset intervals to obtain a plurality of vanishing points;
[0025] For each group, the direction angle between the included boundary cells and each vanishing point is calculated.
[0026] Optionally, analyzing the movement change characteristics of the segmentation unit, and segmenting the segmentation unit whose movement change characteristics and validity weight satisfy a preset segmentation condition from the image to be processed as an image segmentation result, includes:
[0027] Analyzing the movement change characteristics of the segmentation unit;
[0028] Segmenting a segmentation unit whose movement change feature satisfies a moving object condition from the image to be processed as a first segmentation result;
[0029] Segmenting the segmentation units whose validity weights satisfy the preset validity conditions from the image to be processed as the second segmentation result;
[0030] The first segmentation result and the second segmentation result are subjected to refinement segmentation processing to obtain an image segmentation result.
[0031] In a second aspect, an embodiment of the present application provides an image segmentation device, including:
[0032] An acquisition module, used for acquiring a plurality of continuous images to be processed;
[0033] A boundary recognition module is used to perform boundary recognition on each image to be processed to obtain multiple boundary units;
[0034] An object recognition module is used to recognize adjacent pixels with the same pixel value in each of the images to be processed to obtain a plurality of pixel clusters;
[0035] A layer segmentation module, used for tracking the boundary unit and the pixel group in the adjacent to-be-processed image, respectively, obtaining a reference layer distance of the boundary unit and the pixel group, and dividing the boundary unit and the pixel group into at least one segmentation unit according to the reference layer distance;
[0036] The segmentation module is used to determine the direction angle between the boundary unit and a plurality of preset vanishing points, and analyze the movement change characteristics of the segmentation unit, and segment the image to be processed according to the direction angle and the movement change characteristics of the boundary unit included in the segmentation unit to obtain an image segmentation result.
[0037] Optionally, the boundary identification module is used to:
[0038] Traversing each image to be processed according to a preset window, and calculating the color difference between pixels in the preset window;
[0039] When the color difference satisfies a preset boundary condition, the pixel points within the preset window are used as boundary units.
[0040] Optionally, the segmentation module is used to:
[0041] Determining the direction angle between the boundary unit and a plurality of preset vanishing points, and determining the validity weight of each segmentation unit according to the direction angle of the boundary unit included in the segmentation unit;
[0042] The movement change characteristics of the segmentation unit are analyzed, and the segmentation units whose movement change characteristics and validity weights meet the preset segmentation conditions are segmented from the image to be processed as image segmentation results.
[0043] Optionally, the segmentation module is used to:
[0044] When the direction angle of the boundary unit is horizontal or vertical, increase the validity weight corresponding to the segmentation unit to which the boundary unit belongs;
[0045] Based on the direction angle, the boundary cells are divided into at least one boundary cell group;
[0046] For each boundary unit group, the angles between the boundary units whose direction angles are not horizontal or vertical are calculated pairwise, and based on the angles and the number of boundary units whose direction angles are not horizontal or vertical, the validity weights corresponding to the segmentation units to which they belong are adjusted; the validity weights are proportional to the size of the angles and the number.
[0047] Optionally, the segmentation module is used to:
[0048] Calculating a histogram parameter of each boundary unit, and dividing the boundary unit into at least one group according to the histogram parameter;
[0049] Determine a horizon and a median line in the image to be processed, and perform sampling on the horizon and the median line at preset intervals to obtain a plurality of vanishing points;
[0050] For each group, the direction angle between the included boundary cells and each vanishing point is calculated.
[0051] Optionally, the segmentation module is used to:
[0052] Analyzing the movement change characteristics of the segmentation unit;
[0053] Segmenting a segmentation unit whose movement change feature satisfies a moving object condition from the image to be processed as a first segmentation result;
[0054] Segmenting the segmentation units whose validity weights satisfy the preset validity conditions from the image to be processed as the second segmentation result;
[0055] The first segmentation result and the second segmentation result are subjected to refinement segmentation processing to obtain an image segmentation result.
[0056] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.
[0057] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0058] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.
[0059] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the first aspect.
[0060] In the solution provided in the embodiment of the present application, an image segmentation method is proposed, which obtains a plurality of continuous images to be processed; performs boundary identification on each image to be processed to obtain a plurality of boundary units; identifies adjacent pixels with the same pixel value in each image to be processed to obtain a plurality of pixel clusters; tracks the boundary units and pixel clusters in adjacent images to be processed to obtain reference layer distances of the boundary units and pixel clusters, and divides the boundary units and pixel clusters into at least one segmentation unit based on the reference layer distance; determines the direction angle between the boundary unit and a plurality of preset vanishing points, and analyzes the movement change characteristics of the segmentation unit, and segments the image to be processed based on the direction angle and movement change characteristics of the boundary unit included in the segmentation unit to obtain an image segmentation result.
[0061] In this way, by simulating the biological vision mechanism and drawing on the principle of painting perspective, multi-point perspective calculations are performed on the image to be processed. At the same time, objects with changing positions are captured in continuously changing adjacent images to be processed, and the primary spatial vector information in the image to be processed is learned. The segmentation units in the image to be processed are identified, and then, based on the identified segmentation units, the spatial vector information of the object is further accurately corrected, thereby realizing image segmentation. In the process of image segmentation, there is no need to rely on a large amount of training data for model training, the data demand is relatively small, and a lot of computing resources can be saved. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] Figure 1 is a flow chart of an image segmentation method according to an exemplary embodiment;
[0063] Figure 2 is a schematic diagram showing a position numbering rule of an image to be processed according to an exemplary embodiment;
[0064] Figure 3 is a schematic diagram showing a layer distance and a camera position according to an exemplary embodiment;
[0065] Figure 4 It is a schematic diagram of a process of efficiently calculating the distance between a layer number and a reference layer through a recursive function according to an exemplary embodiment;
[0066] Figure 5 is a schematic diagram showing a horizon, a median line and a vanishing point in an image to be processed according to an exemplary embodiment;
[0067] Figure 6 is a schematic diagram showing a horizon and a median line setting rule according to an exemplary embodiment;
[0068] Figure 7 is a perspective principle schematic diagram according to an exemplary embodiment;
[0069] Figure 8 is a block diagram of an image segmentation device according to an exemplary embodiment;
[0070] Fig. 9 A block diagram showing a base station terminal accessing an electronic device according to an exemplary embodiment;
[0071] Fig.10 It is a block diagram of a device for terminal access according to an exemplary embodiment. DETAILED DESCRIPTION
[0072] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0073] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0074] The image segmentation method provided in the embodiment of the present application is described in detail below through specific embodiments and their application scenarios in conjunction with the accompanying drawings.
[0075] Figure 1 is a flowchart of an image segmentation method according to an exemplary embodiment. The image segmentation method includes the following steps.
[0076] In step S11, a plurality of continuous images to be processed are obtained.
[0077] Image segmentation is an important branch of image processing and machine vision. Its goal is to divide an image into several semantically or structurally consistent regions or objects. In related technologies, artificial neural network recognition technology is usually used for image segmentation.
[0078] Among them, the basis for image segmentation by artificial neural network is the brightness and color of pixels in the image to be processed. By training the multi-layer perceptron, a linear decision function is obtained, and then the decision function is used to classify the pixels in the image to be processed to achieve the purpose of image segmentation.
[0079] However, the training of artificial neural networks requires a large amount of training data, and the data demand is large, and the model training process consumes a lot of computing resources. Based on this, the present application proposes an image segmentation method to solve the above problem.
[0080] Specifically, the present application can be applied to a server or a terminal. The server can be a local server, other servers in the network, etc., by acquiring multiple consecutive images to be processed, simulating the biological vision mechanism, and drawing on the principle of painting perspective, multi-point perspective calculation is performed on the image to be processed, and the segmentation units in the image to be processed are identified. Then, the effective value weight calculation is further performed on the segmentation units, and the image to be processed is segmented, so as to achieve image segmentation processing of the image to be processed without relying on a large amount of training data for model training.
[0081] The above-mentioned terminal can be a terminal device in various forms such as a mobile phone, a tablet computer, a desktop computer, a portable laptop computer, etc., and the embodiments of the present application are not limited to this.
[0082] The above-mentioned server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), as well as big data and artificial intelligence platforms.
[0083] Among them, cloud technology refers to a hosting technology that unifies hardware, software, network and other resources in a wide area network or local area network to realize data computing, storage, processing and sharing. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool, which is used on demand and flexible and convenient. Cloud computing technology will become an important support. The background services of the technical network system require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the high development and application of the Internet industry, in the future, each item may have its own identification mark, and all need to be transmitted to the background system for logical processing. Data of different levels will be processed separately. All kinds of industry data require strong system backing support, which can only be achieved through cloud computing.
[0084] In some embodiments, the above-mentioned server can also be implemented as a node in a blockchain system. Blockchain is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, the platform product service layer, and the application service layer.
[0085] In this step, first, multiple continuous images to be processed are obtained. The images to be processed are images that need to be segmented. The multiple continuous images to be processed can be continuous video frames, or multiple continuous key frames in video frames, or multiple images in a dynamic image group, etc. This application does not make any specific limitations on this.
[0086] In step S12, boundary recognition is performed on each image to be processed to obtain a plurality of boundary units.
[0087] In this step, boundary recognition processing can be performed on each image to be processed, and the boundary area of each object included in the image to be processed can be identified to obtain a plurality of boundary units, which are then used for object recognition and segmentation.
[0088] For example, if the image to be processed is a road monitoring image, then the boundary between the vehicle and the road, or the boundary between the road and the green belt or the sidewalk in the image to be processed can be identified as boundary units.
[0089] Among them, various algorithms such as histogram-based, filter-based, gradient-based, etc. can be used to perform boundary recognition on the image to be processed, and this application does not make any specific limitations on this.
[0090] In one implementation, each image to be processed is subjected to boundary recognition to obtain a plurality of boundary units, including:
[0091] Traverse each image to be processed according to the preset window and calculate the color difference between the pixels in the preset window;
[0092] When the color difference meets the preset boundary conditions, the pixels within the preset window are used as boundary units.
[0093] That is to say, the histogram method can be applied to perform boundary recognition on the image to be processed. First, the image to be processed is traversed according to the preset window. The preset window can be determined based on a preset value or the clarity of the image to be processed. The higher the clarity of the image to be processed and the greater the pixel density, the smaller the preset window can be. For example, the preset window can be 9 pixels, that is, a 9-grid; then, the color and intensity distribution of the pixels included in the preset window can be calculated to determine the color difference between the pixels in the preset window. If the color difference meets the preset boundary condition, the pixels in the preset window can be used as a boundary unit.
[0094] Among them, the color difference meeting the preset boundary condition may mean that the color difference exceeds a preset threshold, or may mean that the color difference is ranked in the top few places from large to small, and this application does not specifically limit this.
[0095] In step S13, adjacent pixels with the same pixel value in each image to be processed are identified to obtain a plurality of pixel clusters.
[0096] In this step, adjacent pixels with the same pixel value in each image to be processed are identified. That is to say, for each pixel in the image to be processed, if the pixel value is the same as that of another adjacent pixel, then the pixel and the other pixels are likely to be from the same object. Therefore, the pixel is divided into the group to which the other pixels belong. In this way, multiple pixel clusters can be obtained.
[0097] For example, each frame of the image to be processed can be read in sequence. Assuming that the image to be processed is the i-th image Fi, all pixels are divided into multiple pixel groups according to the grouping principle that pixels adjacent to each other and having the same color are in the same group. The groups are represented as pixel group i [color value, number of pixels, position parameter], where the same color means that the red, green and blue components are all the same. The position parameter is represented as position [position number 1 (a1, b1), position number 2...], and the position number is to divide the image to be processed into m×n position areas in a grid shape, with the center point of the image numbered (0, 0). The numbering rule is as follows: Figure 2 shown.
[0098] In step S14, the boundary units and pixel clusters are tracked in adjacent images to be processed, respectively, to obtain reference layer distances of the boundary units and pixel clusters, and the boundary units and pixel clusters are divided into at least one segmentation unit according to the reference layer distances.
[0099] It can be understood that a frame of the image to be processed includes multiple pixel clusters and multiple boundary units. In this step, the changes in the number of pixels and position parameters of each boundary unit and pixel cluster included in the adjacent images to be processed are compared in sequence to determine the reference layer distance of the boundary unit and the pixel cluster.
[0100] Among them, Figure 3 As shown in FIG. 1 , it is a schematic diagram of layer distance and camera position. The change in the number of pixels of the boundary unit and the pixel group reflects the change in the front-to-back distance of the boundary unit and the pixel group, and the change in position reflects the change in displacement up, down, left, and right. The farther the pixel group is, the smaller the change in the number of pixels and the position is. For example, the distant mountains and the starry sky far away from the camera position in the image to be processed remain basically unchanged, while the pedestrians or vehicles close to the camera position change greatly. Therefore, based on the change data of each boundary unit and pixel group in each frame, the reference layer distance of each boundary unit and pixel group in each frame can be calculated, which is expressed as: reference layer distance [layer number, layer distance], where the numbers are 1, 2, 3, ... from near to far.
[0101] Among them, the reference layer distance algorithm is as follows:
[0102] Assume that the change in the number of pixels of pixel cluster 1 from the image to be processed Fi to Fi+1 is Δa, where an increase in the number is positive and a decrease in the number is negative; the displacement relative to the center point is Δb, where a departure from the center point is positive and a decrease in the number is negative; then the layer distance Di1 of pixel cluster 1 of the image to be processed Fi is:
[0103] Di1=Δa×distance coefficient Ca+Δb×distance coefficient Cb
[0104] Among them, the distance coefficients Ca and Cb can be set as functions containing angle factors, which can improve the calculation accuracy of the layer distance. The detailed calculation formula can refer to the parallax formula of geometric theory, and this application does not make any specific limitations on this.
[0105] In this step, after determining the reference layer distance of the boundary unit and pixel cluster, a layer distance threshold can be set to classify all boundary units and pixel clusters with approximately equal reference layer distance D into one layer. Furthermore, boundary units and pixel clusters with large step changes can be eliminated to reduce noise and interference.
[0106] Furthermore, in the present application, a recursive function can be used to efficiently calculate the layer number and the reference layer distance. The reference layer distances of all boundary units and pixel groups are first calculated layer by layer, and then the layer number is recursively derived layer by layer according to the distance.
[0107] For example, assuming that the image to be processed Fi includes 5 pixel clusters, the operation effect of this recursive function is as follows: Figure 4 shown.
[0108] In step S15, the direction angle between the boundary unit and the preset multiple vanishing points is determined, and the movement change characteristics of the segmentation unit are analyzed. The image to be processed is segmented according to the direction angle and movement change characteristics of the boundary unit included in the segmentation unit to obtain an image segmentation result.
[0109] In this step, drawing on the principle of perspective in painting, based on multiple preset vanishing points, multi-point perspective calculation is performed on the boundary unit to determine its direction angle, and then combined with the movement and change characteristics of the segmentation unit, the obtained boundary unit data set: vanishing point 1 […], vanishing point 2 […]… vanishing point n […], and the obtained segmentation unit characterization parameters: [layer number, [pixel group 1, pixel group 2…]] are integrated to further correct the reference layer distance of the segmentation unit, and then the parameters are judged and the image is segmented in turn. The image to be processed is segmented to obtain the image segmentation result.
[0110] It can be understood that by simulating the principle of vision, the camera simulates the human eye. In scene 1, when the camera moves left, right, up, or down, the static object being observed will undergo displacement changes in the camera's image. The closer the distance and the closer to the center of sight, the more obvious the displacement. In scene 2, when the camera is stationary, the object being viewed moves back and forth, left, right, up, or down, and the size and mutual distance of the pixel units that make up the object will change. This change data can be used to calculate and analyze which pixels belong to the same object, as well as the distance and angle change information of the object.
[0111] In one implementation, the direction angle between the boundary unit and a plurality of preset vanishing points is determined, and the movement change characteristics of the segmentation unit are analyzed. The image to be processed is segmented according to the direction angle and the movement change characteristics of the boundary unit included in the segmentation unit to obtain the image segmentation result, including:
[0112] Determine the direction angle between the boundary unit and a plurality of preset vanishing points, and determine the validity weight of each segmentation unit according to the direction angle of the boundary unit included in the segmentation unit;
[0113] The moving change characteristics of the segmentation unit are analyzed, and the segmentation units whose moving change characteristics and validity weights meet the preset segmentation conditions are segmented from the image to be processed as the image segmentation result.
[0114] That is to say, the effectiveness weight of each segmentation unit can be determined by the direction angle between the boundary unit and multiple preset vanishing points. At the same time, by horizontally comparing the adjacent images to be processed, the movement change characteristics of each segmentation unit can be calculated and analyzed, including factors such as the continuity, integrity, and change speed and direction of the change.
[0115] Then, it can be determined which segmentation units are in the same layer, which segmentation units are stationary, which segmentation units are moving, and which segmentation units are stationary backgrounds. Then, each frame of the image to be processed is segmented and classified. The higher the validity weight of the pixel group, the stronger the layer distance reliability. Therefore, adjacent segmentation units of the same layer with continuous gradient distance are segmented together, and the segmentation units judged to be moving are given the highest priority, followed by the segmentation units with high validity weights.
[0116] In one implementation, determining the validity weight of each segmentation unit according to the direction angle of the boundary unit included in the segmentation unit includes:
[0117] When the direction angle of the boundary cell is horizontal or vertical, the validity weight corresponding to the segmentation cell to which the boundary cell belongs is increased;
[0118] Based on the direction angle, the boundary cells are divided into at least one boundary cell group;
[0119] For each boundary unit group, the angles between the boundary units whose direction angles are not horizontal or vertical are calculated pairwise, and based on the angle and the number of boundary units whose direction angles are not horizontal or vertical, the validity weight corresponding to the corresponding segmentation unit is adjusted; the validity weight is proportional to the size and number of the angle.
[0120] That is, if the direction angle of the boundary cell is horizontal or vertical, the segmentation cells at the same reference layer distance as the boundary cell, that is, the segmentation cells in the same layer as the boundary cell, have a higher validity weight.
[0121] At the same time, the boundary units whose direction angles corresponding to the vanishing point n[…] are not horizontal or vertical can be traversed and screened out, and the angles between these boundary units, that is, the difference in direction angles, are calculated two by two. The larger the angle, the closer to the camera position. The segmentation units with the same distance from the reference layer of each boundary unit, that is, the validity weights of the segmentation units in the same layer as each boundary unit, are corrected in turn.
[0122] In addition, for each segmentation unit, the greater the number of boundary units with the same distance to its reference layer, the higher its validity weight.
[0123] In one implementation, determining the direction angle between the boundary unit and a plurality of preset vanishing points includes:
[0124] Calculating a histogram parameter of each boundary unit, and dividing the boundary unit into at least one group according to the histogram parameter;
[0125] Determine the horizon and the median line in the image to be processed, and perform sampling on the horizon and the median line at a preset interval to obtain a plurality of vanishing points;
[0126] For each group, the direction angle between the included boundary cells and each vanishing point is calculated.
[0127] That is, the parameters assigned to the boundary cells are:
[0128] ① Position parameters (X, Y);
[0129] ②Use cv2.calcHist (find histogram) to obtain the histogram parameters, expressed as:
[0130] hist=cv.calcHist([img],[0],None,
[256] ,[0,256]);
[0131] where hist is a 256x1 array, and each value corresponds to the number of pixels in the image that have the corresponding pixel value.
[0132] Furthermore, the boundary cells can be divided into multiple groups according to the principle of the same or similar histogram parameters (hist). For each boundary cell in each group, the vector coordinates (direction angle A, distance D) are calculated based on the position parameters (X, Y) and the perspective vanishing point as the center of the coordinate circle.
[0133] like Figure 5 As shown in FIG. 1 , it is a schematic diagram of the horizon, median line and vanishing point in the image to be processed, wherein the intersection of the horizon and the median line is the perspective vanishing point, which is the coordinate origin of the boundary unit vector coordinates, the distance D is the length from the boundary unit to the origin, and the direction angle A is the angle from the horizon to the boundary unit counterclockwise.
[0134] like Figure 6 As shown in the figure, the setting rules of the horizon and the median are as follows: first, the horizontal line in the center of the image is taken as the horizon, and the vertical line is taken as the median. The vector coordinates of all boundary cells are calculated and saved. The boundary cells with the same and similar histogram parameters are taken as a group. In the same group, more than two boundary cells with the same direction angle are screened out and recorded as: vanishing point 1 [boundary cell group 1 [vector angle A1 [boundary cell 1.1, boundary cell 1.2…], vector angle A2 [boundary cell 2.1, boundary cell 2.2…]…], boundary cell group 2 [vector angle A1 [boundary cell 1.1, boundary cell 1.2…], vector angle A2 [boundary cell 2.1, boundary cell 2.2…]…]…], and temporarily stored in the data set.
[0135] Then, the vanishing point is moved left and right on this horizon by a predetermined unit distance, that is, the median line is translated. Each time the vanishing point is changed, the above vector coordinate calculation process is repeated. The moving vanishing point on the horizon is allowed to exceed the left and right boundaries of the image. The amount of excess can be preset. If it exceeds too much, it will not contribute much to the use of the calculation result. After the vanishing point on this horizon is calculated, the horizon is moved up and down in the vertical direction by a predetermined unit distance. The horizon movement is also allowed to exceed the upper and lower boundaries of the image. The amount of excess can be preset. If it exceeds too much, it will not contribute much to the use of the calculation result. Each time the horizon is changed, the above vanishing point translation and vector coordinate calculation process are repeated and temporarily stored in the data set. Finally, a set of boundary unit data of the same group and the same direction angle of all corresponding vanishing points is obtained: vanishing point 1[…], vanishing point 2[…]… vanishing point n[…].
[0136] like Figure 7 As shown, it is a schematic diagram of the perspective principle. This application simulates the biological vision mechanism, draws on the perspective method of painting, introduces reference quantities such as the horizon, the center line, the vanishing point, etc. in the perspective method, and performs multi-point perspective calculation on the segmented units in the processed image.
[0137] In one implementation, the moving change characteristics of the segmentation unit are analyzed, and the segmentation unit whose moving change characteristics and validity weight meet the preset segmentation conditions is segmented from the image to be processed as the image segmentation result, including:
[0138] Analyze the movement and change characteristics of the segmentation unit;
[0139] Segmenting a segmentation unit whose moving change feature satisfies the moving object condition from the image to be processed as a first segmentation result;
[0140] Segmenting the segmentation units whose validity weights satisfy the preset validity conditions from the image to be processed as the second segmentation result;
[0141] The first segmentation result and the second segmentation result are subjected to refinement segmentation processing to obtain an image segmentation result.
[0142] That is to say, after segmenting each image component according to the layer distance classification rule, the traditional image segmentation technology can be used to further refine the image segmentation. For example, grayscale threshold segmentation, region splitting and merging, edge segmentation, histogram method and other image segmentation algorithms can be used. This application does not make any specific limitations on this.
[0143] Furthermore, a double-embedded recursive calculation method can be used to nest the above pixel group layer numbering recursive function in a recursive function of frame image traversal operation. The operating characteristics are similar, and the effect is to run the pixel group, boundary unit, and three-dimensional vector calculation programs of each frame image layer by layer. After traversing all frames, the image segmentation program of each frame image is calculated layer by layer from back to front, making the program code more efficient.
[0144] From the above, it can be seen that the technical solution provided by the embodiment of the present application, by simulating the biological vision mechanism and drawing on the principle of perspective in painting, performs multi-point perspective calculation on the image to be processed. At the same time, it captures objects with changing positions in continuously changing adjacent images to be processed, learns the primary spatial vector information in the image to be processed, identifies the segmentation units in the image to be processed, and then, based on the identified segmentation units, further accurately corrects the spatial vector information of the object, thereby realizing image segmentation. In the process of image segmentation, there is no need to rely on a large amount of training data for model training, the data demand is relatively small, and a large amount of computing resources can be saved.
[0145] The image segmentation method provided in the embodiment of the present application can be executed by an image segmentation device. In the embodiment of the present application, the method of executing terminal access by an image segmentation device is taken as an example to illustrate the device of the image segmentation method provided in the embodiment of the present application.
[0146] Figure 8 is a block diagram of an image segmentation device according to an exemplary embodiment, comprising:
[0147] An acquisition module 201 is used to acquire a plurality of continuous images to be processed;
[0148] The boundary recognition module 202 is used to perform boundary recognition on each image to be processed to obtain a plurality of boundary units;
[0149] An object recognition module 203 is used to recognize adjacent pixels with the same pixel value in each of the images to be processed to obtain a plurality of pixel clusters;
[0150] A layer segmentation module 204 is used to track the boundary unit and the pixel group in the adjacent image to be processed, obtain reference layer distances of the boundary unit and the pixel group, and divide the boundary unit and the pixel group into at least one segmentation unit according to the reference layer distance;
[0151] The segmentation module 205 is used to determine the direction angle between the boundary unit and a plurality of preset vanishing points, and analyze the movement change characteristics of the segmentation unit, and segment the image to be processed according to the direction angle and the movement change characteristics of the boundary unit included in the segmentation unit to obtain an image segmentation result.
[0152] Optionally, the boundary identification module 202 is used to:
[0153] Traversing each image to be processed according to a preset window, and calculating the color difference between pixels in the preset window;
[0154] When the color difference satisfies a preset boundary condition, the pixel points within the preset window are used as boundary units.
[0155] Optionally, the segmentation module 205 is used to:
[0156] Determining the direction angle between the boundary unit and a plurality of preset vanishing points, and determining the validity weight of each segmentation unit according to the direction angle of the boundary unit included in the segmentation unit;
[0157] The movement change characteristics of the segmentation unit are analyzed, and the segmentation units whose movement change characteristics and validity weights meet the preset segmentation conditions are segmented from the image to be processed as image segmentation results.
[0158] Optionally, the segmentation module 205 is used to:
[0159] When the direction angle of the boundary unit is horizontal or vertical, increase the validity weight corresponding to the segmentation unit to which the boundary unit belongs;
[0160] Based on the direction angle, the boundary cells are divided into at least one boundary cell group;
[0161] For each boundary unit group, the angles between the boundary units whose direction angles are not horizontal or vertical are calculated pairwise, and based on the angles and the number of boundary units whose direction angles are not horizontal or vertical, the validity weights corresponding to the segmentation units to which they belong are adjusted; the validity weights are proportional to the size of the angles and the number.
[0162] Optionally, the segmentation module 205 is used to:
[0163] Calculating a histogram parameter of each boundary unit, and dividing the boundary unit into at least one group according to the histogram parameter;
[0164] Determine a horizon and a median line in the image to be processed, and perform sampling on the horizon and the median line at preset intervals to obtain a plurality of vanishing points;
[0165] For each group, the direction angle between the included boundary cells and each vanishing point is calculated.
[0166] Optionally, the segmentation module 205 is used to:
[0167] Analyzing the movement change characteristics of the segmentation unit;
[0168] Segmenting a segmentation unit whose movement change feature satisfies a moving object condition from the image to be processed as a first segmentation result;
[0169] Segmenting the segmentation units whose validity weights satisfy the preset validity conditions from the image to be processed as the second segmentation result;
[0170] The first segmentation result and the second segmentation result are subjected to refinement segmentation processing to obtain an image segmentation result.
[0171] From the above, it can be seen that the technical solution provided by the embodiment of the present application, by simulating the biological vision mechanism and drawing on the principle of perspective in painting, performs multi-point perspective calculation on the image to be processed. At the same time, it captures objects with changing positions in continuously changing adjacent images to be processed, learns the primary spatial vector information in the image to be processed, identifies the segmentation units in the image to be processed, and then, based on the identified segmentation units, further accurately corrects the spatial vector information of the object, thereby realizing image segmentation. In the process of image segmentation, there is no need to rely on a large amount of training data for model training, the data demand is relatively small, and a large amount of computing resources can be saved.
[0172] The image segmentation method provided in the embodiment of the present application can be executed by a terminal access terminal. In the embodiment of the present application, a method in which a terminal access terminal executes terminal access is taken as an example to illustrate the apparatus of the image segmentation method provided in the embodiment of the present application.
[0173] The image segmentation device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a car electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0174] The image segmentation device provided in the embodiment of the present application can achieve Figures 1 to 3 To avoid repetition, the various processes implemented by the method embodiment are not described here.
[0175] Alternatively, if Fig. 9 As shown, an embodiment of the present application also provides an electronic device 500, including a processor 501 and a memory 502, wherein the memory 502 stores programs or instructions that can be executed on the processor 501, and when the program or instructions are executed by the processor 501, the various steps of the above-mentioned image segmentation method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, they are not described here.
[0176] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0177] Fig.10 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.
[0178] The electronic device 1000 includes but is not limited to: a radio frequency unit 1001, a network module 1002, an audio output unit 1003, an input unit 1004, a sensor 1005, a display unit 1006, a user input unit 1007, an interface unit 1008, a memory 1009, and a processor 1010 and other components.
[0179] Those skilled in the art will appreciate that the electronic device 1000 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 1010 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Fig.10 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0180] From the above, it can be seen that the technical solution provided by the embodiment of the present application, by simulating the biological vision mechanism and drawing on the principle of perspective in painting, performs multi-point perspective calculation on the image to be processed. At the same time, it captures objects with changing positions in continuously changing adjacent images to be processed, learns the primary spatial vector information in the image to be processed, identifies the segmentation units in the image to be processed, and then, based on the identified segmentation units, further accurately corrects the spatial vector information of the object, thereby realizing image segmentation. In the process of image segmentation, there is no need to rely on a large amount of training data for model training, the data demand is relatively small, and a large amount of computing resources can be saved.
[0181] It should be understood that in the embodiment of the present application, the input unit 1004 may include a graphics processor (Graphics Processing Unit, GPU) 10041 and a microphone 10042, and the graphics processor 10041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 1006 may include a display panel 10061, and the display panel 10061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 1007 includes a touch panel 10071 and at least one of other input devices 10072. The touch panel 10071 is also called a touch screen. The touch panel 10071 may include two parts: a touch detection device and a touch controller. Other input devices 10072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
[0182] The memory 1009 can be used to store software programs and various data. The memory 1009 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 1009 may include a volatile memory or a non-volatile memory, or the memory 1009 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 109 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0183] The processor 1010 may include one or more processing units; optionally, the processor 1010 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 1010.
[0184] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned image segmentation method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0185] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0186] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned image segmentation method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0187] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0188] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned image segmentation method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0189] It should be noted that, in this article, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises one..." does not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be noted that the scope of the method and device in the embodiment of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0190] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0191] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. An image segmentation method, characterized in that: include: Acquire multiple consecutive images to be processed; Perform boundary recognition on each image to be processed to obtain multiple boundary units; Identify adjacent pixels with the same pixel value in each of the images to be processed to obtain a plurality of pixel clusters; Tracking the boundary unit and the pixel group in the adjacent image to be processed respectively to obtain reference layer distances of the boundary unit and the pixel group, and dividing the boundary unit and the pixel group into at least one segmentation unit according to the reference layer distance; Determine the direction angle between the boundary unit and a plurality of preset vanishing points, analyze the movement change characteristics of the segmentation unit, and segment the image to be processed according to the direction angle and the movement change characteristics of the boundary unit included in the segmentation unit to obtain an image segmentation result.
2. The image segmentation method according to claim 1, characterized in that: The step of performing boundary recognition on each image to be processed to obtain a plurality of boundary units includes: Traversing each image to be processed according to a preset window, and calculating the color difference between pixels in the preset window; When the color difference satisfies a preset boundary condition, the pixel points within the preset window are used as boundary units.
3. The image segmentation method according to claim 1, characterized in that: The determining of the direction angle between the boundary unit and a plurality of preset vanishing points, analyzing the movement change characteristics of the segmentation unit, and segmenting the image to be processed according to the direction angle and the movement change characteristics of the boundary unit included in the segmentation unit to obtain an image segmentation result includes: Determining the direction angle between the boundary unit and a plurality of preset vanishing points, and determining the validity weight of each segmentation unit according to the direction angle of the boundary unit included in the segmentation unit; The movement change characteristics of the segmentation unit are analyzed, and the segmentation units whose movement change characteristics and validity weights meet the preset segmentation conditions are segmented from the image to be processed as image segmentation results.
4. The image segmentation method according to claim 3, characterized in that: The determining the validity weight of each segmentation unit according to the direction angle of the boundary unit included in the segmentation unit includes: When the direction angle of the boundary unit is horizontal or vertical, increase the validity weight corresponding to the segmentation unit to which the boundary unit belongs; Based on the direction angle, the boundary cells are divided into at least one boundary cell group; For each boundary unit group, the angles between the boundary units whose direction angles are not horizontal or vertical are calculated pairwise, and based on the angles and the number of boundary units whose direction angles are not horizontal or vertical, the validity weights corresponding to the segmentation units to which they belong are adjusted; the validity weights are proportional to the size of the angles and the number.
5. The image segmentation method according to claim 4, characterized in that: The determining of the direction angle between the boundary unit and a plurality of preset vanishing points includes: Calculating a histogram parameter of each boundary unit, and dividing the boundary unit into at least one group according to the histogram parameter; Determine a horizon and a median line in the image to be processed, and perform sampling on the horizon and the median line at preset intervals to obtain a plurality of vanishing points; For each group, the direction angle between the included boundary cells and each vanishing point is calculated.
6. The image segmentation method according to claim 3, characterized in that: The analyzing the movement change characteristics of the segmentation unit and segmenting the segmentation unit whose movement change characteristics and validity weight satisfy the preset segmentation condition from the image to be processed as the image segmentation result includes: Analyzing the movement change characteristics of the segmentation unit; Segmenting a segmentation unit whose movement change feature satisfies a moving object condition from the image to be processed as a first segmentation result; Segmenting the segmentation units whose validity weights satisfy the preset validity conditions from the image to be processed as the second segmentation result; The first segmentation result and the second segmentation result are subjected to refinement segmentation processing to obtain an image segmentation result.
7. An image segmentation device, characterized in that: include: An acquisition module, used for acquiring a plurality of continuous images to be processed; A boundary recognition module is used to perform boundary recognition on each image to be processed to obtain multiple boundary units; An object recognition module is used to recognize adjacent pixels with the same pixel value in each of the images to be processed to obtain a plurality of pixel clusters; A layer segmentation module, used for tracking the boundary unit and the pixel group in the adjacent to-be-processed image, respectively, obtaining a reference layer distance of the boundary unit and the pixel group, and dividing the boundary unit and the pixel group into at least one segmentation unit according to the reference layer distance; The segmentation module is used to determine the direction angle between the boundary unit and a plurality of preset vanishing points, and analyze the movement change characteristics of the segmentation unit, and segment the image to be processed according to the direction angle and the movement change characteristics of the boundary unit included in the segmentation unit to obtain an image segmentation result.
8. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the image segmentation method according to any one of claims 1 to 6.
9. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the image segmentation method according to any one of claims 1 to 6 are implemented.
10. A computer program product, the program product being stored in a storage medium, and the program product being executed by at least one processor to implement the image segmentation method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Image boundary recognition method, device, equipment, system and storage medium
CN113781512A
Image segmentation method and device
CN117876387A
Image segmentation method and device, and three-dimensional reconstruction method and device for image
WO2022052032A1
