Image segmentation method and image segmentation equipment
By adding black closed frames to the image and using the eight-neighborhood image processing principle, efficient image segmentation is achieved, solving the problem of low image segmentation efficiency in the prior art, and improving segmentation efficiency and speed.
Patent Information
- Application Number
- CN202510219595.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-26
- Publication Date
- 2025-05-16
AI Technical Summary
Existing image segmentation methods are inefficient, especially when large numbers of images are needed to be segmented, manual segmentation efficiency is very inefficient.
By adding any shape of black enclosure frames to the first image, a second image is formed, and all black pixels of each black enclosure frame are sequentially retrieved according to the eight-neighborhood image processing principle, and using each black enclosure frame as the segmentation track, N second sub-images are gradually divided.
This method significantly improves the efficiency of image segmentation, reduces the retrieval time, and can quickly segment a large number of first sub-images separately, and is suitable for applications such as direct laser plate making.
Smart Images

Figure CN120013967A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of image processing technology, and in particular, to an image segmentation method and a segmentation device. Background Art
[0002] refer to Figure 1 In the laser direct platemaking industry, it is usually necessary to separate N (5 for example) first sub-images 01-05 on the first image 00 separately and completely, and each first sub-image is used for laser direct platemaking separately. At present, the commonly used processing method is to manually segment the five first sub-images separately, but the manual segmentation efficiency is low: if N is relatively large (for example, N value is greater than 50), it takes a long time to manually segment all the first sub-images, and the efficiency is very low. Summary of the invention
[0003] The embodiments of the present application provide an image segmentation method and a segmentation device, which aim to solve the shortcoming of low efficiency of existing image segmentation methods.
[0004] An image segmentation method, comprising:
[0005] Step 1: Add a black closed frame of any shape to the periphery of each of the N first sub-images on the first image to obtain a second image, wherein the second image includes the N second sub-images, and each second sub-image includes all image regions including the first sub-image enclosed by the corresponding black closed frame; wherein the shapes of the N black closed frames may be the same or different from each other;
[0006] Step 2: According to the eight-neighborhood image processing principle, all black pixels of each black closed frame are retrieved in turn, and each black closed frame is used as a segmentation trajectory to segment N second sub-images in turn.
[0007] In some embodiments, in step 2, sequentially dividing N second sub-images specifically includes:
[0008] Step 21: firstly segment the first second sub-image;
[0009] Step 22: Then, the remaining N-1 second sub-images are segmented in sequence.
[0010] In some embodiments, step 21 includes:
[0011] Step 211: define the upper left corner position of the second image as the initial position o(0,0), the computer starts from the initial position o(0,0), searches row by row from left to right and from top to bottom until the first black pixel B11 (X11, Y11) is first searched, the black closed frame containing the first black pixel B11 is defined as the first black closed frame, the first black pixel B11 (X11, Y11) is defined as the first black pixel of the first black closed frame, the first sub-image located inside the first black closed frame is defined as the first first sub-image, and the image formed by all areas enclosed by the first black closed frame is defined as the first second sub-image;
[0012] Step 212: The computer uses the first black pixel B11 (X11, Y11) of the first black closed frame as the search starting point, and searches for all black pixels of the first black closed frame in a clockwise or counterclockwise direction according to the eight-neighborhood image processing principle, until the black pixel B11 (X11, Y11) is found again, thereby completing the search for all black pixels of the first black closed frame;
[0013] Step 213: The computer segments the first second sub-image along the trajectory of the first black closed frame.
[0014] In some embodiments, step 22 includes:
[0015] Step 221: The computer segments a second second sub-image along the trajectory of the second black closed frame;
[0016] Step 222: Using the same idea as segmenting the second second sub-image, the computer sequentially segments the remaining N-2 second sub-images.
[0017] In some embodiments, step 221 includes:
[0018] Step 2211: The computer takes the black pixel (X11, Y11) as the starting point, and searches row by row from left to right and from top to bottom until the first black pixel B21 (X21, Y21) is first searched, and the black closed frame containing the first black pixel B21 is defined as the second black closed frame, the first black pixel B21 (X21, Y21) is defined as the first black pixel of the second black closed frame, the first sub-image located inside the second black closed frame is defined as the second first sub-image, and the image formed by all areas enclosed by the second black closed frame is defined as the second second sub-image;
[0019] Step 2212: The computer uses the first black pixel (X21, Y21) of the second black closed frame as the search starting point, and searches for all black pixels of the second black closed frame in a clockwise or counterclockwise direction according to the eight-neighborhood image processing principle, until the black pixel (X21, Y21) is found again, thereby completing the search for all black pixels of the second black closed frame;
[0020] Step 2213: The computer intercepts along the trajectory of the first black closed frame to obtain a second second sub-image.
[0021] The present application also discloses an image segmentation device, comprising:
[0022] A black closed frame adding module is used to: add a black closed frame of any shape to the periphery of each of the N first sub-images on the first image to obtain a second image, wherein the second image includes the N second sub-images, and each second sub-image includes all image areas including the first sub-image enclosed by the corresponding black closed frame; wherein the shapes of the N black closed frames may be the same or different from each other;
[0023] The image segmentation module is used to retrieve all black pixels of each black closed frame in turn according to the eight-neighborhood image processing principle, and use each black closed frame as a segmentation trajectory to sequentially segment N second sub-images.
[0024] In some embodiments, the image segmentation module is used to segment the first first sub-image to obtain the first second sub-image by:
[0025] The upper left corner position of the second image is defined as the initial position o(0,0). The computer starts from the initial position o(0,0) and searches row by row from left to right and from top to bottom until the first black pixel B11 (X11, Y11) is first searched. The black closed frame containing the first black pixel B11 is defined as the first black closed frame. The first black pixel B11 (X11, Y11) is defined as the first black pixel of the first black closed frame. The first sub-image located inside the first black closed frame is defined as the first first sub-image. The image formed by all areas enclosed by the first black closed frame is defined as the first second sub-image.
[0026] Taking the first black pixel (X11, Y11) of the first black closed frame as the search starting point, all black pixels of the first black closed frame are searched in turn in a clockwise or counterclockwise direction according to the eight-neighborhood image processing principle until a black pixel (X11, Y11) is found again, thus completing the search for all black pixels of the first black closed frame;
[0027] Cut along the trajectory of the first black closed frame to obtain the first second sub-image.
[0028] In some embodiments, the image segmentation module is used to segment the second first sub-image, and the steps of obtaining the second second sub-image are:
[0029] Starting from the black pixel (X11, Y11), search row by row from left to right and from top to bottom until the first black pixel B21 (X21, Y21) is first searched, a black closed frame containing the first black pixel B21 is defined as a second black closed frame, the first black pixel B21 (X21, Y21) is defined as the first black pixel of the second black closed frame, the first sub-image located inside the second black closed frame is defined as a second first sub-image, and an image formed by all areas enclosed by the second black closed frame is defined as a second second sub-image;
[0030] Taking the first black pixel (X21, Y21) of the second black closed frame as the search starting point, all black pixels of the second black closed frame are searched in turn in a clockwise or counterclockwise direction according to the eight-neighborhood image processing principle until a black pixel (X21, Y21) is found again, thus completing the search of all black pixels of the first black closed frame;
[0031] Cut along the trajectory of the first black closed frame to obtain the first second sub-image.
[0032] The embodiment of the present application further discloses a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the aforementioned image segmentation method are implemented.
[0033] The embodiment of the present application also discloses a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps of the aforementioned image segmentation method are implemented.
[0034] The technical effects of the embodiments of the present application are as follows:
[0035] The computer searches one by one from the initial position o(0,0) of the second image in the order from left to right and from top to bottom until the first black pixel is first found, and the first black pixel is used as the first black pixel of the first black closed frame. Then, starting from the first black pixel, all the black pixels of the first black closed frame are searched one by one in a clockwise or counterclockwise direction according to the eight-neighborhood image processing principle, and the trajectory of the first black closed frame is obtained. The first black closed frame is used as the segmentation trajectory to segment the first second sub-image.
[0036] The computer then uses the first black pixel of the first black closed frame as the starting point, and searches one by one from left to right and from top to bottom until the first black pixel is found, and uses the black closed frame corresponding to the first black pixel as the second black closed frame. Then, using the first black pixel as the starting point, the computer searches one by one for all the black pixels of the second black closed frame in a clockwise or counterclockwise direction according to the eight-neighborhood image processing principle, obtains the trajectory of the second black closed frame, and uses the second black closed frame as the segmentation trajectory to segment the second sub-image of the second frame.
[0037] The computer sequentially segments the third second sub-image to the last second sub-image using the same idea as that of segmenting the second second sub-image, thereby completing the segmentation of all second sub-images of the second image.
[0038] According to the technical solution of the present application, when segmenting the second image and the remaining second sub-images, the position at which the computer starts searching is the position of the first black pixel of the black closed frame corresponding to the segmentation of the previous second sub-image. Therefore, after the computer completes the segmentation of each second sub-image, it is not necessary to return to the starting point 0 (0,0) at the upper left corner of the second image to start searching, which reduces the search time and improves the image segmentation efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 is a schematic diagram of five first sub-images that need to be segmented and are distributed on the first image 00;
[0040] Figure 2 For Figure 1 Schematic diagram of adding black closed frames to the five first sub-images to become the second image 00A;
[0041] Figure 3 A diagram showing the steps of an image segmentation method according to an embodiment of the present application;
[0042] Figure 4 The distribution diagram of each black pixel displayed after the first black closed frame 01A retrieved by the computer is enlarged;
[0043] Figure 5 It is a schematic diagram of eight-neighborhood image processing;
[0044] Figure 6 for Figure 2 A schematic diagram of a first second sub-image 01B of the second image 00A after being segmented;
[0045] Figure 7 The distribution diagram of each black pixel displayed after the second black closed frame 02A is enlarged;
[0046] Figure 8is a schematic diagram of the first second sub-image 01B and the second second sub-image 02B in the second image 00A after being segmented;
[0047] Fig. 9 This is a module diagram of the image segmentation device of this application. DETAILED DESCRIPTION
[0048] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0049] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific position, be constructed and operated in a specific position, and therefore cannot be understood as limiting the present invention; the terms "first", "second", and "third" are only used to describe the difference, and cannot be understood as indicating or implying relative importance. In addition, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be an indirect connection through an intermediate object, or it can be a connection between the two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0050] All images in this application are referred to as bitmaps.
[0051] Figure 1In the figure, the dotted rectangular box represents the length and width boundary of the artificially constructed first image 00. In fact, the boundary does not have any black pixels. In order to segment the five first sub-images 01-05 of the first image 00 separately and completely, a black closed frame is added to the outside of each of the five first sub-images 01-05. After adding the five black closed frames, the first image 00 becomes the second image 00A. The shapes of the five black closed frames can be the same or different, and the shapes are not restricted. However, what needs to be satisfied is that the five black closed frames can enclose each first sub-image, that is, each black closed frame should not have any overlapping black pixels with the first sub-image enclosed inside. There is no intersection between each two adjacent black closed frames, that is, there is no intersection between the two. The purpose of adding a black closed frame to the outside of each first sub-image is to provide a segmentation trajectory for segmenting each first sub-image, that is, the computer uses it to segment each first sub-image. Figure 2 When any first sub-image in is selected, the segmentation trajectory is the corresponding black closed box.
[0052] refer to Figure 1 The first image 00 exemplarily includes: a first first sub-image 01 , a second first sub-image 02 , a third first sub-image 03 , a fourth first sub-image 04 and a fifth first sub-image 05 . Figure 2 In the figure, the black closed frames added to the periphery of each first sub-image 01 are respectively named as the first black closed frame 01A, the second black closed frame 02A, the third black closed frame 03A, the fourth black closed frame 04A, and the fifth black closed frame 05A. Each black closed frame together with all the images enclosed by it (including the corresponding first sub-image) is defined as the Nth second sub-image. For example, the image enclosed by the first black closed frame 01A, including all areas of the first first sub-image 01, is defined as the first second sub-image 01B; the image enclosed by the second black closed frame 02A, including all areas of the second first sub-image 02, is defined as the second second sub-image 02B; the image enclosed by the third black closed frame 03A, including all areas of the third first sub-image 03, is defined as the second second sub-image 03B; the image enclosed by the fourth black closed frame 04A, including all areas of the fourth first sub-image 04, is defined as the fourth second sub-image 04B; the image enclosed by the fifth black closed frame 05A, including all areas of the fifth first sub-image 05, is defined as the fifth second sub-image 05B. It should be noted that the naming order of the five second sub-images 01B-05B is based on the order in which the corresponding black closed frames are retrieved by the computer. Figure 2 The arrangement order of the five second sub-images, which are placed in sequence from left to right and from top to bottom, is merely exemplary.
[0053] refer to Figure 3 , an image segmentation method disclosed in an embodiment of the present application includes:
[0054] Step 1: Add a black closed frame of any shape to the periphery of each of the N first sub-images on the first image to obtain a second image, wherein the second image includes the N second sub-images, and each second sub-image includes all image regions including the first sub-image enclosed by the corresponding black closed frame; wherein the shapes of the N black closed frames may be the same or different from each other;
[0055] Step 2: The computer retrieves all black pixels of each black closed frame in turn according to the eight-neighborhood image processing principle, and uses each black closed frame as a segmentation trajectory to segment N second sub-images in turn.
[0056] The following specifically describes how to use this method to segment the five second sub-images in sequence.
[0057] Step 2 is broken down into:
[0058] Step 21: firstly segment the first second sub-image;
[0059] Step 22: Then, the remaining N-1 second sub-images are segmented in sequence.
[0060] refer to Figures 2 to 5 , step 21 is specifically broken down as follows:
[0061] Step 211: Figure 2 The upper left corner position of the second image 00A in the image is set as the initial position o(0,0), (0,0) represents the set coordinate origin, the computer starts from the initial position o(0,0), searches row by row from left to right and from top to bottom, and first searches for the first black pixel B11 (X11, Y11), and defines the black closed frame containing the first black pixel B11 as the first black closed frame 01A, see Figure 2 . Figure 2 The first sub-image enclosed in the first black closed frame 01A in is defined as the first first sub-image, numbered 01, see Figure 1 The image formed by all the areas enclosed by the first black closed frame 01A is defined as the first second sub-image 01B. Obviously, the segmentation trajectory of the first second sub-image 01B is the first black closed frame 01A. Figure 4 The first black closed frame 01A is composed of a number of black pixels arranged in sequence, and all the black pixels form a closed frame. The first black pixel B11 (X11, Y11) is located at the uppermost left end of the first black closed frame 01A, and is therefore first retrieved by the computer program.
[0062] Step 212: The computer uses the first black pixel B11 (X11, Y11) of the first black closed frame as the search starting point, and searches for all black pixels of the first black closed frame in a clockwise or counterclockwise direction according to the eight-neighborhood image processing principle, until the black pixel B11 (X11, Y11) is found again, thus completing the search for all black pixels of the first black closed frame. Specifically, the present application takes the clockwise direction as an example, and searches for all black pixels of the first black closed frame in a clockwise or counterclockwise direction according to the eight-neighborhood image processing principle. Figure 5 , the eight-neighborhood image processing principle is: for any pixel p(x,y), its adjacent eight pixels (assuming that each pixel size is 1 unit, for example, 1 micron * 1 micron) are: the upper pixel p(x,y+1), the lower pixel p(x,y-1), the left pixel p(x-1,y), the right pixel p(x+1,y), the upper left pixel p(x-1,y+1), the upper right pixel p(x+1,y+1), the lower left pixel p(x-1,y-1) and the lower right pixel p(x+1,y-1). These eight positions are the eight-neighborhood of the pixel p(x,y). If the pixel p(x,y) is a black pixel, then as long as any one of the eight directions is a black pixel, the requirement is met. For example, if a computer wants to retrieve all black pixels based on the eight-neighborhood image processing principle, after retrieving any black pixel p(x,y), and then continues to search for the next black pixel of any black pixel p(x,y), as long as the next black pixel is located at any of the eight positions of any black pixel p(x,y), the retrieval condition is met. Figure 4 After the computer retrieves the first black pixel B11 (X11, Y11) of the first black closed frame, it retrieves the second black pixel B12 (X12, Y12) to its right in a clockwise direction, and then retrieves the third black pixel B13 (X13, Y13) located at the lower right of the second black pixel B12 (X12, Y12) based on the second black pixel B12 (X12, Y12) ... until the first black pixel B11 (X11, Y11) of the first black closed frame is retrieved again and the search ends. It can be understood that since all the black pixels constituting the first black closed frame are adjacent in sequence, the positional relationship between every two adjacent black pixels conforms to the eight-neighborhood positional relationship. (X11, Y11), (X12, Y12), (X12, Y12) and (X13, Y13) all represent the coordinates of the corresponding black pixels.
[0063] Step 213, the computer segments the first second sub-image along the trajectory of the first black closed frame: through step 212, the computer obtains the coordinate values of all black pixels constituting the first black closed frame 01A, so the computer segments the first second sub-image 01B along the first black closed frame 01A, and cuts off the entire piece for separate storage.
[0064] The following describes how the computer segments the second sub-image.
[0065] Step 2211: Reference Figure 6 and Figure 7 ,when Figure 2 After the first second sub-image 01B in the image is segmented, the area corresponding to the first second sub-image 01B is a blank area. When the computer segments the next second sub-image 02B, there is no need to return to Figure 2 Instead of using the initial point o(0,0) at the top left of the second image 00A, the first black pixel B11(X11, Y11) of the first black closed frame 01A is used as a new starting point, and the search is repeated row by row from left to right and from top to bottom until the first black pixel B21(X21, Y21) is found. The black closed frame containing the first black pixel B21 is defined as the second black closed frame 02A, the first black pixel B21(X21, Y21) is defined as the first black pixel B21(X21, Y21) of the second black closed frame 02A, the first sub-image located inside the second black closed frame is defined as the second first sub-image 02, and the image formed by all areas enclosed by the second black closed frame is defined as the second second sub-image 02B. Exemplarily, the shape of the second black closed frame 02A is a circular black closed frame, and the black pixels constituting the black circular closed frame are as follows: Figure 7 The distribution shown, from Figure 7 It can be seen that the figure formed by connecting all the black pixels after magnification is not a circle.
[0066] Step 2212: The computer uses the first black pixel B21 (X21, Y21) of the second black closed frame 02A as the search starting point, and searches in a clockwise or counterclockwise direction (clockwise in this application), according to the eight-neighborhood image processing principle described above, to search for all black pixels of the second black closed frame in sequence: the second black pixel B22 (X22, Y22), the third black pixel B23 (X23, Y23).... When the first black pixel B21 (X21, Y21) is retrieved again, the search for all black pixels of the second black closed frame 02A is completed.
[0067] Step 2213: The computer intercepts along the trajectory of the second black closed frame 02A to obtain the second second sub-image 02B. After completing the search of all black pixels of the second black closed frame 02A, the computer obtains the trajectory of the second black closed frame 02A. The computer segments the second second sub-image 02B according to the trajectory of the second black closed frame 02A. Figure 2 Become like Figure 8 The image shown: that is, there are 3 second sub-images 03B-05B left.
[0068] refer to Figure 6 and Figure 8 After the computer has segmented the second second sub-image 02B, it uses the first black pixel B21 (X21, Y21) of the second black closed frame 02A as the search starting point, and searches for black pixels row by row from left to right and from top to bottom. When the black pixel B31 (X31, Y31) is first searched, the black closed frame corresponding to the black pixel B31 (X31, Y31) is named the third black closed frame 03A, and the image of the area enclosed by the third black closed frame 03A is defined as the third second sub-image 03B, and the first sub-image located inside it is defined as the third first sub-image 03A. The computer then uses the black pixel B31 (X31, Y31) as the search starting point, and searches for all black pixels of the third black closed frame 03A in turn in a clockwise direction according to the eight-neighborhood image processing principle, and finally segments the third second sub-image 03B according to the trajectory shown by the third black closed frame 03A.
[0069] Use the same idea to segment the fourth second sub-image, the Nth second sub-image, etc., until all the sub-images are segmented. Figure 2 It becomes a blank image without any black pixels.
[0070] From the above description we can analyze:
[0071] Before exposing the first second sub-image, the computer first needs to search from the initial position o(0,0) in order from left to right and from top to bottom until the first black pixel is first retrieved, and the first black pixel is used as the first black pixel of the first black closed frame. Then, starting from the first black pixel, all black pixels of the first black closed frame are retrieved one by one in a clockwise or counterclockwise direction according to the eight-neighborhood image processing principle, and the trajectory of the first black closed frame is obtained. The first black closed frame is used as the segmentation trajectory to segment the first second sub-image.
[0072] The computer then uses the first black pixel of the first black closed frame as the starting point, and searches one by one from left to right and from top to bottom until the first black pixel is found, and uses the black closed frame corresponding to the first black pixel as the second black closed frame. Then, using the first black pixel as the starting point, all the black pixels of the second black closed frame are searched one by one in a clockwise or counterclockwise direction according to the eight-neighborhood image processing principle, and the trajectory of the second black closed frame is obtained. The second black closed frame is used as the segmentation trajectory to segment the second sub-image of the second frame.
[0073] The computer sequentially segments the third second sub-image to the last second sub-image using the same idea as that of segmenting the second second sub-image, thereby completing the segmentation of all second sub-images of the second image.
[0074] Through the above method, N first sub-images located on the first image can be quickly and individually segmented for use in laser direct plate making, thereby improving image processing efficiency.
[0075] It should be noted that the order in which the N first sub-images on the first image are named: the first first sub-image, the second second sub-image, ... the Nth second sub-image has nothing to do with their arrangement order.
[0076] refer to Fig. 9 , the embodiment of the present application also discloses an image segmentation device, including:
[0077] A black closed frame adding module is used to: add a black closed frame of any shape to the periphery of each of the N first sub-images on the first image to obtain a second image, wherein the second image includes the N second sub-images, and each second sub-image includes all image areas including the first sub-image enclosed by the corresponding black closed frame; wherein the shapes of the N black closed frames may be the same or different from each other;
[0078] The image segmentation module is used to retrieve all black pixels of each black closed frame in turn according to the eight-neighborhood image processing principle, and use each black closed frame as a segmentation trajectory to sequentially segment N second sub-images.
[0079] The functional modules of the above image segmentation device have been described in detail when introducing the segmentation method, and will not be repeated here. The technical effect of the image segmentation device is the same as that of the image processing method, and will not be repeated here.
[0080] The present application also discloses a storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the aforementioned image segmentation method can be implemented. The storage medium refers to a carrier for storing data. For example, a floppy disk, an optical disk, a DVD, a hard disk, a flash memory, a USB flash disk, a CF card, an SD card, an MMC card, a SM card, a memory stick (Memory Stick), an xD card, etc. Popular storage media are media based on flash memory (Nand flash), such as a USB flash disk, a CF card, an SD card, an SDHC card, an MMC card, a SM card, a memory stick, an XD card, etc.
[0081] The embodiment of the present application also discloses a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the aforementioned image segmentation method when executing the program. The processor includes a kernel, and the kernel retrieves the corresponding program unit from the memory, and one or more kernels may be provided. The memory may include a non-permanent memory in a computer-readable medium, a random access memory (RAM) and / or a non-volatile memory, such as a read-only memory (ROM) or a flash memory (flash RAM), and the memory includes at least one memory chip.
[0082] The image segmentation method, device, storage medium and computer equipment disclosed in the embodiments of the present application can achieve the following technical effects: N first sub-images located on the first image can be quickly and individually segmented for use in laser direct platemaking, thereby improving image processing efficiency.
[0083] Finally, it should be noted that the above are only preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, it is still possible for those skilled in the art to modify the technical solutions described in the aforementioned embodiments, or to make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. An image segmentation method, characterized in that: include: Step 1: Add a black closed frame of any shape to the periphery of each of the N first sub-images on the first image to obtain a second image, wherein the second image includes N second sub-images, and each of the second sub-images includes all image regions including the first sub-image enclosed by the corresponding black closed frame; wherein the shapes and sizes of the N black closed frames are the same or different; Step 2: All black pixels of each black closed frame are retrieved in turn according to the eight-neighborhood image processing principle, and each black closed frame is used as a segmentation trajectory to sequentially segment N second sub-images.
2. The image segmentation method according to claim 1, characterized in that: In step 2, sequentially dividing N second sub-images includes: Step 21: firstly segment the first second sub-image; Step 22: Then, the remaining N-1 second sub-images are segmented in sequence.
3. The image segmentation method according to claim 2, characterized in that: Step 21 includes: Step 211: define the upper left corner position of the second image as the initial position o(0,0), the computer starts from the initial position o(0,0), searches row by row from left to right and from top to bottom until the first black pixel B11 (X11, Y11) is first retrieved, define the black closed frame containing the first black pixel B11 as the first black closed frame, define the first black pixel B11 (X11, Y11) as the first black pixel of the first black closed frame, define the first sub-image located inside the first black closed frame as the first first sub-image, and define the image in all areas enclosed by the first black closed frame as the first second sub-image; Step 212: The computer uses the first black pixel B11 (X11, Y11) of the first black closed frame as the search starting point, and searches for all black pixels of the first black closed frame in a clockwise or counterclockwise direction according to the eight-neighborhood image processing principle, until the black pixel B11 (X11, Y11) is found again, thereby completing the search for all black pixels of the first black closed frame; Step 213: The computer segments the first second sub-image along the trajectory of the first black closed frame.
4. The image segmentation method according to claim 3, characterized in that: Step 22 includes: Step 221: The computer segments a second second sub-image along the trajectory of the second black closed frame; Step 222: Using the same idea as segmenting the second second sub-image, the computer sequentially segments the remaining N-2 second sub-images.
5. The image segmentation method according to claim 4, characterized in that: Step 221 includes: Step 2211: The computer takes the black pixel (X11, Y11) as the starting point, and searches row by row from left to right and from top to bottom until the first black pixel B21 (X21, Y21) is first searched, and a black closed frame including the first black pixel B21 is defined as a second black closed frame, and the first black pixel B21 (X21, Y21) is defined as the first black pixel of the second black closed frame, and the first sub-image located inside the second black closed frame is defined as the second first sub-image, and the image formed by all areas enclosed by the second black closed frame is defined as the second second sub-image; Step 2212: The computer uses the first black pixel (X21, Y21) of the second black closed frame as the search starting point, and searches for all black pixels of the second black closed frame in a clockwise or counterclockwise direction according to the eight-neighborhood image processing principle, until the black pixel (X21, Y21) is found again, thereby completing the search for all black pixels of the second black closed frame; Step 2213: The computer intercepts along the trajectory of the first black closed frame to obtain the second second sub-image.
6. An image segmentation device, characterized in that: include: A black closed frame adding module is used to: add a black closed frame of any shape to the periphery of each of the N first sub-images on the first image to obtain a second image, wherein the second image includes the N second sub-images, and each of the second sub-images includes all image areas including the first sub-image enclosed by the corresponding black closed frame; wherein the shapes of the N black closed frames may be the same or different from each other; The image segmentation module is used to retrieve all black pixels of each black closed frame in turn according to the eight-neighborhood image processing principle, and use each black closed frame as a segmentation trajectory to sequentially segment N second sub-images.
7. The image segmentation device according to claim 6, characterized in that: The image segmentation module is used to segment the first first sub-image, and the steps of obtaining the first second sub-image are: The upper left corner position of the second image is defined as the initial position o(0,0). The computer starts from the initial position o(0,0) and searches row by row from left to right and from top to bottom until the first black pixel B11(X11, Y11) is first searched. The black closed frame containing the first black pixel B11 is defined as the first black closed frame. The first black pixel B11(X11, Y11) is defined as the first black pixel of the first black closed frame. The first sub-image located inside the first black closed frame is defined as the first first sub-image. The image in all areas enclosed by the first black closed frame is defined as the first second sub-image. Taking the first black pixel (X11, Y11) of the first black closed frame as the search starting point, all black pixels of the first black closed frame are searched in turn in a clockwise or counterclockwise direction according to the eight-neighborhood image processing principle until the black pixel (X11, Y11) is retrieved again, thereby completing the search of all black pixels of the first black closed frame; The first second sub-image is obtained by intercepting along the trajectory of the first black closed frame.
8. The image segmentation device according to claim 7, characterized in that: The image segmentation module is used to segment the second first sub-image, and the steps of obtaining the second second sub-image are: Taking the black pixel (X11, Y11) as the starting point, searching row by row in the order from left to right and from top to bottom until the first black pixel B21 (X21, Y21) is first retrieved, defining the black closed frame containing the first black pixel B21 as the second black closed frame, defining the first black pixel B21 (X21, Y21) as the first black pixel of the second black closed frame, defining the first sub-image located inside the second black closed frame as the second first sub-image, and defining the image formed by all areas enclosed by the second black closed frame as the second second sub-image; Taking the first black pixel (X21, Y21) of the second black closed frame as the search starting point, all black pixels of the second black closed frame are searched in turn in a clockwise or counterclockwise direction according to the eight-neighborhood image processing principle until the black pixel (X21, Y21) is retrieved again, thereby completing the search of all black pixels of the first black closed frame; The first second sub-image is obtained by intercepting along the trajectory of the first black closed frame.
9. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the image segmentation method according to any one of claims 1 to 5 are implemented.
10. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the image segmentation method according to any one of claims 1 to 5 are implemented.