CN110675384B - Image processing method and device - Google Patents
Image processing method and device Download PDFInfo
- Publication number
- CN110675384B CN110675384B CN201910909459.6A CN201910909459A CN110675384B CN 110675384 B CN110675384 B CN 110675384B CN 201910909459 A CN201910909459 A CN 201910909459A CN 110675384 B CN110675384 B CN 110675384B
- Authority
- CN
- China
- Prior art keywords
- rectangular
- rectangular frame
- target
- position information
- target image
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/0002—Inspection of images, e.g. flaw detection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/30—Subject of image; Context of image processing
- G06T2207/30204—Marker
- G06T2207/30208—Marker matrix
Landscapes
- Engineering & Computer Science (AREA)
- Quality & Reliability (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Image Analysis (AREA)
Abstract
The application provides an image processing method and an image processing device, wherein the image processing method comprises the following steps: acquiring position information of an initial element in a target image; detecting a blank area in the target image according to the position information of the initial element to obtain at least one rectangular frame and position information of the rectangular frame, wherein the rectangular frame is used for representing the blank area in the target image; and marking at least one rectangular frame in the target image according to the rectangular frame and the position information of the rectangular frame. According to the image processing method and device, the blank area in the target image is detected, the rectangular frame representing the blank area is automatically marked in the target image, and marking efficiency and marking accuracy of the blank area in the image are effectively improved.
Description
Technical Field
The present application relates to the field of image processing technologies, and in particular, to an image processing method and apparatus.
Background
In an image, an area other than a filler element (e.g., a filler pattern, a filler text, etc.) may be referred to as a blank area, and the blank area can play a role in guiding a visual flow, emphasizing subject matter, alleviating visual fatigue, and the like. Too much or too little blank area affects the visual effect, and therefore, the blank area is also an important reference factor in the image.
At present, blank areas in images are usually marked manually by processing personnel, and the method is often laborious and time-consuming and has low efficiency, and the situation of marking errors is easy to occur in complex images, which is not beneficial to the calculation of image blank area ratio and the like.
Disclosure of Invention
An object of the embodiments of the present application is to provide an image processing method and apparatus, which automatically mark a rectangular frame representing a blank area in a target image by detecting the blank area in the target image, thereby effectively improving marking efficiency and marking accuracy of the blank area in the image.
In a first aspect, an embodiment of the present application provides an image processing method, including:
acquiring position information of an initial element in a target image;
detecting a blank area in the target image according to the position information of the initial element to obtain at least one rectangular frame and position information of the rectangular frame, wherein the rectangular frame is used for representing the blank area in the target image;
and marking at least one rectangular frame in the target image according to the rectangular frame and the position information of the rectangular frame.
In the implementation process, the distribution of the initial elements in the target image can be determined by the position information of the initial elements in the target image, the blank area in the target image is automatically detected through the distribution of the initial elements in the target image, so that the rectangular frame for representing the blank area and the position information of the rectangular frame are obtained, and then the blank area is marked by the rectangular frame in the target image.
Further, after the obtaining of the position information of the initial element in the target image, before the detecting of the blank area in the target image according to the position information of the initial element and obtaining of the position information of at least one rectangular frame and the rectangular frame, the method further includes:
judging whether the initial element crosses the boundary of the target image or not according to the position information of the initial element;
if so, adjusting the position of the initial element or the position of the target image boundary so as to adjust the initial element crossing the target image boundary into the boundary of the target image;
and position information of the initial element in the target image is acquired again.
In the implementation process, when the method judges that the initial element crosses the boundary of the target image, the position of the initial element or the position of the boundary of the target image is adjusted, so that the initial element crossing the boundary of the target image falls in the boundary of the target image, and the influence of the initial element crossing the boundary of the target image on the visual effect and expression of the target image is avoided; and the position information of the initial element in the target image can be obtained again, so that the accuracy of the obtained rectangular frame and the position information of the rectangular frame is guaranteed, and the marking accuracy of the hollow white area in the image is guaranteed.
Further, the detecting the blank area in the target image according to the position information of the initial element to obtain at least one rectangular frame and position information of the rectangular frame includes:
setting a dot matrix in the target image;
and detecting a blank area in the target image on each point outside the initial element according to the position information of the initial element to obtain at least one rectangular frame meeting a preset selection rule and position information of the rectangular frame, wherein each point outside the initial element is a point in the dot matrix.
In the implementation process, the method sets the dot matrix in the target image, and the rectangular frame for representing the blank area is obtained based on the dot matrix, so that the setting of the dot matrix greatly reduces the calculation amount, facilitates the determination of the rectangular frame, and enables the rectangular frame to be more regular.
Further, the detecting the blank area in the target image at each point outside the initial element according to the position information of the initial element to obtain at least one rectangular frame meeting a preset selection rule and position information of the rectangular frame includes:
according to the position information of the initial element, connecting all points outside the initial element along the x-axis direction to obtain all transverse connecting lines;
On each point outside the initial element, obtaining a first rectangle set by the movement of the transverse connecting line along the y-axis direction, wherein the first rectangle set comprises at least one rectangle frame and position information of the rectangle frame;
connecting all points outside the initial element along the y-axis direction according to the position information of the initial element to obtain all vertical connecting lines;
at each point outside the initial element, obtaining a second rectangle set by the movement of the vertical connecting line along the x-axis direction, wherein the second rectangle set comprises at least one rectangle frame and position information of the rectangle frame;
and filtering the position information of the rectangular frames and the rectangular frames in the first rectangular set and the second rectangular set, and reserving the position information of the rectangular frames and the rectangular frames which are not overlapped and the position information of the rectangular frames and the rectangular frames which are overlapped and have the largest area.
In the implementation process, the method obtains the first rectangular set through the determination mode of the first rectangular frame, obtains the second rectangular set through the determination mode of the second rectangular frame, obtains all initial rectangular frames firstly, avoids missing possible rectangular frames, and further filters out unsuitable rectangular frames, so that the reserved rectangular frames can clearly mark blank areas of the image and completely mark the blank areas of the image as much as possible.
Further, the filtering the position information of the rectangular frames and the rectangular frames in the first rectangular set and the second rectangular set, and keeping the position information of the rectangular frames and the rectangular frames which are not overlapped and the position information of the rectangular frames and the rectangular frames which are overlapped and have the largest area, includes:
judging whether the positions of any rectangular frame in the first rectangular set and any rectangular frame in the second rectangular set are overlapped or not;
if so, keeping the position information of the rectangular frame with the largest area and the rectangular frame with the largest area;
judging whether the positions of any two rectangular frames in the first rectangular set are overlapped;
if so, retaining the position information of the rectangular frame with the largest area and the rectangular frame with the largest area;
judging whether the positions of any two rectangular frames in the second rectangular set are overlapped;
if so, the position information of the rectangular frame with the largest area and the rectangular frame with the largest area is reserved.
In the implementation process, the method well filters out the unsuitable rectangular frame, and avoids filtering out the suitable rectangular frame in the filtering process, so that the reserved rectangular frame can clearly and completely mark the blank area of the image.
Further, after the marking at least one rectangular frame in the target image according to the rectangular frame and the position information of the rectangular frame, the method further includes:
acquiring elements to be filled of the target image;
judging whether a fillable rectangular frame exists in all the rectangular frames, wherein the fillable rectangular frame is a rectangular frame capable of accommodating the element to be filled;
if yes, all the fillable rectangular frames are obtained;
filling the elements to be filled in the fillable rectangular frames with the smallest area in all the fillable rectangular frames;
if not, the filling is cancelled.
In the implementation process, the method can automatically fill the elements to be filled into the rectangular frame to be filled and the rectangular frame to be filled with the smallest area, manual filling by a processor is not needed, filling efficiency of the elements to be filled is effectively improved, occupation of the space of the blank area is fully reduced, and filling of other elements to be filled is facilitated.
Further, after the marking at least one rectangular frame in the target image according to the rectangular frame and the position information of the rectangular frame, the method further includes:
Acquiring initial elements with overlapping in the target image;
judging whether the initial elements with the overlap are overlapped after being moved away;
if the overlapped initial elements are overlapped after being moved away, selecting any target initial element from the overlapped initial elements, and judging whether a first target rectangular frame exists in all the rectangular frames, wherein the first target rectangular frame is a rectangular frame capable of accommodating the target initial elements;
if the first target rectangular frame exists in all the rectangular frames, acquiring all the first target rectangular frames;
and moving the target initial element to the first target rectangular box with the smallest area in all the first target rectangular boxes.
In the implementation process, when the method judges that the overlapped initial elements still have the overlap after being moved away, any one of the target initial elements is selected, the target initial element is moved into the first target rectangular frame and is moved into the first target rectangular frame with the smallest area, manual operation of a processing person is not needed, the processing efficiency of the overlapped initial elements is effectively improved, and the occupation of the blank area space is fully reduced.
Further, if the first target rectangular frame does not exist in all the rectangular frames, selecting another target initial element from the overlapped initial elements, and judging whether a second target rectangular frame exists in all the rectangular frames, wherein the second target rectangular frame is a rectangular frame capable of accommodating another target initial element;
if the second target rectangular frames exist in all the rectangular frames, acquiring all the second target rectangular frames;
and moving another target initial element to the second target rectangular box with the smallest area in all the second target rectangular boxes.
In the implementation process, when the method judges that the first target rectangular frame does not exist, another target initial element is selected, and the other target initial element is moved into the second target rectangular frame and the second target rectangular frame with the smallest area, so that the processing efficiency of the overlapped initial elements is better, and meanwhile, the occupation of the blank area space is fully reduced.
In a second aspect, an embodiment of the present application provides an image processing apparatus, including:
the acquisition module is used for acquiring the position information of the initial element in the target image;
a detection module, configured to detect a blank area in the target image according to the position information of the initial element, to obtain at least one rectangular frame and position information of the rectangular frame, where the rectangular frame is used to represent the blank area in the target image;
And the generating module is used for marking at least one rectangular frame in the target image according to the rectangular frame and the position information of the rectangular frame.
In the implementation process, the distribution of the initial elements in the target image can be determined by the position information of the initial elements in the target image, the blank area in the target image is automatically detected through the distribution of the initial elements in the target image, so that the rectangular frame for representing the blank area and the position information of the rectangular frame are obtained, and then the blank area is marked by the rectangular frame in the target image.
In a third aspect, an embodiment of the present application provides an electronic device, including a memory and a processor, where the memory is used to store a computer program, and the processor runs the computer program to make the electronic device execute the above-mentioned image processing method.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program used in the electronic device described above.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and that those skilled in the art can also obtain other related drawings based on the drawings without inventive efforts.
Fig. 1 is a schematic flowchart of an image processing method according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a target image according to an embodiment of the present disclosure;
FIG. 3 is a schematic diagram of a target image indicating a blank area of the target image according to an embodiment of the present disclosure;
fig. 4 is a schematic flowchart of step S120 according to a first embodiment of the present application;
fig. 5 is a schematic flowchart of step S122 according to a first embodiment of the present application;
fig. 6 is a schematic diagram of a target image when a rectangular frame is filtered out according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of an image processing apparatus according to a second embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined or explained in subsequent figures. Meanwhile, in the description of the present application, the terms "first", "second", and the like are used only for distinguishing the description, and are not construed as indicating or implying relative importance.
At present, blank areas in images are usually marked manually by processing personnel, and the method is often laborious and time-consuming and has low efficiency, and the situation of marking errors is easy to occur in complex images, which is not beneficial to the calculation of image blank area ratio and the like.
In view of the above problems in the prior art, the present application provides an image processing method and apparatus, which automatically detect a blank area in a target image through distribution of initial elements in the target image, mark a rectangular frame representing the blank area in the target image, without manual marking by a processing person, and avoid the occurrence of an error in marking the blank area in a complex image due to omission of the processing person, thereby effectively improving marking efficiency and marking accuracy of the blank area in the image, and facilitating calculation of a blank area ratio of the image.
Example one
Referring to fig. 1, fig. 1 is a schematic flowchart of an image processing method according to an embodiment of the present application. The execution subject for executing the image processing method described below in the embodiments of the present application may be a personal computer or a server.
The image processing method of the embodiment of the application comprises the following steps:
step S110, position information of an initial element in the target image is acquired.
In the present embodiment, the target image may be a picture, an image in an image design process, an image in an image processing process, a text image, a slide image, or the like. Wherein the image in the image design process may be an image in a flat design process. The present embodiment mainly exemplifies an image in a planar design process as a target image.
Referring to fig. 2, fig. 2 is a schematic diagram of a target image provided in an embodiment of the present application, where four small boxes in a large box represent initial elements in the target image, the initial elements in the target image are filled elements in the target image, and the initial elements may be filled patterns, filled characters, and the like.
The position information of the initial element may include tag information of the initial element and coordinate information of the initial element. Alternatively, the tag information of the initial element may be a name of the initial element, a distinguishing code of the initial element, or the like, and the coordinate information of the initial element may be represented by a plurality of coordinates.
Alternatively, a coordinate system may be established for the origin of coordinates in the lower left corner of the large box in FIG. 2.
Optionally, when the position information of the initial element in the target image is obtained, the coordinate information and the tag information of each initial element may be extracted by using a deep convolutional network.
In this embodiment, the position information of the initial element in the target image can determine the distribution position or distribution condition of the initial element in the target image.
Step S120, detecting a blank area in the target image according to the position information of the initial element, to obtain at least one rectangular frame and position information of the rectangular frame, where the rectangular frame is used to indicate the blank area in the target image.
In the present embodiment, at least one rectangular frame is employed for representing a blank area in the target image. A blank area in the target image, i.e. an area other than the original elements.
The position information of the rectangular frame may include tag information of the rectangular frame and coordinate information of the rectangular frame. Alternatively, the label information of the rectangular frame may be a name of the rectangular frame, a distinguishing code of the rectangular frame, or the like, and the coordinate information of the rectangular frame may be represented by a plurality of coordinates. The position of a certain rectangular frame in the target image can be determined through the position information of the rectangular frame.
Alternatively, when there are a plurality of rectangular frames obtained, there is no overlapping portion between the plurality of rectangular frames. It should be noted that the overlapping emphasized by the embodiments of the present application includes complete overlapping and partial overlapping.
Optionally, the rectangular frame is a positive rectangular frame, and does not include an oblique rectangular frame. The positive rectangular frame is a rectangular frame which is arranged horizontally or vertically, and the oblique rectangular frame is a rectangular frame which is arranged obliquely.
In step S130, at least one rectangular frame is marked in the target image according to the rectangular frame and the position information of the rectangular frame.
Referring to fig. 3, fig. 3 is a schematic diagram of a target image indicating a blank area of the target image according to an embodiment of the present application, where a dashed box in the diagram is a rectangular box representing the blank area of the target image.
In this embodiment, the marked rectangular frame is embodied by a dotted line, and in other embodiments, the marked rectangular frame may also be embodied in other ways.
According to the image processing method, the distribution of the initial elements in the target image can be determined according to the position information of the initial elements in the target image, the blank area in the target image is automatically detected according to the distribution of the initial elements in the target image, the rectangular frame used for representing the blank area and the position information of the rectangular frame are obtained, and then the blank area is marked in the target image by the rectangular frame.
Assuming that the ratio of the blank area of the target image needs to be calculated, the area of all rectangular frames marked in the target image can be calculated and obtained, and then the area is divided by the total area of the target image, so that the calculation is more convenient and quicker.
In order to avoid the situation that an initial element occasionally crosses a boundary of a target image in an image in a planar design process, where the appearance of the situation more or less affects the visual effect and the expression of the target image, embodiments of the present application provide a possible implementation manner, after obtaining position information of the initial element in the target image, and before detecting a blank area in the target image according to the position information of the initial element and obtaining position information of at least one rectangular frame and a rectangular frame, an image processing method of an embodiment of the present application further includes:
judging whether the initial element crosses the boundary of the target image according to the position information of the initial element;
if so, adjusting the position of the initial element or the position of the target image boundary so as to adjust the initial element crossing the target image boundary into the boundary of the target image;
and position information of the initial element in the target image is acquired again.
In this embodiment, referring to fig. 2, the four edges of the large box in fig. 2 are the boundaries of the target image.
When adjusting the position of the initial element or the position of the target image boundary, only the position of the initial element crossing the target image boundary may be adjusted; the positions of the initial elements crossing the boundary of the target image and the positions of the other individual initial elements can also be adjusted; only the position of the boundary of the target image may be adjusted; the position of the initial element that crosses the boundary of the target image and the position of the boundary of the target image may also be adjusted.
After the position of the initial element or the position of the boundary of the target image is adjusted, the position information of the initial element is changed, and therefore, the position information of the initial element in the target image needs to be acquired again.
In such an embodiment, the method avoids that the initial elements crossing the boundary of the target image affect the visual effect and expression of the target image; and the accuracy of the obtained rectangular frame and the position information of the rectangular frame is guaranteed, so that the marking accuracy of the hollow area in the image is guaranteed.
Referring to fig. 4, fig. 4 is a schematic flowchart of a step S120 provided in this embodiment of the present application, as an optional implementation manner, the image processing method according to this embodiment of the present application, which detects a blank area in a target image according to position information of an initial element, to obtain position information of at least one rectangular frame and a rectangular frame, includes:
Step S121, setting a dot matrix in a target image;
and step S122, detecting blank areas in the target image on all points outside the initial elements according to the position information of the initial elements to obtain at least one rectangular frame meeting a preset selection rule and the position information of the rectangular frame, wherein all the points outside the initial elements are points in the dot matrix.
In setting the dot matrix in the target image, the distances between adjacent dots are equal. In the lattice, points falling within the initial element and points outside the initial element are included.
The rectangular frame meeting the preset selection rule is obtained on the basis of points outside the initial elements in the dot matrix, namely four end points of the rectangular frame are all positioned on the points outside the initial elements in the dot matrix. Alternatively, when a plurality of rectangular frames are obtained, there is no overlapping portion between the plurality of rectangular frames.
In this embodiment, the rectangular frame used for representing the blank area is obtained based on the dot matrix, and the arrangement of the dot matrix greatly reduces the calculation amount, facilitates the determination of the rectangular frame, and makes the rectangular frame more regular.
Referring to fig. 5, fig. 5 is a schematic flowchart of step S122 provided in the embodiment of the present application. Optionally, in step S122, detecting blank areas in the target image at each point outside the initial element according to the position information of the initial element, to obtain at least one rectangular frame and position information of the rectangular frame, where the at least one rectangular frame and the position information of the rectangular frame meet a preset selection rule, where the step S includes:
S122-1, connecting all points outside the initial element along the x-axis direction according to the position information of the initial element to obtain all transverse connecting lines;
s122-2, moving a transverse connecting line along the y-axis direction at each point outside the initial element to obtain a first rectangle set, wherein the first rectangle set comprises at least one rectangle frame and position information of the rectangle frame;
s122-3, connecting all points outside the initial element along the y-axis direction according to the position information of the initial element to obtain all vertical connecting lines;
s122-4, moving each point outside the initial elements along the x-axis direction by using a vertical connecting line to obtain a second rectangular set, wherein the second rectangular set comprises at least one rectangular frame and position information of the rectangular frame;
and S122-5, filtering the position information of the rectangular frames and the rectangular frames in the first rectangular set and the second rectangular set, and reserving the position information of the rectangular frames and the rectangular frames which are not overlapped and the position information of the rectangular frames and the rectangular frames which are overlapped and have the largest area.
The lattice comprises a plurality of rows of transverse dots and a plurality of columns of vertical dots, wherein each row of transverse dots is in the direction of an x axis, and each column of vertical dots is in the direction of a y axis.
Describing by transverse connecting lines, if an initial element exists on a row of transverse points, at least two transverse connecting lines exist on the row of transverse points, and the points which fall in the initial element on the row of transverse points are not connected; if there is no initial element on the row of transverse points, there is one and only one transverse connecting line on the row of transverse points. The same is true for the transverse connection lines at each row of transverse points, and the transverse connection lines at each row of transverse points are independent.
When a certain transverse connecting line moves along the y-axis direction, if the transverse connecting line touches the initial element, the movement is stopped, and a rectangular frame determined by the transverse connecting line can be obtained; if the horizontal connecting line moves to the bottom end in the dot matrix and the initial element is not touched, a determined rectangular frame is obtained by the starting point of the horizontal connecting line and the bottom end in the dot matrix.
For the vertical connecting lines and the rectangular frames determined by the vertical connecting lines, the above contents are referred to, and are not repeated herein.
Referring to fig. 6, fig. 6 is a schematic diagram of a target image when a rectangular frame is filtered out according to an embodiment of the present application. The large square frame represents the boundary of the target image, the small solid line square frame represents the initial element in the target image, a rectangular frame determined by a transverse connecting line is transversely arranged in the two dotted line rectangular frames, and a rectangular frame determined by a vertical connecting line is vertically arranged in the two dotted line rectangular frames. As can be seen from the figure, the two dotted line rectangular frames overlap, and the area of the vertically arranged dotted line rectangular frame is larger than that of the horizontally arranged dotted line rectangular frame, so that the horizontally arranged dotted line rectangular frame is filtered out and the vertically arranged dotted line rectangular frame is retained in the two dotted line rectangular frames.
In filtering out the rectangular frames and the position information of the rectangular frames, there may be two overlapped rectangular frames, or more than two overlapped rectangular frames.
The method comprises the steps of obtaining a first rectangular set through a first rectangular frame determining mode, obtaining a second rectangular set through a second rectangular frame determining mode, obtaining all initial rectangular frames firstly, avoiding missing possible rectangular frames, and further filtering out unsuitable rectangular frames, so that the reserved rectangular frames can clearly mark blank areas of images and completely mark the blank areas of the images as far as possible.
Optionally, in step S122-5, filtering out the position information of the rectangular frames and the rectangular frames in the first rectangular set and the second rectangular set, and retaining the position information of the rectangular frame and the rectangular frame that are not overlapped and the position information of the rectangular frame and the rectangular frame that are overlapped and have the largest area, includes:
judging whether the positions of any rectangular frame in the first rectangular set and any rectangular frame in the second rectangular set are overlapped or not;
if so, retaining the position information of the rectangular frame with the largest area and the rectangular frame with the largest area;
judging whether the positions of any two rectangular frames in the first rectangular set are overlapped;
If so, keeping the position information of the rectangular frame with the largest area and the rectangular frame with the largest area;
judging whether the positions of any two rectangular frames in the second rectangular set are overlapped;
if so, the position information of the rectangular frame with the largest area and the rectangular frame with the largest area is reserved.
It should be noted that, in the above three determinations, the first determination is performed before the second determination and the third determination, and the second determination and the third determination may be performed simultaneously or sequentially, which is not limited herein.
In the process, the method well filters out the unsuitable rectangular frame, so that the filtering out process is avoided, and the reserved rectangular frame can clearly and completely mark the blank area of the image.
In an image in a planar design process, elements to be filled are generally manually filled by a processing person, and a manual filling manner of the processing person is often inefficient, in order to improve filling efficiency of the elements to be filled, an embodiment of the present application provides a possible implementation manner, after at least one rectangular frame is marked in a target image according to position information of the rectangular frame and the rectangular frame, an image processing method of the embodiment of the present application further includes:
Acquiring elements to be filled of a target image;
judging whether all the rectangular frames have a fillable rectangular frame which is a rectangular frame capable of accommodating elements to be filled;
if yes, all the fillable rectangular frames are obtained;
filling the elements to be filled in the fillable rectangular frames with the smallest area in all the fillable rectangular frames;
if not, the filling is cancelled.
Under the embodiment, the method can automatically fill the elements to be filled into the rectangular frame to be filled and the rectangular frame to be filled with the smallest area, manual filling by a processor is not needed, filling efficiency of the elements to be filled is effectively improved, occupation of the space of the blank area is fully reduced, and filling of other elements to be filled is facilitated.
In order to improve the processing efficiency of the initial elements with overlap, the embodiment of the present application provides a possible implementation manner, after at least one rectangular frame is marked in a target image according to position information of the rectangular frame and the rectangular frame, the image processing method of the embodiment of the present application further includes:
Acquiring initial elements with overlapping in a target image;
judging whether the initial elements with the overlap are overlapped after being moved away;
if the overlapped initial elements are overlapped after being moved away, selecting any target initial element from the overlapped initial elements, and judging whether a first target rectangular frame exists in all the rectangular frames, wherein the first target rectangular frame is a rectangular frame capable of accommodating the target initial elements;
if the first target rectangular frame exists in all the rectangular frames, acquiring all the first target rectangular frames;
and moving the target initial element to the first target rectangular box with the smallest area in all the first target rectangular boxes.
When judging whether the overlapped initial elements are overlapped after being moved away, any overlapped initial element can be moved away in a set range for judgment; the initial elements with the overlap are assumed to comprise two initial elements, and the two initial elements can be moved away within a set range for judgment.
In this embodiment, the method selects any one of the target initial elements, moves the target initial element into the first target rectangular frame, and moves the target initial element into the first target rectangular frame with the smallest area, so that manual operation by a handler is not required, the processing efficiency of the initial elements with overlap is effectively improved, and the occupation of the blank area space is sufficiently reduced.
Optionally, if the first target rectangular frame does not exist in all the rectangular frames, selecting another target initial element from the overlapped initial elements, and determining whether a second target rectangular frame exists in all the rectangular frames, where the second target rectangular frame is a rectangular frame capable of accommodating another target initial element;
if the second target rectangular frame exists in all the rectangular frames, acquiring all the second target rectangular frames;
and moving another target initial element to the second target rectangular box with the smallest area in all the second target rectangular boxes.
In the above process, when it is determined that the first target rectangular frame does not exist, the method selects another target initial element, moves the other target initial element into the second target rectangular frame, and moves the other target initial element into the second target rectangular frame with the smallest area, so as to better process efficiency of the initial element with overlap, and simultaneously, fully reduce occupation of blank area space.
Example two
In order to execute a corresponding method of the above-described embodiments to achieve corresponding functions and technical effects, an image processing apparatus is provided below.
Referring to fig. 7, fig. 7 is a schematic structural diagram of an image processing apparatus according to an embodiment of the present application.
The image processing apparatus of the embodiment of the present application includes:
the obtaining module 210 is configured to obtain position information of an initial element in the target image.
The detecting module 220 is configured to detect a blank area in the target image according to the position information of the initial element, to obtain at least one rectangular frame and position information of the rectangular frame, where the rectangular frame is used to represent the blank area in the target image.
The generating module 230 is configured to mark at least one rectangular frame in the target image according to the rectangular frame and the position information of the rectangular frame.
The image processing apparatus according to the embodiment of the present application, where the distribution of the initial elements in the target image can be determined by the position information of the initial elements in the target image, and the blank area in the target image is automatically detected by the distribution of the initial elements in the target image, so as to obtain the rectangular frame used for representing the blank area and the position information of the rectangular frame, and further the blank area is represented by the rectangular frame in the target image.
As an optional implementation manner, the image processing apparatus according to the embodiment of the present application may further include:
the judging module is used for judging whether the initial element crosses the boundary of the target image according to the position information of the initial element;
the adjusting module is used for adjusting the position of the initial element or the position of the target image boundary when the initial element crosses the boundary of the target image, so that the initial element crossing the target image boundary is adjusted to be in the boundary of the target image;
the obtaining module 210 may be further configured to obtain the position information of the initial element in the target image again.
As an optional implementation manner, the detection module 220 may be specifically configured to:
setting a dot matrix in the target image;
and detecting a blank area in the target image on each point outside the initial element according to the position information of the initial element to obtain at least one rectangular frame meeting a preset selection rule and the position information of the rectangular frame, wherein each point outside the initial element is a point in the dot matrix.
Further, the detecting module 220 may be further specifically configured to:
connecting all points outside the initial element along the x-axis direction according to the position information of the initial element to obtain all transverse connecting lines;
Moving a transverse connecting line along the y-axis direction on each point outside the initial element to obtain a first rectangle set, wherein the first rectangle set comprises at least one rectangle frame and position information of the rectangle frame;
according to the position information of the initial element, connecting all points outside the initial element along the y-axis direction to obtain all vertical connecting lines;
moving each point outside the initial element along the x-axis direction by using a vertical connecting line to obtain a second rectangular set, wherein the second rectangular set comprises at least one rectangular frame and position information of the rectangular frame;
and filtering the position information of the rectangular frames and the rectangular frames in the first rectangular set and the second rectangular set, and reserving the position information of the rectangular frames and the rectangular frames which are not overlapped and the position information of the rectangular frames and the rectangular frames which are overlapped and have the largest area.
Further, the detecting module 220 may be further specifically configured to:
judging whether the positions of any rectangular frame in the first rectangular set and any rectangular frame in the second rectangular set are overlapped or not;
if so, keeping the position information of the rectangular frame with the largest area and the rectangular frame with the largest area;
judging whether the positions of any two rectangular frames in the first rectangular set are overlapped;
If so, keeping the position information of the rectangular frame with the largest area and the rectangular frame with the largest area;
judging whether the positions of any two rectangular frames in the second rectangular set are overlapped;
if so, the position information of the rectangular frame with the largest area and the rectangular frame with the largest area is reserved.
As an optional implementation manner, the obtaining module 210 may be further configured to obtain elements to be filled in the target image;
the judging module can be further used for judging whether the rectangular frames which can be filled exist in all the rectangular frames, wherein the rectangular frames which can be filled are rectangular frames capable of containing elements to be filled;
the obtaining module 210 is further configured to obtain all fillable rectangular frames when fillable rectangular frames exist in all rectangular frames;
the image processing apparatus according to the embodiment of the present application may further include:
and the filling module is used for filling the elements to be filled in the fillable rectangular frames with the smallest area in all the fillable rectangular frames.
As an optional implementation, the obtaining module 210 may be further configured to obtain an initial element in the target image, where the initial element overlaps;
the judging module can also be used for judging whether the overlapped initial elements are overlapped after being moved away; judging whether a first target rectangular frame exists in all the rectangular frames, wherein the first target rectangular frame is a rectangular frame capable of accommodating target initial elements;
The obtaining module 210 may be further configured to select any target initial element from the initial elements with overlapping; when the first target rectangular frame exists in all the rectangular frames, acquiring all the first target rectangular frames;
the adjusting module may be further configured to move the target initial element to a first target rectangular box with a smallest area among all the first target rectangular boxes.
Optionally, the obtaining module 210 may be further configured to select another target initial element from the initial elements with overlapping, where the first target rectangular frame does not exist in all the rectangular frames; acquiring all second target rectangular frames;
the judging module can be further used for judging whether a second target rectangular frame exists in all the rectangular frames, wherein the second target rectangular frame is a rectangular frame capable of accommodating another target initial element;
the adjusting module may be further configured to move another target initial element to a second target rectangular box with a smallest area among all the second target rectangular boxes.
The image processing apparatus can implement the image processing method according to the first embodiment. The alternatives in the first embodiment are also applicable to the present embodiment, and are not described in detail here.
The rest of the embodiments of the present application may refer to the contents of the first embodiment, and in this embodiment, details are not repeated.
EXAMPLE III
An embodiment of the present application provides an electronic device, which includes a memory and a processor, where the memory is used to store a computer program, and the processor runs the computer program to make the electronic device execute the above-mentioned image processing method.
Alternatively, the electronic device may be a personal computer, a server, or the like.
In addition, an embodiment of the present application further provides a computer-readable storage medium, which stores a computer program used in the electronic device.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist alone, or two or more modules may be integrated to form an independent part.
The functions may be stored in a computer-readable storage medium if they are implemented in the form of software functional modules and sold or used as separate products. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above description is only an example of the present application and is not intended to limit the scope of the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily think of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
It should be noted that, in this document, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
Claims (9)
1. An image processing method, comprising:
acquiring position information of an initial element in a target image; the initial elements are filling patterns or filling characters in the target image;
judging whether the initial element crosses the boundary of the target image or not according to the position information of the initial element;
if so, adjusting the position of the initial element or the position of the target image boundary so as to adjust the initial element crossing the target image boundary into the boundary of the target image;
position information of an initial element in the target image is obtained again;
detecting a blank area in the target image according to the position information of the initial element to obtain at least one rectangular frame and position information of the rectangular frame, wherein the rectangular frame is used for representing the blank area in the target image;
marking at least one rectangular frame in the target image according to the rectangular frame and the position information of the rectangular frame;
after the marking at least one rectangular frame in the target image according to the rectangular frame and the position information of the rectangular frame, the method further comprises:
acquiring initial elements with overlapping in the target image;
Judging whether the initial elements with the overlap are overlapped after being removed;
if the overlapped initial elements are overlapped after being moved away, selecting any target initial element from the overlapped initial elements, and judging whether a first target rectangular frame exists in all the rectangular frames, wherein the first target rectangular frame is a rectangular frame capable of accommodating the target initial elements;
if first target rectangular frames exist in all the rectangular frames, acquiring all the first target rectangular frames;
and moving the target initial element to the first target rectangular box with the smallest area in all the first target rectangular boxes.
2. The image processing method according to claim 1, wherein the detecting a blank area in the target image according to the position information of the initial element to obtain at least one rectangular frame and position information of the rectangular frame comprises:
setting a dot matrix in the target image;
and detecting a blank area in the target image on each point outside the initial element according to the position information of the initial element to obtain at least one rectangular frame meeting a preset selection rule and position information of the rectangular frame, wherein each point outside the initial element is a point in the dot matrix.
3. The image processing method according to claim 2, wherein the detecting, according to the position information of the initial element, the blank area in the target image at each point outside the initial element to obtain at least one rectangular frame and position information of the rectangular frame that satisfy a preset selection rule includes:
connecting all points outside the initial element along the x-axis direction according to the position information of the initial element to obtain all transverse connecting lines;
on each point outside the initial element, obtaining a first rectangle set by the movement of the transverse connecting line along the y-axis direction, wherein the first rectangle set comprises at least one rectangle frame and position information of the rectangle frame;
connecting all points outside the initial element along the y-axis direction according to the position information of the initial element to obtain all vertical connecting lines;
at each point outside the initial element, obtaining a second rectangle set by the movement of the vertical connecting line along the x-axis direction, wherein the second rectangle set comprises at least one rectangle frame and position information of the rectangle frame;
and filtering the position information of the rectangular frames and the rectangular frames in the first rectangular set and the second rectangular set, and reserving the position information of the rectangular frames and the rectangular frames which are not overlapped and the position information of the rectangular frames and the rectangular frames which are overlapped and have the largest area.
4. The image processing method according to claim 3, wherein the filtering out the position information of the rectangular frames and the rectangular frames in the first rectangular set and the second rectangular set, and keeping the position information of the rectangular frames and the rectangular frames that are not overlapped and the position information of the rectangular frames and the rectangular frames that are overlapped and have the largest area comprises:
judging whether the positions of any rectangular frame in the first rectangular set and any rectangular frame in the second rectangular set are overlapped or not;
if so, keeping the position information of the rectangular frame with the largest area and the rectangular frame with the largest area;
judging whether the positions of any two rectangular frames in the first rectangular set are overlapped;
if so, keeping the position information of the rectangular frame with the largest area and the rectangular frame with the largest area;
judging whether the positions of any two rectangular frames in the second rectangular set are overlapped;
if so, the position information of the rectangular frame with the largest area and the rectangular frame with the largest area is reserved.
5. The image processing method according to claim 1, wherein after said marking at least one rectangular frame in the target image based on the rectangular frame and the position information of the rectangular frame, the method further comprises:
Acquiring elements to be filled of the target image;
judging whether a fillable rectangular frame exists in all the rectangular frames, wherein the fillable rectangular frame is a rectangular frame capable of accommodating the element to be filled;
if yes, all the fillable rectangular frames are obtained;
filling the elements to be filled in the fillable rectangular frames with the smallest area in all the fillable rectangular frames;
if not, the filling is cancelled.
6. The image processing method according to claim 1,
if the first target rectangular frame does not exist in all the rectangular frames, selecting another target initial element from the overlapped initial elements, and judging whether a second target rectangular frame exists in all the rectangular frames, wherein the second target rectangular frame is a rectangular frame capable of accommodating the other target initial element;
if the second target rectangular frames exist in all the rectangular frames, acquiring all the second target rectangular frames;
and moving another target initial element to the second target rectangular box with the smallest area in all the second target rectangular boxes.
7. An image processing apparatus characterized by comprising:
the acquisition module is used for acquiring the position information of the initial element in the target image; the initial elements are filling patterns or filling characters in the target image;
A detection module, configured to detect a blank area in the target image according to the position information of the initial element, to obtain at least one rectangular frame and position information of the rectangular frame, where the rectangular frame is used to represent the blank area in the target image;
the generating module is used for marking at least one rectangular frame in the target image according to the rectangular frame and the position information of the rectangular frame;
the judging module is used for judging whether the initial element crosses the boundary of the target image or not according to the position information of the initial element;
the adjusting module is used for adjusting the position of the initial element or the position of the target image boundary when the initial element crosses the boundary of the target image, so that the initial element crossing the target image boundary is adjusted to be in the boundary of the target image;
the acquisition module can be also used for acquiring the position information of the initial element in the target image again;
the acquisition module can be further used for acquiring overlapped initial elements in the target image;
the judging module can also be used for judging whether the overlapped initial elements are overlapped after being moved away; judging whether a first target rectangular frame exists in all the rectangular frames, wherein the first target rectangular frame is a rectangular frame capable of accommodating target initial elements;
The acquisition module can be further used for selecting any target initial element from the overlapped initial elements; when the first target rectangular frame exists in all the rectangular frames, acquiring all the first target rectangular frames;
the adjusting module may be further configured to move the target initial element to a first target rectangular box with a smallest area among all the first target rectangular boxes.
8. An electronic device, comprising a memory for storing a computer program and a processor for executing the computer program to cause the electronic device to perform the image processing method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that it stores a computer program for use in the electronic device of claim 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910909459.6A CN110675384B (en) | 2019-09-24 | 2019-09-24 | Image processing method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910909459.6A CN110675384B (en) | 2019-09-24 | 2019-09-24 | Image processing method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110675384A CN110675384A (en) | 2020-01-10 |
CN110675384B true CN110675384B (en) | 2022-06-07 |
Family
ID=69079171
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910909459.6A Active CN110675384B (en) | 2019-09-24 | 2019-09-24 | Image processing method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110675384B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111738275A (en) * | 2020-06-13 | 2020-10-02 | 玖壹叁陆零医学科技南京有限公司 | Generation method and training method of sampling frame and neural network |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103053169A (en) * | 2011-06-08 | 2013-04-17 | 松下电器产业株式会社 | Image processing device and image processing method |
CN103198310A (en) * | 2012-01-06 | 2013-07-10 | 富士施乐株式会社 | Image processing apparatus and image processing method |
CN104778489A (en) * | 2015-03-24 | 2015-07-15 | 立德高科(北京)数码科技有限责任公司 | Combined anti-counterfeit label, and generation method and generation device of combined anti-counterfeit label |
WO2017118377A1 (en) * | 2016-01-07 | 2017-07-13 | Mediatek Inc. | Method and apparatus of image formation and compression of cubic images for 360 degree panorama display |
CN110008809A (en) * | 2019-01-04 | 2019-07-12 | 阿里巴巴集团控股有限公司 | Acquisition methods, device and the server of list data |
CN110070094A (en) * | 2019-04-30 | 2019-07-30 | 济南浪潮高新科技投资发展有限公司 | A kind of AI digital recognition system and method |
CN110134347A (en) * | 2019-04-30 | 2019-08-16 | 深圳市雄帝科技股份有限公司 | Image processing method, device, computer equipment and storage medium |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107977995B (en) * | 2016-10-25 | 2022-05-06 | 菜鸟智能物流控股有限公司 | Target area position detection method and related device |
CN109547692B (en) * | 2018-10-26 | 2021-12-14 | 华为技术有限公司 | Image posture correction method, equipment and terminal |
-
2019
- 2019-09-24 CN CN201910909459.6A patent/CN110675384B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103053169A (en) * | 2011-06-08 | 2013-04-17 | 松下电器产业株式会社 | Image processing device and image processing method |
CN103198310A (en) * | 2012-01-06 | 2013-07-10 | 富士施乐株式会社 | Image processing apparatus and image processing method |
CN104778489A (en) * | 2015-03-24 | 2015-07-15 | 立德高科(北京)数码科技有限责任公司 | Combined anti-counterfeit label, and generation method and generation device of combined anti-counterfeit label |
WO2017118377A1 (en) * | 2016-01-07 | 2017-07-13 | Mediatek Inc. | Method and apparatus of image formation and compression of cubic images for 360 degree panorama display |
CN110008809A (en) * | 2019-01-04 | 2019-07-12 | 阿里巴巴集团控股有限公司 | Acquisition methods, device and the server of list data |
CN110070094A (en) * | 2019-04-30 | 2019-07-30 | 济南浪潮高新科技投资发展有限公司 | A kind of AI digital recognition system and method |
CN110134347A (en) * | 2019-04-30 | 2019-08-16 | 深圳市雄帝科技股份有限公司 | Image processing method, device, computer equipment and storage medium |
Non-Patent Citations (1)
Title |
---|
显微高光谱成像系统及大区域多维影像数据获取方法研究;袁晨;《中国优秀硕士学位论文全文数据库 工程科技Ⅱ辑》;20190915;摘要 * |
Also Published As
Publication number | Publication date |
---|---|
CN110675384A (en) | 2020-01-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110069767B (en) | Typesetting method based on electronic book, electronic equipment and computer storage medium | |
CN105469027B (en) | For the horizontal and vertical lines detection and removal of file and picture | |
CN108255489B (en) | Front-end interface code generation method and device, electronic equipment and storage medium | |
US9449210B2 (en) | Method and system for detecting a correction pattern in a QR code | |
CN110619333A (en) | Text line segmentation method, text line segmentation device and electronic equipment | |
CN115018895A (en) | Goods placing method, device, equipment and storage medium for high-level goods shelf of unmanned forklift | |
CN112446262A (en) | Text analysis method, text analysis device, text analysis terminal and computer-readable storage medium | |
CN106502701A (en) | The method and device of component alignment during a kind of establishment webpage | |
CN109754460B (en) | Automatic die overturning method, electronic equipment and storage medium | |
CN106934839B (en) | Automatic cutting method and device for CAD vector diagram | |
CN114627482B (en) | Method and system for realizing table digital processing based on image processing and character recognition | |
CN110675384B (en) | Image processing method and device | |
CN106528736A (en) | Method and apparatus for displaying alignment line during dragging of page components | |
US20150112644A1 (en) | Evaluating the stability of three-dimensional models | |
CN115249324A (en) | Method and device for determining position to be stacked in stack shape and computing equipment | |
CN109003257A (en) | A kind of optical character verification method | |
JP6377743B2 (en) | Method and apparatus for building an intermediate character library | |
CN107615333B (en) | Image speckle processing method | |
CN109948605A (en) | A kind of picture Enhancement Method and device for Small object | |
CN116168192A (en) | Image detection area determination method and device, electronic equipment and storage medium | |
JPH02232690A (en) | Data converting device | |
CN114022434B (en) | Automatic extraction method and extraction system for upper and lower side lines of guardrail | |
CN114219871A (en) | Obstacle detection method and device based on depth image and mobile robot | |
CN110135425A (en) | Sample mask method and computer storage medium | |
JP6512852B2 (en) | Information processing apparatus, information processing method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |