Image processing method, electronic device, storage medium and program product
Through the image processing method of building images, which performs expansion processing, grayscale processing and contour recognition, the problems of low manual measurement efficiency and poor accuracy in the prior art are solved, efficient and accurate building contour recognition is achieved, and the results are converted into latitude and longitude, which is suitable for large-scale urban projects.
Patent Information
- Application Number
- CN202411764553.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-04-01
AI Technical Summary
The existing methods of manual measurement and outline are inefficient, making it difficult to accurately identify disturbing factors in the environment, resulting in inaccurate acquisition of building profile information and cannot be suitable for the needs of large-scale urban projects.
An image processing method is proposed, by expanding the first set of pixels in the first image to obtain the second set of pixels; then, grayscale processing is performed on each pixel point in the second set of pixels and rendering it into a white image; finally, a contour recognition tool is called to contour recognition on the binary image, redundant points are eliminated, and a contour point set is obtained.
It improves the accuracy and efficiency of building profile information, overcomes the problems of light and environmental interference, and the obtained profile is smoother and more realistic, and can be converted into latitude and longitude, suitable for a wider range of application scenarios.
Smart Images

Figure CN119741503A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to technical fields such as data processing, and in particular to an image processing method, electronic equipment, storage medium, and program product. Background Art
[0002] In order to more efficiently promote urban planning, building management and security monitoring, it is particularly important to accurately obtain the outline information of buildings. However, the existing methods of manual measurement and outlining are inefficient and not suitable for large-scale urban projects. In addition, when manually obtaining outline information, it is difficult to accurately identify interference factors in the environment, and the error between the obtained results and the actual outline is large, which is not suitable as data support for urban construction. Summary of the invention
[0003] The present disclosure provides an image processing method, an electronic device, a storage medium, and a program product.
[0004] According to one aspect of the present disclosure, there is provided an image processing method, comprising: performing dilation processing on a first pixel set in a first image to obtain a second pixel set, wherein the first pixel set includes a plurality of first pixel points whose color values are within a target range in the first image, and the second pixel set includes the first pixel set and a plurality of dilated pixel points, wherein the dilated pixel points are pixel points in the neighborhood of the first pixel points; performing grayscale processing on each pixel point in the second pixel set to obtain a second image, wherein the second image includes a background portion and a target object portion corresponding to the second pixel set; and performing contour recognition on the second image to obtain a contour point set, wherein the contour point set includes pixel points in the target object portion that are adjacent to the background portion.
[0005] In some embodiments, a first pixel set in a first image is expanded to obtain a second pixel set, including: superimposing a horizontal axis expansion coefficient on both sides of the horizontal coordinate of the first pixel point to obtain a horizontal coordinate range, the horizontal axis expansion coefficient indicating the number of unit coordinates expanded on one side of the horizontal coordinate in the horizontal direction; superimposing a vertical axis expansion coefficient on both sides of the vertical coordinate of the first pixel point to obtain a vertical coordinate range, the vertical axis expansion coefficient indicating the number of unit coordinates expanded on one side of the vertical coordinate in the vertical direction; in the first image, determining a plurality of expanded pixel points whose image coordinates fall within the horizontal coordinate range and the vertical coordinate range and do not belong to the first pixel set; and obtaining a second pixel set based on the first pixel set and the plurality of expanded pixel points.
[0006] In some embodiments, obtaining a second image includes: establishing a white image; converting color features of pixels in the second pixel set into grayscale values, wherein the grayscale values are used to affect the brightness of corresponding pixels; rendering the target object portion in the white image according to the image position of each pixel in the second pixel set and the grayscale value; and obtaining a second image including the target object portion and a background portion, wherein the background portion is an area in the white image that is not covered by the target object portion.
[0007] In some embodiments, obtaining a second image further includes: adjusting the grayscale value of the pixel points in the target object portion to a black grayscale value; converting the pixel points in the background portion from a white color feature to a white grayscale value; obtaining the second image, in which the target object portion has a black grayscale value and the background portion has a white grayscale value.
[0008] In some embodiments, contour recognition is performed on the second image to obtain a contour point set, including: calling a contour recognition tool to determine a first contour point set in the second image, the first contour point set including all pixel points in the target object portion that are adjacent to the background portion; according to a simplification coefficient, redundant points in the first contour point set are eliminated to obtain a second contour point set, the simplification coefficient represents the difference between the shape of the original contour and the shape of the simplified contour, the original contour is the target object contour corresponding to the first contour point set, the simplified contour is the target object contour corresponding to the second contour point set, the simplification coefficient is proportional to the difference, wherein the redundant points are pixel points that do not constitute the shape of the original contour; and converting the image coordinates of each pixel point in the second contour point set into a floating point format to obtain the contour point set.
[0009] In some embodiments, before dilating a first pixel set in a first image to obtain a second pixel set, the process includes: determining a first pixel point in the first image whose color characteristics meet color requirements to obtain the first pixel set, wherein the color characteristics of the pixel point include a red channel value, a green channel value, and a blue channel value of the pixel point, and the color requirement is determined based on the color characteristics of a target object in the first image, and the color requirement includes a red channel value range, a green channel value range, and a blue channel value range.
[0010] In some embodiments, after performing contour recognition on the second image to obtain a contour point set, the method includes: determining the longitude and latitude of each pixel point in the contour point set based on the longitude and latitude of the reference point in the first image and the image coordinates, and obtaining contour point longitude and latitude data, wherein the contour point longitude and latitude data includes the longitude and latitude of each contour point in the contour point set.
[0011] According to another aspect of the present disclosure, an electronic device is provided, comprising: a memory storing execution instructions; and a processor executing the execution instructions stored in the memory, so that the processor executes the image processing method of any one of the above-mentioned embodiments.
[0012] According to another aspect of the present disclosure, a readable storage medium is provided, in which execution instructions are stored. When the execution instructions are executed by a processor, they are used to implement the image processing method of any of the above-mentioned embodiments.
[0013] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the image processing method of any of the above embodiments is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] The accompanying drawings illustrate exemplary embodiments of the present disclosure and together with the description serve to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification.
[0015] Figure 1 It is a schematic diagram of an application scenario of the image processing method according to an embodiment of the present disclosure.
[0016] Figure 2 It is a schematic diagram of a process of obtaining a contour point set according to an embodiment of the present disclosure.
[0017] Figure 3 is a first image schematic diagram according to an embodiment of the present disclosure.
[0018] Figure 4 It is a grayscale image obtained by grayscale processing of the first image according to an embodiment of the present disclosure.
[0019] Figure 5 is a schematic diagram of a second image according to an embodiment of the present disclosure.
[0020] Figure 6 is a contour schematic diagram determined by a first contour point set according to an embodiment of the present disclosure.
[0021] Figure 7 is a contour schematic diagram determined by a second contour point set according to an embodiment of the present disclosure.
[0022] Figure 8 is a flow chart of an image processing method according to an embodiment of the present disclosure.
[0023] Fig. 9 It is a schematic block diagram of the structure of an image processing device according to one embodiment of the present disclosure.
[0024] Fig.10 The present invention is a block diagram showing a structure of an electronic device equipped with an image processing device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0025] The present disclosure is further described in detail below in conjunction with the accompanying drawings and examples. It is understood that the specific examples described herein are only used to explain the relevant content, rather than to limit the present disclosure. It should also be noted that, for ease of description, only the parts related to the present disclosure are shown in the accompanying drawings.
[0026] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in the present disclosure can be combined with each other. The technical solution of the present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0027] Accurately determining the outline information of buildings is an important part of urban construction. In related technologies, the developer of the building provides a bird's-eye view of the building, and then manually eliminates interference factors such as vegetation and roads in the bird's-eye view, identifies the outline of the building in the bird's-eye view, and manually draws the outline of the building. Obviously, when manually obtaining the outline, it is difficult to accurately determine the longitude and latitude information of the outline in the world coordinate system, and it is also difficult to accurately eliminate interference factors in the environment; moreover, it is inefficient and not suitable for large-scale urban projects.
[0028] To this end, the present disclosure proposes an image processing method.
[0029] Figure 1 Schematic diagram of an application scenario of the image processing method according to an embodiment of the present disclosure. Figure 1 As shown, the application scenario may include a server 100 and a terminal device 200. The server 100 may be a cloud server or a physical server, and the terminal device 200 may be a mobile phone, a computer or other device. The server 100 and the terminal device 200 communicate with each other through a network or other means.
[0030] The server 100 runs an image processing method. When the terminal device 200 responds to the user's instruction to obtain the contour information of the first image, the server 100 performs the following steps: dilate the first pixel set in the obtained first image to obtain the second pixel set; then, convert the color features of each pixel point in the second pixel set into a grayscale value, and render it into a white image to obtain a grayscale image; further, binarize the grayscale image to convert it into a second image in black and white; further, call the contour recognition tool to identify the first contour point set of the second image, and remove the redundant points in the first contour point set to obtain the second contour point set; finally, adjust the second contour point set to a floating point format to obtain a contour point set, wherein the contour point set includes the image coordinates of the pixel points on the contour of the target object included in the first image, where the target object can be a building. The server 100 can also convert the image coordinates of each pixel point in the contour point set into longitude and latitude coordinates according to the image coordinates and longitude and latitude coordinates of the reference point in the first image, so that the obtained contour point set is suitable for a wider range of application scenarios. The server 100 can also generate a contour structure image of the target object according to the contour point set, so that the user can intuitively understand the contour shape of the target object. The server 100 synchronizes the obtained contour point set and other derivative results to the terminal device 200 through a network or other means, and the terminal device 200 can display these contents on a display screen for the user to view.
[0031] The server 100 runs the image processing method, and by expanding the first pixel set, it compensates for the incomplete pixel collection of the target object due to light and other problems, and overcomes the interference of environmental factors such as vegetation on the recognition of the target object. The color features of the second pixel set are adjusted to grayscale values and rendered to a blank image, and then the obtained grayscale image is binarized, so that the obtained second image pays more attention to the boundary position between the target part and the background part, and eliminates the interference of the internal structure of the target part on the contour recognition. Finally, by eliminating redundant points, a contour point set is obtained, and the contour drawn by the contour point set is smoother and more realistic. In addition, the contour point set can be converted into longitude and latitude, which expands the scenarios applicable to the contour point set.
[0032] Figure 2 is a schematic diagram of a flow chart of obtaining a contour point set according to an embodiment of the present disclosure. Figure 2 right Figure 1 The solution in which the server obtains a set of contour points through an image processing method is described.
[0033] The first image is analyzed according to a user's instruction to recognize contour information of the first image. Figure 3 is a first image schematic diagram according to an embodiment of the present disclosure. Figure 3As shown, the first image shows a top view of a building in a certain area, including a building part and an environment part. In the first image, parts with different functional attributes are represented by different colors, for example, residential buildings are represented by light brown, roads, storefronts, etc. are represented by gray, vegetation, grass, etc. are represented by green, and the remaining functional parts can be represented by pink, blue, and other colors. Obviously, the buildings and the environment in the first image are highly integrated, especially the colors of roads and storefronts are similar to those of residential buildings, and it is difficult to accurately identify the outline of the buildings manually. It should be noted that the first image can use other colors to represent parts with the same functional attributes, all of which fall within the protection scope of the present disclosure.
[0034] The first image can be provided by the developer, or obtained by preprocessing an image collected by a camera or other collection device. The first image can be a static photo or a video frame. In addition, in this embodiment, a bird's-eye view of a residential building in a certain area is used as the first image, and a residential building is used as the target object of the contour to be identified, but the target object is not limited to buildings such as residential buildings, and this method can be applied to any contour recognition scenario.
[0035] After acquiring the first image, according to the predetermined color requirement, the pixels in the first image that meet the requirement are determined to obtain the first pixel set. The color requirement is determined according to the color of the target object whose contour is to be identified in the first image. For example, in the first image, the color of the target object is light brown, then the range of each color channel shown by the target object in the first image is taken as the color requirement, which can be: the red channel value range is between 235 and 245, the green channel value range is between 235 and 245, and the blue channel value is between 210 and 230. Of course, for light brown, the color requirement can cover other ranges, and the target object can also be other colors. Further, the first image is converted into an RGB (red, green, blue) color space to determine the color characteristics of each pixel in the first image, that is, the red channel value, the green channel value and the blue channel value of each pixel. Then, all the pixels are traversed to filter out multiple pixels whose red channel value is in the red channel value range, the green channel value is in the green channel value range, and the blue channel value is in the blue channel value range. These pixels that meet the color requirements are called first pixels, and a set of multiple first pixels is a first pixel set. In the first pixel combination, the first pixel has color characteristics and image coordinates. The image coordinates represent the horizontal and vertical positions of the first pixel in the first image. It should be noted that in order to more accurately screen out the pixels belonging to the target object, the value ranges of each channel can be set to a smaller span.
[0036] Different functional parts in the first image use different colors. Therefore, by using color features, the first pixel points that meet the color requirements are screened in the first image, which can maximize the recognition accuracy of the first pixel constituting the target object, overcoming the limitations of manual work in similar color representation scenes. In addition, through this step, the interference of environmental factors that do not belong to the target object, such as vegetation and roads, is eliminated.
[0037] In addition, since the first image is provided by the developer, it is inevitable that there will be problems such as uneven exposure and color rendering, which will cause the pixels that originally belong to the target object to appear in non-target colors. For example, in an exposed scene, some areas of the originally light brown residential building will appear white. If the pixel points of the target part are determined entirely by color features, then the part of the target object restored based on the final set of first pixel points will be missing.
[0038] Based on this, the present disclosure proposes to perform expansion processing on the first pixel set to obtain the second pixel set.
[0039] Specifically, each first pixel in the first pixel set is traversed, and the horizontal axis expansion coefficient is superimposed on both sides of the horizontal axis of the first pixel with the horizontal axis of the first pixel as the center to obtain the horizontal axis range. The horizontal axis expansion coefficient represents the number of unit coordinates expanded on one side of the horizontal axis in the horizontal direction.
[0040] For example, if the horizontal expansion coefficient is i and the image coordinates of the first pixel are (20, 30), then the horizontal expansion coefficients are superimposed on both sides of the horizontal coordinate, and the obtained horizontal coordinate range is: 20-i to 20+i. The horizontal expansion coefficient i is usually set according to factors such as the size of the first image and pixel accuracy, and i can be any value.
[0041] Similarly, with the vertical coordinate of the first pixel as the center, the vertical axis expansion coefficient is superimposed on both sides of the vertical coordinate of the first pixel to obtain the vertical coordinate range. The vertical axis expansion coefficient represents the number of unit coordinates expanded on one side of the vertical coordinate in the vertical axis direction.
[0042] For example, if the vertical expansion coefficient is j and the image coordinates of the first pixel are (20, 30), then the vertical expansion coefficients are superimposed on both sides of the vertical coordinates, and the vertical coordinate range obtained is: 30-j to 30+j. The vertical expansion coefficient j is usually set according to factors such as the size and pixel accuracy of the first image, and j can be any value. i and j can be the same or different.
[0043] Furthermore, the area enclosed by the horizontal coordinate range and the vertical coordinate range is used as the neighborhood of the first pixel, and the pixel points falling into the neighborhood are also used as the pixel points describing the target object. And the pixel points falling into the neighborhood and not belonging to the first pixel set are used as the expanded pixel points supplemented by the expansion process.
[0044] By traversing each first pixel point, a plurality of dilated pixel points are obtained, and then a second pixel set consisting of each first pixel point in the first pixel set and the plurality of dilated pixel points is obtained. The second pixel set is used to describe the target area in the first image.
[0045] Further, a white image is established, and the image properties of the white image, such as size and pixel accuracy, should be consistent with those of the first image. Then, the grayscale value of each pixel is determined according to the color characteristics of each pixel in the second pixel set. The color characteristics include red channel value, green channel value and blue channel value, and these three colors are mixed to form the color of the pixel. Although each pixel meets the color requirements, the red channel value, green channel value and blue channel value of each pixel are not exactly the same. Therefore, by taking the average of the three color channels as the grayscale value of the pixel, the pixel only represents the brightness feature and ignores the color feature, and the outline of the target object is more prominent and its color is ignored. For example, the red channel value of a certain pixel is 245, the green channel value is 245, and the blue channel value is 220, then the average of the three is calculated to be 237. Of course, the grayscale value can also be calculated by weighted average method, maximum value method, minimum value method, etc., which are not limited here.
[0046] Then, according to the image coordinates and the corresponding grayscale value of each pixel point in the second pixel set, a pixel point with the grayscale value is rendered at a corresponding position of the white image to form a grayscale image. Figure 4 is a grayscale image obtained by grayscale processing of the first image according to an embodiment of the present disclosure. Figure 4 As shown, the background part of the grayscale image is white, and the target part depicted by the second pixel set is gray with different brightness. In the grayscale image, the internal structure of the target can still be seen, and in the subsequent contour recognition process, these internal structures will interfere with the contour recognition.
[0047] In order to minimize the interference of non-building contour parts on contour recognition, the grayscale image is further binarized. Specifically, a grayscale threshold is set, and the pixel points with grayscale values less than the grayscale threshold are set to black grayscale values, that is, 0; the pixel points with grayscale values greater than the grayscale threshold are set to white grayscale values, that is, 255.
[0048] Alternatively, according to the image coordinates of each pixel in the second pixel set, the grayscale value of the pixel of the target object in the grayscale image is adjusted to a black grayscale value; the white color feature of the background part in the grayscale image is converted to a white grayscale value to obtain a second image.
[0049] Figure 5is a schematic diagram of a second image according to an embodiment of the present disclosure. After the aforementioned binarization process, the second image obtained is as follows Figure 5 As shown, it only contains two brightness values, black grayscale value and white grayscale value, and the human eye sees black and white colors. The second image does not focus on the internal structure of the target object, but only presents the outline shape of the target object, which is more conducive to subsequent outline recognition. Of course, the black grayscale value and the white grayscale value are the optimal solutions, and the background part and the target part can also be set to other grayscale values with large differences, which are not limited here.
[0050] Then, the contour recognition tool is called to recognize the contour of the target object in the second image to obtain a first contour point set. The pixel points in the first contour point set are all pixel points in the target part that are adjacent to the background part, and the pixel points are recorded in the form of image coordinates. The contour recognition tool can be a contour recognition function with OpenCV (Open Source Computer Vision Library) as a database. The contour recognition tool can also be other tools that can recognize the contour of the target object in the image, which is not limited here. In the first contour point set, each pixel point contains information such as its image coordinates.
[0051] Figure 6 is a schematic diagram of a contour determined by a first contour point set according to an embodiment of the present disclosure. Figure 6 As shown, if the contour of the target object is depicted with the first contour point set, redundant points near the contour may appear due to some errors in the previous steps, so that the final contour has burrs, is not smooth enough, and is inconsistent with the actual contour.
[0052] Therefore, the present disclosure determines the simplification coefficient by a preset scaling factor, and then uses the simplification coefficient to remove redundant points in the first contour point set to obtain a second contour point set that does not contain redundant points, and the pixel points are recorded in the form of image coordinates.
[0053] Specifically, the scaling factor represents the approximation between the original contour and the simplified contour, and the scaling factor is proportional to the simplification coefficient. The original contour is a contour determined by the first contour point set, and the simplified contour is a contour determined by the second contour point set. The scaling factor is defined by the user, and the specific value is not limited here.
[0054] Simplification coefficient: epsilon = dp_value * math.sqrt(math.sqrt(area)), where dp_value represents the scaling factor, math.sqrt(math.sqrt(area)) represents the fourth root of area, and area is the area of the contour depicted by the first contour point set. The simplification coefficient represents the difference between the shape of the original contour corresponding to the first contour point set and the shape of the simplified contour, and the simplification coefficient is proportional to the difference. For contours with larger areas, the simplification coefficient will be relatively large, allowing for larger errors; for smaller contours, the simplification coefficient will be relatively small to maintain higher accuracy.
[0055] Furthermore, the contour recognition tool is called to redetermine the pixel points used to describe the contour of the target object according to the simplification coefficient, that is, the redundant points in the first contour point set are eliminated to obtain the second contour point set.
[0056] Figure 7 is a schematic diagram of a contour determined by a second contour point set according to an embodiment of the present disclosure. Figure 7 , showing the target object outline depicted by the second set of contour points, compared to Figure 6 It is obvious that after removing redundant points, the outline of the target object depicted can be smoother and closer to the real target object outline.
[0057] Furthermore, the image coordinates of each pixel point in the second contour point set are converted into floating point format to obtain the contour point set of the target. For example, the second contour point set is [(1,2), (3,4), (5,6)], which can be converted into a contour point set [(1.0, 2.0), (3.0, 4.0), (5.0, 6.0)] after conversion to floating point format. The floating point format has the advantages of higher precision, better flexibility, and support for sub-pixel level operations.
[0058] Furthermore, the longitude and latitude of each pixel point in the contour point set can be determined according to the longitude and latitude of the reference point in the first image and the image coordinates, and the longitude and latitude data of the contour point can be obtained, and the longitude and latitude data of the contour point includes the longitude and latitude of each contour point in the contour point set. The reference point is a pixel point with longitude and latitude and image coordinates in the first image, usually a pixel point in the upper left corner and a pixel point in the lower right corner of the first image. By converting the pixel points in the contour point set from image coordinates to longitude and latitude, the contour of the target object can be restored in the longitude and latitude scene, thereby improving the applicability of contour recognition.
[0059] The present disclosure avoids the inefficient and low-precision contour recognition process of manual intervention through the aforementioned image processing method. By screening the first pixel set, the target object part is screened with quantized color features, thereby improving the accuracy of contour recognition. By expanding the first pixel set, the incomplete pixel collection of the target object caused by light and other problems is compensated, and the interference of environmental factors such as vegetation on the recognition of the target object is overcome. The color features of the second pixel set are adjusted to grayscale values and rendered to a blank image, and then the obtained grayscale image is binarized, so that the obtained second image pays more attention to the boundary position between the target object part and the background part, and eliminates the interference of the internal structure of the target object part on contour recognition. Finally, by eliminating redundant points, a contour point set is obtained, and the contour drawn by the contour point set is smoother and more realistic. In addition, the contour point set can be converted into longitude and latitude, which expands the scenarios applicable to the contour point set.
[0060] Figure 8 is a flow chart of an image processing method according to an embodiment of the present disclosure. Figure 8 As shown, in order to implement the aforementioned technical solution, the present disclosure proposes an image processing method M800, including: step S810, dilating a first pixel set in a first image to obtain a second pixel set, the first pixel set including a plurality of first pixel points whose color values are in a target range in the first image, the second pixel set including the first pixel set and a plurality of dilated pixel points, the dilated pixel points being pixel points in the neighborhood of the first pixel points; step S820, performing grayscale processing on each pixel point in the second pixel set to obtain a second image, the second image including a background portion and a target object portion corresponding to the second pixel set; and step S830, performing contour recognition on the second image to obtain a contour point set, the contour point set including pixel points in the target object portion adjacent to the background portion.
[0061] In some embodiments, step S810 is specifically as follows: superimposing a horizontal axis expansion coefficient on both sides of the horizontal coordinate of the first pixel point to obtain a horizontal coordinate range, where the horizontal axis expansion coefficient represents the number of unit coordinates expanded on one side of the horizontal coordinate in the horizontal direction; superimposing a vertical axis expansion coefficient on both sides of the vertical coordinate of the first pixel point to obtain a vertical coordinate range, where the vertical axis expansion coefficient represents the number of unit coordinates expanded on one side of the vertical coordinate in the vertical direction; in the first image, determining a plurality of expanded pixel points whose image coordinates fall within the horizontal coordinate range and the vertical coordinate range and do not belong to the first pixel set; and obtaining a second pixel set based on the first pixel set and the plurality of expanded pixel points.
[0062] In some embodiments, the execution steps of step S820 include: establishing a white image; converting the color characteristics of the pixel points in the second pixel set into grayscale values, and the grayscale values are used to affect the brightness of the corresponding pixel points; rendering the target object part in the white image according to the image position and grayscale value of each pixel point in the second pixel set; and obtaining a second image including the target object part and the background part, the background part being the area in the white image not covered by the target object part.
[0063] In some embodiments, the execution steps of step S820 also include: adjusting the grayscale value of the pixel points in the target object part to a black grayscale value; converting the pixel points in the background part from a white color feature to a white grayscale value; obtaining a second image, in which the target object part has a black grayscale value and the background part has a white grayscale value.
[0064] In some embodiments, the execution steps of step S830 include: calling a contour recognition tool to determine a first contour point set in the second image, the first contour point set including all pixel points in the target object part that are adjacent to the background part; according to the simplification coefficient, eliminating redundant points in the first contour point set to obtain a second contour point set, the simplification coefficient represents the difference between the shape of the original contour and the shape of the simplified contour, the original contour is the target object contour corresponding to the first contour point set, the simplified contour is the target object contour corresponding to the second contour point set, the simplification coefficient is proportional to the difference, and the redundant points are pixel points that do not constitute the shape of the original contour; and converting the image coordinates of each pixel point in the second contour point set into a floating point format to obtain a contour point set.
[0065] In some embodiments, it also includes: determining a first pixel point whose color characteristics meet the color requirements in the first image, obtaining a first pixel set, the color characteristics of the pixel point include the red channel value, green channel value and blue channel value of the pixel point, the color requirement is determined according to the color characteristics of the target object in the first image, and the color requirement includes the red channel value range, the green channel value range and the blue channel value range.
[0066] In some embodiments, the method further includes: determining the longitude and latitude of each pixel point in the contour point set according to the longitude and latitude of the reference point in the first image and the image coordinates, and obtaining the longitude and latitude data of the contour point, wherein the longitude and latitude data of the contour point includes the longitude and latitude of each contour point in the contour point set.
[0067] The implementation method and principle of each step of the image processing method M800 can be found in the previous text and will not be repeated here.
[0068] The image processing method disclosed in the present invention avoids the inefficient and low-precision contour recognition process caused by manual intervention. By screening the first pixel set, the target object part is screened with quantized color features, thereby improving the accuracy of contour recognition. By expanding the first pixel set, the incomplete pixel collection of the target object caused by light and other problems is compensated, and the interference of environmental factors such as vegetation on the recognition of the target object is overcome. The color features of the second pixel set are adjusted to grayscale values and rendered to a blank image, and then the obtained grayscale image is binarized, so that the obtained second image pays more attention to the boundary position between the target object part and the background part, and eliminates the interference of the internal structure of the target object part on contour recognition. Finally, by eliminating redundant points, a contour point set is obtained, and the contour drawn by the contour point set is smoother and more realistic. In addition, the contour point set can be converted into longitude and latitude, which expands the scenarios applicable to the contour point set.
[0069] Fig. 9 is a schematic block diagram of the structure of an image processing device according to an embodiment of the present disclosure. Fig. 9 , showing the basic structure of the image processing device, which is a virtual device of the image processing method, including a dilation processing module 810, a grayscale processing module 820 and a contour recognition module 830.
[0070] The expansion processing module 810 is used to perform expansion processing on a first pixel set in a first image to obtain a second pixel set, wherein the first pixel set includes a plurality of first pixel points whose color values are within a target range in the first image, and the second pixel set includes the first pixel set and a plurality of expanded pixel points, wherein the expanded pixel points are pixel points in the neighborhood of the first pixel points; the grayscale processing module 820 is used to perform grayscale processing on each pixel point in the second pixel set to obtain a second image, wherein the second image includes a background portion and a target object portion corresponding to the second pixel set; and the contour recognition module 830 is used to perform contour recognition on the second image to obtain a contour point set, wherein the contour point set includes pixel points in the target object portion that are adjacent to the background portion.
[0071] In some embodiments, the expansion processing module 810 executes steps including: superimposing a horizontal axis expansion coefficient on both sides of the horizontal coordinate of the first pixel point to obtain a horizontal coordinate range, where the horizontal axis expansion coefficient represents the number of unit coordinates expanded on one side of the horizontal coordinate in the horizontal direction; superimposing a vertical axis expansion coefficient on both sides of the vertical coordinate of the first pixel point to obtain a vertical coordinate range, where the vertical axis expansion coefficient represents the number of unit coordinates expanded on one side of the vertical coordinate in the vertical direction; in the first image, determining a plurality of expanded pixel points whose image coordinates fall within the horizontal coordinate range and the vertical coordinate range and do not belong to the first pixel set; and obtaining a second pixel set based on the first pixel set and the plurality of expanded pixel points.
[0072] In some embodiments, the execution steps of the grayscale processing module 820 include: establishing a white image; converting the color characteristics of the pixel points in the second pixel set into grayscale values, and the grayscale values are used to affect the brightness of the corresponding pixel points; rendering the target object part in the white image according to the image position and grayscale value of each pixel point in the second pixel set; and obtaining a second image including the target object part and the background part, the background part being the area in the white image not covered by the target object part.
[0073] In some embodiments, the execution steps of the grayscale processing module 820 also include: adjusting the grayscale value of the pixel points in the target object part to a black grayscale value; converting the pixel points in the background part from a white color feature to a white grayscale value; obtaining a second image, in which the target object part has a black grayscale value and the background part has a white grayscale value.
[0074] In some embodiments, the execution steps of the contour recognition module 830 include: calling the contour recognition tool to determine a first contour point set in the second image, the first contour point set including all pixel points in the target object part that are adjacent to the background part; according to the simplification coefficient, eliminating redundant points in the first contour point set to obtain a second contour point set, the simplification coefficient represents the difference between the shape of the original contour and the shape of the simplified contour, the original contour is the target object contour corresponding to the first contour point set, the simplified contour is the target object contour corresponding to the second contour point set, the simplification coefficient is proportional to the difference, and the redundant points are pixel points that do not constitute the shape of the original contour; and converting the image coordinates of each pixel point in the second contour point set into a floating point format to obtain a contour point set.
[0075] In some embodiments, a preprocessing module (not shown) is further included, which is used to determine a first pixel point whose color characteristics meet the color requirements in the first image, and obtain a first pixel set. The color characteristics of the pixel point include the red channel value, green channel value, and blue channel value of the pixel point. The color requirements are determined based on the color characteristics of the target object in the first image, and the color requirements include the red channel value range, the green channel value range, and the blue channel value range.
[0076] In some embodiments, a post-processing module (not shown) is further included, which is used to determine the longitude and latitude of each pixel point in the contour point set based on the longitude and latitude of the reference point in the first image and the image coordinates, and obtain the longitude and latitude data of the contour point, wherein the longitude and latitude data of the contour point includes the longitude and latitude of each contour point in the contour point set.
[0077] The modules of the image processing device are configured to implement the steps of the image processing method M800. The implementation method and principle are the same as those of the method M800, and reference may be made to the foregoing text, which will not be described in detail here.
[0078] The image processing device disclosed in the present invention avoids the inefficient and low-precision contour recognition process caused by manual intervention. By screening the first pixel set, the target object part is screened with quantized color features, thereby improving the accuracy of contour recognition. By expanding the first pixel set, the incomplete pixel collection of the target object caused by light and other problems is compensated, and the interference of environmental factors such as vegetation on the recognition of the target object is overcome. The color features of the second pixel set are adjusted to grayscale values and rendered to a blank image, and then the obtained grayscale image is binarized, so that the obtained second image pays more attention to the boundary position between the target object part and the background part, and eliminates the interference of the internal structure of the target object part on contour recognition. Finally, by eliminating redundant points, a contour point set is obtained, and the contour drawn by the contour point set is smoother and more realistic. In addition, the contour point set can be converted into longitude and latitude, which expands the scenarios applicable to the contour point set.
[0079] Fig.10 The present invention is a block diagram showing a structure of an electronic device equipped with an image processing device according to an embodiment of the present invention.
[0080] The hardware structure of the electronic device 1000 can be implemented using a bus architecture. The bus architecture can include any number of interconnected buses and bridges, depending on the specific application and overall design constraints of the hardware. The bus 1100 connects various circuits including one or more processors 1200, memory 1300 and / or hardware modules together. The bus 1100 can also connect various other circuits 1400 such as peripherals, voltage regulators, power management circuits, external antennas, etc.
[0081] The bus 1100 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Component (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the figure only uses one connecting line, but does not mean that there is only one bus or one type of bus.
[0082] The present disclosure also provides a readable storage medium, in which a computer program is stored, and the computer program is used to implement the above method when executed by a processor. "Readable storage medium" can be any device that can contain, store, communicate, propagate or transmit a program for use in an instruction execution system, device or equipment or in combination with these instruction execution systems, devices or equipment. More specific examples of readable storage media include the following: an electrical connection portion (electronic device) with one or more wirings, a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable read-only memory (CDROM), etc.
[0083] The present disclosure also provides a computer program product. The method of the present disclosure can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instruction is loaded and executed, the process or function of the present disclosure is executed in whole or in part.
[0084] The computer program or instructions may be stored in a readable storage medium or transmitted from one readable storage medium to another readable storage medium, for example, the computer program or instructions may be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired or wireless means. The readable storage medium may be any available medium that can be accessed or a data storage device such as a server, data center, etc. that integrates one or more available media. The available medium may be a magnetic medium, such as a floppy disk, a hard disk, or a magnetic tape; it may also be an optical medium, such as a digital video disk; it may also be a semiconductor medium, such as a solid state drive. The computer readable storage medium may be a volatile or non-volatile storage medium, or may include both volatile and non-volatile types of storage media.
[0085] The image processing method, device, electronic device, readable storage medium and computer program product provided by the present disclosure all avoid the inefficient and low-precision contour recognition process of manual intervention. By screening the first pixel set, the target object part is screened with quantized color features, thereby improving the accuracy of contour recognition. By expanding the first pixel set, the incomplete pixel point collection of the target object caused by light and other problems is compensated, and the interference of environmental factors such as vegetation on the recognition of the target object is overcome. The color features of the second pixel set are adjusted to grayscale values and rendered to a blank image, and then the obtained grayscale image is binarized, so that the obtained second image pays more attention to the boundary position between the target object part and the background part, and eliminates the interference of the internal structure of the target object part on contour recognition. Finally, by eliminating redundant points, a contour point set is obtained, and the contour drawn by the contour point set is smoother and more realistic. In addition, the contour point set can be converted into longitude and latitude, which expands the scenes applicable to the contour point set.
[0086] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, electronic devices, readable storage media, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0087] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0088] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0089] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0090] In the description of this specification, the description with reference to the terms "one embodiment / method", "some embodiments / methods", "example", "specific example", or "some examples" etc. means that the specific features, structures, or characteristics described in conjunction with the embodiment / method or example are included in at least one embodiment / method or example of the present disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment / method or example. Moreover, the specific features, structures, or characteristics described may be combined in a suitable manner in any one or more embodiments / methods or examples. In addition, those skilled in the art may combine and combine different embodiments / methods or examples described in this specification and features of different embodiments / methods or examples, unless they are contradictory.
[0091] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, "plurality" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0092] Those skilled in the art should understand that the above embodiments are only for the purpose of clearly illustrating the present disclosure, and are not intended to limit the scope of the present disclosure. For those skilled in the art, other changes or modifications may be made based on the above disclosure, and these changes or modifications are still within the scope of the present disclosure.
Claims
1. An image processing method, characterized in that: include: Performing dilation processing on a first pixel set in a first image to obtain a second pixel set, wherein the first pixel set includes a plurality of first pixel points in the first image whose color values are within a target range, and the second pixel set includes the first pixel set and a plurality of dilated pixel points, wherein the dilated pixel points are pixel points in the neighborhood of the first pixel points; Performing grayscale processing on each pixel in the second pixel set to obtain a second image, wherein the second image includes a background portion and a target object portion corresponding to the second pixel set; as well as Perform contour recognition on the second image to obtain a contour point set, where the contour point set includes pixel points in the target object portion that are adjacent to the background portion.
2. The image processing method according to claim 1, characterized in that: Performing dilation processing on a first pixel set in a first image to obtain a second pixel set includes: superimposing a horizontal axis expansion coefficient on both sides of the horizontal coordinate of the first pixel point to obtain a horizontal coordinate range, wherein the horizontal axis expansion coefficient represents the number of unit coordinates expanded on one side of the horizontal coordinate in the horizontal axis direction; Superimposing a longitudinal expansion coefficient on both sides of the longitudinal coordinate of the first pixel point to obtain a longitudinal coordinate range, wherein the longitudinal expansion coefficient represents the number of unit coordinates expanded on one side of the longitudinal coordinate in the longitudinal direction; In the first image, determining a plurality of dilated pixel points whose image coordinates fall within the abscissa range and the ordinate range and do not belong to the first pixel set; and A second pixel set is obtained according to the first pixel set and the plurality of dilated pixel points.
3. The image processing method according to claim 1, characterized in that: Obtaining a second image, comprising: Create a white image; Converting color features of pixels in the second pixel set into grayscale values, where the grayscale values are used to affect the brightness of the corresponding pixels; Rendering the target object portion in the white image according to the image position and the grayscale value of each pixel in the second pixel set; and A second image including the target object portion and a background portion is obtained, wherein the background portion is an area of the white image that is not covered by the target object portion.
4. The image processing method according to claim 3, characterized in that: Acquiring a second image further includes: Adjusting the grayscale value of the pixel points in the target object portion to a black grayscale value; Converting the pixel points in the background portion from white color features to white grayscale values; The second image is obtained, in which the target object portion has a black grayscale value and the background portion has a white grayscale value.
5. The image processing method according to claim 1 or 4, characterized in that: Performing contour recognition on the second image to obtain a contour point set includes: Invoking a contour recognition tool to determine a first contour point set in the second image, wherein the first contour point set includes all pixel points in the target object portion that are adjacent to the background portion; Eliminate redundant points in the first contour point set according to a simplification coefficient to obtain a second contour point set, wherein the simplification coefficient represents a difference between a shape of an original contour and a shape of a simplified contour, wherein the original contour is a contour of the target object corresponding to the first contour point set, and the simplified contour is a contour of the target object corresponding to the second contour point set, and the simplification coefficient is proportional to the difference, wherein the redundant points are pixel points that do not constitute the shape of the original contour; and The image coordinates of each pixel point in the second contour point set are converted into a floating point format to obtain the contour point set.
6. The image processing method according to claim 1, characterized in that: Before dilating the first pixel set in the first image to obtain the second pixel set, the method includes: A first pixel point whose color characteristics meet the color requirements is determined in the first image to obtain the first pixel set, wherein the color characteristics of the pixel point include a red channel value, a green channel value, and a blue channel value of the pixel point, and the color requirement is determined according to the color characteristics of the target object in the first image, and the color requirement includes a red channel value range, a green channel value range, and a blue channel value range.
7. The image processing method according to claim 1, characterized in that: After performing contour recognition on the second image to obtain a set of contour points, the method includes: The longitude and latitude of each pixel point in the contour point set are determined according to the longitude and latitude of the reference point in the first image and the image coordinates, and the longitude and latitude data of the contour point are obtained, wherein the longitude and latitude data of the contour point include the longitude and latitude of each contour point in the contour point set.
8. An electronic device, characterized in that: include: A memory storing execution instructions; as well as A processor, wherein the processor executes the execution instruction stored in the memory, so that the processor executes the image processing method according to any one of claims 1 to 7.
9. A readable storage medium, characterized in that: The readable storage medium stores execution instructions, which are used to implement the image processing method according to any one of claims 1 to 7 when executed by a processor.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the image processing method according to any one of claims 1 to 7 is implemented.