CN114549700A - Method and device for determining typesetting area based on cartoon translation - Google Patents

Method and device for determining typesetting area based on cartoon translation Download PDF

Info

Publication number
CN114549700A
CN114549700A CN202210172124.2A CN202210172124A CN114549700A CN 114549700 A CN114549700 A CN 114549700A CN 202210172124 A CN202210172124 A CN 202210172124A CN 114549700 A CN114549700 A CN 114549700A
Authority
CN
China
Prior art keywords
area
region
expansion
side boundary
translation
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.)
Pending
Application number
CN202210172124.2A
Other languages
Chinese (zh)
Inventor
王喆
范凌
梁天明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tezign Shanghai Information Technology Co Ltd
Original Assignee
Tezign Shanghai Information Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Tezign Shanghai Information Technology Co Ltd filed Critical Tezign Shanghai Information Technology Co Ltd
Priority to CN202210172124.2A priority Critical patent/CN114549700A/en
Publication of CN114549700A publication Critical patent/CN114549700A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/60Editing figures and text; Combining figures or text
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/109Font handling; Temporal or kinetic typography

Abstract

The invention provides a method and a device for determining a typesetting area based on cartoon translation.A plurality of groups of expansion step values in different directions are preset, and the expansion step values are used for gradually expanding a translation area to the horizontal direction and/or the vertical direction; based on a region progressive expansion method and each group of expansion step values, expanding the initial translation region to obtain a candidate expansion region, and calculating the area of the candidate expansion region; and selecting the expansion step value with the maximum expansion area, and taking the candidate expansion area corresponding to the step value as the target translation typesetting area. The invention can standardize the typesetting standard, reduce the influence of subjective factors in the translation process and realize that a machine automatically determines the optimal drawing area; and the labor participation is reduced, and the labor is saved.

Description

Method and device for determining typesetting area based on cartoon translation
Technical Field
The application relates to the technical field of computers, in particular to a method and a device for determining a typesetting area based on cartoon translation, computer equipment and a storage medium.
Background
People who have browsed the cartoon do not have strangeness to the word 'Hanhua group'. For a long time, the work of cartoon translation follows a set of flow with a long period and large repeated labor intensity.
The tools used by the cartoon translation group are mostly Photoshop (abbreviated as "PS"). As specialized sprite software, PS has a high learning cost and does not completely match the requirements of caricature translation. The cartoon translation group needs to manually extract and translate the character information in the picture, erase the original text in the picture, correspondingly embed the translated text one by one, adjust the font and the typesetting to be suitable for the original picture, and export the picture. With the continuous development of the domestic cartoon market, the cartoon translation field gradually develops related tools for assisting manual translation, wherein the related tools mainly relate to original text detection, text quick erasing, translation of different languages of translated text, multiple selection of font styles and the like of cartoon files to help manually reduce the complicated work of step-by-step operation ps.
Although the existing translation tool lightens part of manual work, the result of the translation tool still needs to be continuously corrected manually, and the existing cartoon translation tool has the following problems on the typesetting part:
in the prior art, a text editing area is mainly added in an original text area to directly fill a translated text, or simple grid division is performed according to the number of translated text words; the text area needs to be manually adjusted, and the mesh division mode has large influence on the typesetting of words with large length span such as English and the like, so that the problem of rough typesetting area determination is caused; and the extension of the translation region depends on artificial subjective judgment: and adding a text editing area, and then manually stretching and adapting, or directly typesetting by adopting the area of the original text.
Therefore, a layout area determination method and apparatus capable of automatically determining an optimal rendering area through a machine are needed.
Disclosure of Invention
The embodiment of the invention provides a method and a device for determining a typesetting area based on cartoon translation, computer equipment and a storage medium, which are used for solving the problems that the existing cartoon translation tool is rough in typesetting area determination, the extension of a translated region depends on artificial subjective judgment, and manual correction is needed, so that time and labor are wasted.
In order to achieve the above object, a first aspect of the embodiments of the present invention provides a method for determining a layout area based on cartoon translation, including:
presetting a plurality of groups of expansion step values in different directions, wherein the expansion step values are used for gradual expansion of a translation region in the horizontal and/or vertical direction;
based on a region progressive expansion method and each group of expansion step values, expanding the initial translation region to obtain a candidate expansion region, and calculating the area of the candidate expansion region;
and selecting the expansion step value with the maximum expansion area, and taking the candidate expansion area corresponding to the step value as the target translation typesetting area.
Optionally, in a possible implementation manner of the first aspect, the expanding the initial translation region based on the region progressive expansion method and each group of expansion step values to obtain a candidate expansion region, and calculating an area of the candidate expansion region includes:
acquiring rectangular coordinates of an initial translation region, wherein the rectangular coordinates are coordinates of upper, lower, left and right vertex positions of the initial translation region, and calculating a pixel mean value of the initial translation region according to the rectangular coordinates;
selecting any one side boundary of the initial translation region, wherein the side boundary comprises: a left side boundary, an upper side boundary, a right side boundary, a lower side boundary;
expanding the side boundary outwards towards the corresponding side based on the expansion step value to obtain a current expansion area, and calculating the pixel mean value of the current expansion area according to the rectangular coordinate of the current expansion area;
determining side boundary coordinate values of the candidate expansion region according to the pixel mean values of the current expansion region and the initial translation region, wherein the side boundary coordinate values comprise: an upper boundary ordinate, a lower boundary ordinate, a left boundary abscissa, and a right boundary abscissa.
Optionally, in a possible implementation manner of the first aspect, the determining, according to a pixel mean of the current expanded region and the initial translation region, side boundary coordinate values of the candidate expanded region includes:
if the pixel mean difference value between the current expansion area and the initial translation area is larger than a preset threshold value, taking the corresponding side boundary coordinate value of the initial translation area as the side boundary coordinate value of the candidate expansion area;
and if the pixel mean difference value between the current expansion area and the initial translation area is smaller than or equal to a preset threshold value, taking the corresponding side boundary coordinate value of the current expansion area as the side boundary coordinate value of the candidate expansion area.
Optionally, in a possible implementation manner of the first aspect, the method further includes:
based on the expansion step value, expanding the initial translation region respectively towards four directions, namely, up, down, left and right, to obtain four side boundary coordinate values of the candidate expansion region;
calculating the area of the candidate expansion region based on the four side boundary coordinate values.
Optionally, in a possible implementation manner of the first aspect, calculating a pixel mean of the initial translation region according to the rectangular coordinates includes:
according to the rectangular coordinates of the initial translation region, carrying out cutout processing on the original picture at a corresponding position by utilizing the existing computer image processing library;
based on the pixel representation of the image after the matting process, the average value of all pixels in the image is calculated by using the existing computer data processing library.
In a second aspect of the embodiments of the present invention, there is provided a layout area determining apparatus based on cartoon translation, including:
the extension step value setting module is used for presetting a plurality of groups of extension step values in different directions, and the extension step values are used for gradually extending the translation region to the horizontal direction and/or the vertical direction;
the candidate expansion region area calculation module is used for expanding the initial translation region to obtain a candidate expansion region and calculating the area of the candidate expansion region based on a region progressive expansion method and each group of expansion step values;
and the target translation typesetting area determining module is used for selecting the expansion step value with the maximum expansion area and taking the candidate expansion area corresponding to the step value as the target translation typesetting area.
Optionally, in a possible implementation manner of the second aspect, the candidate extended region area calculating module is further configured to:
the initial translation region pixel mean value calculation module is used for acquiring rectangular coordinates of an initial translation region, wherein the rectangular coordinates are coordinates of four vertex positions, namely the upper vertex position, the lower vertex position, the left vertex position and the right vertex position, of the initial translation region, and calculating the pixel mean value of the initial translation region according to the rectangular coordinates;
a side boundary selection module, configured to select any one side boundary of the initial translation region, where the side boundary includes: a left side boundary, an upper side boundary, a right side boundary, a lower side boundary;
the current extended area pixel mean value calculation module is used for outwards extending the side boundary to the corresponding side based on the extended step value to obtain a current extended area and calculating the pixel mean value of the current extended area according to the rectangular coordinate of the current extended area;
a side boundary coordinate value determining module, configured to determine, according to a pixel mean of the current extended region and the initial translation region, a side boundary coordinate value of the candidate extended region, where the side boundary coordinate value includes: an upper boundary ordinate, a lower boundary ordinate, a left boundary abscissa, and a right boundary abscissa.
Optionally, in a possible implementation manner of the second aspect, the side boundary coordinate value determining module includes:
the first side boundary coordinate value determining module is used for taking the corresponding side boundary coordinate value of the initial translation region as the side boundary coordinate value of the candidate expansion region if the pixel mean difference value between the current expansion region and the initial translation region is greater than a preset threshold value;
and the second side boundary coordinate value determining module is used for taking the corresponding side boundary coordinate value of the current expansion region as the side boundary coordinate value of the candidate expansion region if the pixel mean difference value between the current expansion region and the initial translation region is less than or equal to a preset threshold value.
In a third aspect of the embodiments of the present invention, a computer device is provided, which includes a memory and a processor, where the memory stores a computer program that is executable on the processor, and the processor implements the steps in the above method embodiments when executing the computer program.
A fourth aspect of the embodiments of the present invention provides a readable storage medium, in which a computer program is stored, which, when being executed by a processor, is adapted to carry out the steps of the method according to the first aspect of the present invention and various possible designs of the first aspect of the present invention.
According to the method, the device, the computer equipment and the storage medium for determining the composition area based on the cartoon translation, multiple groups of expansion step values in different directions are preset, and the expansion step values are used for gradual expansion of the translation area to the horizontal direction and/or the vertical direction; based on a region progressive expansion method and each group of expansion step values, expanding the initial translation region to obtain a candidate expansion region, and calculating the area of the candidate expansion region; and selecting the expansion step value with the maximum expansion area, and taking the candidate expansion area corresponding to the step value as the target translation typesetting area. The invention can standardize the typesetting standard, reduce the influence of subjective factors in the translation process and realize that a machine automatically determines the optimal drawing area; and the manual participation is reduced, and the labor is saved.
Drawings
FIG. 1 is a display diagram of a cartoon bubble pattern
FIG. 2 is a flowchart of a first embodiment of a method for determining a layout area based on caricature translation;
FIG. 3 is a schematic diagram of the step-size region extrapolation for multi-scale expansion;
FIG. 4 is a schematic diagram of a candidate extended region configuration;
fig. 5 is a block diagram of a first embodiment of a layout region determination apparatus based on comic translation.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein.
It should be understood that, in various embodiments of the present invention, the sequence numbers of the processes do not mean the execution sequence, and the execution sequence of the processes should be determined by the functions and the internal logic of the processes, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
It should be understood that in the present application, "comprising" and "having" and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be understood that, in the present invention, "a plurality" means two or more. "and/or" is merely an association describing an associated object, meaning that three relationships may exist, for example, and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. "comprises A, B and C" and "comprises A, B, C" means that A, B, C all comprise, "comprises A, B or C" means comprise one of A, B, C, "comprises A, B and/or C" means comprise any 1 or any 2 or 3 of A, B, C.
It should be understood that in the present invention, "B corresponding to a", "a corresponds to B", or "B corresponds to a" means that B is associated with a, and B can be determined from a. Determining B from a does not mean determining B from a alone, but may be determined from a and/or other information. And the matching of A and B means that the similarity of A and B is greater than or equal to a preset threshold value.
As used herein, "if" may be interpreted as "at … …" or "when … …" or "in response to a determination" or "in response to a detection", depending on the context.
The technical solution of the present invention will be described in detail below with specific examples. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments.
The invention aims to automatically determine an optimal drawing area through a machine, namely a maximum translation typesetting area is determined, the expansion of the translation area can simultaneously expand the translations, and one conventional premise in the cartoon translation field is that the larger the character size of the translated text is, the better the visual effect is; and most translations will be placed in different styles of solid bubbles, as shown in figure 1.
Example 1:
the invention provides a method for determining a typesetting area based on cartoon translation, which is shown in a flow chart of figure 2 and comprises the following steps:
and step S1, presetting a plurality of groups of expansion step values in different directions, wherein the expansion step values are used for gradually expanding the translation region towards the horizontal direction and/or the vertical direction.
In this step, a multi-scale step group extending in the horizontal direction and the vertical direction needs to be preset, that is, scale _ anchors [ [ (a1, b1), (a2, b2),. ], (an, bn) ], where a represents a step of the horizontal direction progressive extension and b represents a step of the vertical direction progressive extension. Specifically, as shown in fig. 3, a solid-line rectangular region in the first bubble diagram is an initial translation drawing region, the subsequent three bubbles respectively represent final expansion regions (dashed rectangles) obtained by adopting different scale expansion step lengths, and si represents the areas of the corresponding regions.
And step S2, based on the region progressive expansion method and each group of expansion step values, expanding the initial translation region to obtain a candidate expansion region, and calculating the area of the candidate expansion region.
In step S2, after obtaining multiple sets of expansion step values (scale _ anchors), the expansion step values (ai, bi) of each set are sequentially selected, and the initial translation region is expanded by using a progressive expansion method based on the mean change of region pixels, so as to obtain the current expansion region coordinates and area based on the current step value.
And step S3, selecting the expansion step value with the maximum expansion area, and taking the candidate expansion area corresponding to the step value as the target translation typesetting area.
In the step, the coordinates and the areas of the extended regions based on each group of step values are sequentially obtained, and the group of step values with the largest region area and the coordinates of the extended regions corresponding to the step sizes are the final translation typesetting regions.
In an embodiment, the expanding the initial translation region based on the region progressive expansion method and each group of expansion step values to obtain a candidate expansion region, and calculating the area of the candidate expansion region, includes:
step S21, obtaining rectangular coordinates of the initial translation region, where the rectangular coordinates are coordinates of four vertex positions, i.e., box ═ x [ (x1, y1), (x2, y1), (x2, y2), (x1, y2) ]; and calculating the pixel mean crop _ mean of the initial translation region according to the rectangular coordinates, wherein the specific process is as follows: firstly, according to the rectangular coordinates of the initial translation region, carrying out cutout processing on the corresponding position of an original picture by utilizing the existing computer image processing library; the average of all pixels in the image is then calculated based on the pixel representation of the matte-processed image, using the existing computer data processing library.
Step S22, selecting any one side boundary of the initial translation region, where the side boundary includes: a left side boundary, an upper side boundary, a right side boundary, a lower side boundary; expanding the side boundary outwards towards the corresponding side based on the expansion step value to obtain a current expansion area, and calculating a pixel mean value (crop _ mean _ left/top/right/down) of the current expansion area according to the rectangular coordinates of the current expansion area, wherein the specific process is as follows: firstly, according to the rectangular coordinates of the current extended area, carrying out cutout processing on the corresponding position of an original picture by utilizing the existing computer image processing library; the average of all pixels in the image is then calculated based on the pixel representation of the matte-processed image, using the existing computer data processing library.
In this step, the current expanded region is obtained by performing the outward expansion to the corresponding lateral direction according to the lateral boundary of the selected initial translation region, wherein the "outward expansion to the corresponding lateral direction" means: the direction spread in the same side as the lateral border, for example: when the upper side boundary of the rectangular region of the initial translation region is selected currently, the side boundary is expanded upwards; similarly, upper boundary-upper, lower boundary-lower, left boundary-left, right boundary-right. Wherein "expanding the side boundary outward to the corresponding side based on the expansion step value to obtain the current expansion region" means: when the upper side boundary and the expansion step length value (a, b) of the rectangular region of the initial translation region are selected, the coordinate points corresponding to the boundary are [ (x1, y1), (x2, y1) ], new coordinates [ (x1, y1-b), (x2, y1-b) ] are obtained by extending towards the upper side, and further new rectangular coordinates [ (x1, y1-b), (x2, y1-b), (x2, y2), (x1, y2) ].
Step S23, determining side boundary coordinate values of the candidate expanded region according to the pixel mean values of the current expanded region and the initial translation region, where the side boundary coordinate values include: an upper boundary ordinate, a lower boundary ordinate, a left boundary abscissa, and a right boundary abscissa.
In step S23, an area expansion stop threshold (expanded _ threshold > -0) is preset, and if the difference between the pixel mean values of the current expanded area and the initial translation area is greater than the area expansion stop threshold, the corresponding side boundary coordinate value of the initial translation area is used as the side boundary coordinate value of the candidate expanded area. And if the pixel mean difference value between the current expansion area and the initial translation area is smaller than or equal to a preset threshold value, taking the corresponding side boundary coordinate value of the current expansion area as the side boundary coordinate value of the candidate expansion area.
The above-mentioned step S22 is described as an example of selecting the upper boundary of the rectangular region and the extension step value (a, b) for extension: expanding the upper side boundary of the translation initial region upwards to obtain a current expansion region and a pixel mean value crop _ mean _ top of the current expansion region; then, performing difference processing on the pixel mean value of the current expansion area and the pixel mean value of the initial translation area to obtain (crop _ mean _ top-crop _ mean); if the difference processing result is greater than the region expansion stop threshold, that is, abs (crop _ mean _ top-crop _ mean) > expand _ threshold, it is determined that the upper side boundary ordinate is y1 and no longer extends, that is, "the corresponding side boundary coordinate value of the initial translation region is taken as the side boundary coordinate value of the candidate expansion region"; otherwise, the updated region upper boundary ordinate y1 is y1-a, that is, "the corresponding side boundary coordinate value of the current expanded region is taken as the side boundary coordinate value of the candidate expanded region". If the region is expanded to be expanded upwards in the upper side direction, the vertical coordinate value of the upper side boundary of the candidate expansion region needs to be determined; similarly, "the lower side direction expands downward", it is necessary to determine the vertical coordinate value of the lower side boundary of the candidate expansion region; if the left side direction expands leftwards, the left side boundary abscissa value of the candidate expansion region needs to be determined; "right direction expands to the right", it is necessary to determine the abscissa value of the right boundary of the expansion candidate region. Wherein abs represents an absolute value.
Step S24, based on the expansion step value, expanding the initial translation region respectively to the upper, lower, left and right directions to obtain four side boundary coordinate values of the candidate expansion region; calculating the area of the candidate expansion region based on the four side boundary coordinate values.
In step S24, the initial translation region is expanded in four directions, i.e., up, down, left, and right, according to the above steps S22-S23, so as to determine four boundary coordinate values, from which a rectangular region (i.e., an expansion candidate region) can be formed, and calculate the area of the rectangular region. As shown in fig. 4, a rectangular area is naturally formed when four boundary coordinate values are determined.
The method, the device, the computer equipment and the storage medium for determining the typesetting area based on the cartoon translation provided by the invention set multiple groups of expansion step values in different directions in advance, wherein the expansion step values are used for gradually expanding the translation area to the horizontal direction and/or the vertical direction; based on a region progressive expansion method and each group of expansion step values, expanding the initial translation region to obtain a candidate expansion region, and calculating the area of the candidate expansion region; and selecting the expansion step value with the maximum expansion area, and taking the candidate expansion area corresponding to the step value as the target translation typesetting area. The invention can standardize the typesetting standard, reduce the influence of subjective factors in the translation process and realize that a machine automatically determines the optimal drawing area; and the manual participation is reduced, and the labor is saved.
In addition, the method and the device can adapt to bubbles in different shapes, prevent the expansion area obtained by fixing the step length from being inconsistent with the requirement of actual drawing, and realize automatic determination of the optimal drawing area by a machine. And note that the method does not limit the area in the bubble to be pure color and does not limit the original text area to be matched with the bubble. In actual situations, more than 95% of translations have bubble matching, and even if no bubble matching exists, the probability that the corresponding translation background area is pure color is extremely low.
Example 2:
an embodiment of the present invention further provides a device for determining a layout area based on cartoon translation, as shown in fig. 5, including:
the extension step value setting module is used for presetting a plurality of groups of extension step values in different directions, and the extension step values are used for gradually extending the translation region to the horizontal direction and/or the vertical direction;
the candidate expansion region area calculation module is used for expanding the initial translation region to obtain a candidate expansion region and calculating the area of the candidate expansion region based on a region progressive expansion method and each group of expansion step values;
and the target translation typesetting area determining module is used for selecting the expansion step value with the maximum expansion area and taking the candidate expansion area corresponding to the step value as the target translation typesetting area.
In one embodiment, the candidate extended region area calculation module includes:
the initial translation region pixel mean value calculation module is used for acquiring rectangular coordinates of an initial translation region, wherein the rectangular coordinates are coordinates of four vertex positions, namely the upper vertex position, the lower vertex position, the left vertex position and the right vertex position, of the initial translation region, and calculating the pixel mean value of the initial translation region according to the rectangular coordinates;
a side boundary selection module, configured to select any one side boundary of the initial translation region, where the side boundary includes: a left side boundary, an upper side boundary, a right side boundary, a lower side boundary;
the current extended area pixel mean value calculation module is used for outwards extending the side boundary to the corresponding side based on the extended step value to obtain a current extended area and calculating the pixel mean value of the current extended area according to the rectangular coordinate of the current extended area;
a side boundary coordinate value determining module, configured to determine, according to a pixel mean of the current extended region and the initial translation region, a side boundary coordinate value of the candidate extended region, where the side boundary coordinate value includes: an upper boundary ordinate, a lower boundary ordinate, a left boundary abscissa, and a right boundary abscissa.
In one embodiment, the side boundary coordinate value determination module includes:
the first side boundary coordinate value determining module is used for taking the corresponding side boundary coordinate value of the initial translation region as the side boundary coordinate value of the candidate expansion region if the pixel mean difference value between the current expansion region and the initial translation region is greater than a preset threshold value;
and the second side boundary coordinate value determining module is used for taking the corresponding side boundary coordinate value of the current expansion region as the side boundary coordinate value of the candidate expansion region if the pixel mean difference value between the current expansion region and the initial translation region is less than or equal to a preset threshold value.
The invention provides a device for determining a composition area based on cartoon translation, and provides a method, a device, computer equipment and a storage medium for determining the composition area based on cartoon translation, wherein multiple groups of expansion step values in different directions are preset, and the expansion step values are used for gradually expanding a translation area to the horizontal direction and/or the vertical direction; based on a region progressive expansion method and each group of expansion step values, expanding the initial translation region to obtain a candidate expansion region, and calculating the area of the candidate expansion region; and selecting the expansion step value with the maximum expansion area, and taking the candidate expansion area corresponding to the step value as the target translation typesetting area. The invention can standardize the typesetting standard, reduce the influence of subjective factors in the translation process and realize that a machine automatically determines the optimal drawing area; and the manual participation is reduced, and the labor is saved.
Example 3:
1.1 region progressive expansion method based on background region pixel mean value change
The method mainly comprises the following steps:
1) given that clockwise four points of the rectangular coordinates of the initial translation region are box [ (x1, y1), (x2, y1), (x2, y2), (x1, y2) ], (x1, y1) are horizontal and vertical coordinates of the top left vertex, the pixel mean value of the current region is crop _ mean, and the expansion stop threshold expansion _ threshold > is set to 0
2) Setting the horizontal direction expansion step length as a and the vertical direction expansion step length as b, wherein a and b are positive integers or 0 and are not 0 at the same time
3) Selecting the left side boundary of the rectangular region, wherein coordinate points corresponding to the boundary are [ (x1, y1), (x1, y2) ], extending the left side outwards to obtain new coordinates [ (x1-a, y1), (x1-a, y2) ], obtaining new rectangular coordinates [ (x1-a, y1), (x2, y1), (x2, y2), (x1-a, y2) ], and calculating the pixel average value of the current extension region to be crop _ mean _ left. If abs (crop _ mean _ left-crop _ mean) > expand _ threshold, then the left boundary abscissa x1 is determined not to be expanded any more; otherwise, the left side boundary abscissa x1 of the updated region x1-a
4) Selecting the upper side boundary of a rectangular region, wherein coordinate points corresponding to the boundary are [ (x1, y1), (x2, y1) ], expanding upwards to obtain new coordinates [ (x1, y1-b), (x2, y1-b) ], obtaining new rectangular coordinates [ (x1, y1-b), (x2, y1-b), (x2, y2), (x1, y2) ], and calculating the pixel average value of the current expansion region to be crop _ mean _ top. If abs (crop _ mean _ top-crop _ mean) > expand _ threshold, then the upper boundary ordinate y1 is determined not to be expanded any more; otherwise, the ordinate and y1-b of the upper boundary of the updated region
5) Selecting the right side boundary of the rectangular region, wherein coordinate points corresponding to the boundary are [ (x2, y1), (x2, y2) ], expanding towards the right side to obtain new coordinates [ (x2+ a, y1), (x2+ a, y2) ], obtaining new rectangular coordinates [ (x1, y1), (x2+ a, y1), (x2+ a, y2), (x1, y2) ], and calculating the pixel average value of the current expansion region to be crop _ mean _ right. If abs (crop _ mean _ right-crop _ mean) > expand _ threshold, then the right boundary abscissa x2 is determined not to be expanded any more; otherwise, the right boundary abscissa x2 of the updated region is x2+ a
6) Selecting the lower side boundary of the rectangular region, wherein coordinate points corresponding to the boundary are [ (x2, y2), (x1, y2) ], expanding downwards to obtain new coordinates [ (x2, y2+ b), (x1, y2+ b) ], obtaining new rectangular coordinates [ (x1, y1), (x2, y1), (x2, y2+ b), (x1, y2+ b) ], and calculating the pixel average value of the current expansion region to be crop _ mean _ down. If abs (crop _ mean _ down-crop _ mean) > expand _ threshold, then it is determined that the lower boundary ordinate is y2 is not outdated; otherwise, the lower boundary abscissa y2 of the updated region is y2+ b
7) And (4) circulating the processes of 3) to 6) until the expansion is stopped in all the directions of up, down, left and right, and the optimal translation area is obtained at the moment
Note that it is necessary to determine whether the extended coordinates overflow the image boundary each time the extension is performed, and if so, the outward extension is stopped in the current direction
1.2 method for determining maximum translation region area by multi-scale extension step length in different directions
Based on the method proposed in 1.1, the optimal rendering region can be obtained according to the initial rendering region coordinate extension, and on the basis, the optimal rendering region searching method with multi-scale step length is proposed
The main steps of the proposed method are as follows:
1) a multi-scale step scale _ anchors for horizontal and vertical expansion is set to [ (a1, b1), (a2, b2),. ·, (an, bn) ], where a represents the step size for horizontal progressive expansion and b represents the step size for vertical progressive expansion
2) And (3) circularly scale _ anchors, selecting the ith group of step sizes (ai, bi), and obtaining the coordinates and the area of the extended translation region based on the current step size by using a 1.1 progressive extension method based on the mean value change of region pixels
3) And one group of step length enables the area expansion area to be maximum, and the step length corresponds to the expansion area coordinate to be the final translation typesetting area.
The readable storage medium may be a computer storage medium or a communication medium. Communication media includes any medium that facilitates transfer of a computer program from one place to another. Computer storage media may be any available media that can be accessed by a general purpose or special purpose computer. For example, a readable storage medium is coupled to the processor such that the processor can read information from, and write information to, the readable storage medium. Of course, the readable storage medium may also be an integral part of the processor. The processor and the readable storage medium may reside in an Application Specific Integrated Circuits (ASIC). Additionally, the ASIC may reside in user equipment. Of course, the processor and the readable storage medium may also reside as discrete components in a communication device. The readable storage medium may be a read-only memory (ROM), a random-access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
The present invention also provides a program product comprising execution instructions stored in a readable storage medium. The at least one processor of the device may read the execution instructions from the readable storage medium, and the execution of the execution instructions by the at least one processor causes the device to implement the methods provided by the various embodiments described above.
In the above embodiments of the terminal or the server, it should be understood that the Processor may be a Central Processing Unit (CPU), other general-purpose processors, a Digital Signal Processor (DSP), etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the present invention may be embodied directly in a hardware processor, or in a combination of the hardware and software modules within the processor.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and these modifications or substitutions do not depart from the spirit of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A method for determining a typesetting area based on cartoon translation is characterized by comprising the following steps:
presetting a plurality of groups of expansion step values in different directions, wherein the expansion step values are used for gradual expansion of a translation region in the horizontal and/or vertical direction;
based on a region progressive expansion method and each group of expansion step values, expanding the initial translation region to obtain a candidate expansion region, and calculating the area of the candidate expansion region;
and selecting the expansion step value with the maximum expansion area, and taking the candidate expansion area corresponding to the step value as the target translation typesetting area.
2. The method for determining the composition area based on the cartoon translation according to claim 1, wherein the step of expanding the initial translation area based on the area progressive expansion method and each group of expansion step values to obtain a candidate expansion area, and calculating the area of the candidate expansion area comprises:
acquiring rectangular coordinates of an initial translation region, wherein the rectangular coordinates are coordinates of upper, lower, left and right vertex positions of the initial translation region, and calculating a pixel mean value of the initial translation region according to the rectangular coordinates;
selecting any one side boundary of the initial translation region, wherein the side boundary comprises: a left side boundary, an upper side boundary, a right side boundary, a lower side boundary;
expanding the side boundary outwards towards the corresponding side based on the expansion step value to obtain a current expansion area, and calculating the pixel mean value of the current expansion area according to the rectangular coordinate of the current expansion area;
determining side boundary coordinate values of the candidate expansion region according to the pixel mean values of the current expansion region and the initial translation region, wherein the side boundary coordinate values comprise: an upper boundary ordinate, a lower boundary ordinate, a left boundary abscissa, and a right boundary abscissa.
3. The method for determining the composition area based on cartoon translation according to claim 2, wherein the determining the side boundary coordinate value of the candidate extension area according to the pixel mean value of the current extension area and the initial translation area comprises:
if the pixel mean difference value between the current expansion area and the initial translation area is larger than a preset threshold value, taking the corresponding side boundary coordinate value of the initial translation area as the side boundary coordinate value of the candidate expansion area;
and if the pixel mean difference value between the current expansion area and the initial translation area is smaller than or equal to a preset threshold value, taking the corresponding side boundary coordinate value of the current expansion area as the side boundary coordinate value of the candidate expansion area.
4. The method for determining the layout region based on cartoon translation according to claim 2 or 3, wherein the method further comprises:
based on the expansion step value, expanding the initial translation region respectively towards four directions, namely, up, down, left and right, to obtain four side boundary coordinate values of the candidate expansion region;
calculating the area of the candidate expansion region based on the four side boundary coordinate values.
5. The method for determining the layout area based on cartoon translation of claim 2, wherein calculating the pixel mean value of the initial translation area according to the rectangular coordinates comprises:
according to the rectangular coordinates of the initial translation region, carrying out cutout processing on the original picture at a corresponding position by utilizing the existing computer image processing library;
based on the pixel representation of the image after the matting process, the average value of all pixels in the image is calculated by using the existing computer data processing library.
6. A layout region determination device based on cartoon translation is characterized by comprising:
the extension step value setting module is used for presetting a plurality of groups of extension step values in different directions, and the extension step values are used for gradually extending the translation region to the horizontal direction and/or the vertical direction;
the candidate expansion region area calculation module is used for expanding the initial translation region to obtain a candidate expansion region and calculating the area of the candidate expansion region based on a region progressive expansion method and each group of expansion step values;
and the target translation typesetting area determining module is used for selecting the expansion step value with the maximum expansion area and taking the candidate expansion area corresponding to the step value as the target translation typesetting area.
7. The apparatus for determining a composition area based on cartoon translation according to claim 6, wherein the candidate extended area calculating module comprises:
the initial translation region pixel mean value calculation module is used for acquiring rectangular coordinates of an initial translation region, wherein the rectangular coordinates are coordinates of four vertex positions, namely the upper vertex position, the lower vertex position, the left vertex position and the right vertex position, of the initial translation region, and calculating the pixel mean value of the initial translation region according to the rectangular coordinates;
a side boundary selection module, configured to select any one side boundary of the initial translation region, where the side boundary includes: a left side boundary, an upper side boundary, a right side boundary, a lower side boundary;
the current extended area pixel mean value calculation module is used for outwards extending the side boundary to the corresponding side based on the extended step value to obtain a current extended area and calculating the pixel mean value of the current extended area according to the rectangular coordinate of the current extended area;
a side boundary coordinate value determining module, configured to determine, according to a pixel mean of the current extended region and the initial translation region, a side boundary coordinate value of the candidate extended region, where the side boundary coordinate value includes: an upper boundary ordinate, a lower boundary ordinate, a left boundary abscissa, and a right boundary abscissa.
8. The apparatus for determining a composition area based on cartoon translation according to claim 6, wherein the side boundary coordinate value determining module comprises:
the first side boundary coordinate value determining module is used for taking the corresponding side boundary coordinate value of the initial translation region as the side boundary coordinate value of the candidate expansion region if the pixel mean difference value between the current expansion region and the initial translation region is greater than a preset threshold value;
and the second side boundary coordinate value determining module is used for taking the corresponding side boundary coordinate value of the current expansion region as the side boundary coordinate value of the candidate expansion region if the pixel mean difference value between the current expansion region and the initial translation region is less than or equal to a preset threshold value.
9. A computer device comprising a memory and a processor, the memory storing a computer program operable on the processor, wherein the processor implements the steps of the method of any one of claims 1 to 5 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 5.
CN202210172124.2A 2022-02-24 2022-02-24 Method and device for determining typesetting area based on cartoon translation Pending CN114549700A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210172124.2A CN114549700A (en) 2022-02-24 2022-02-24 Method and device for determining typesetting area based on cartoon translation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210172124.2A CN114549700A (en) 2022-02-24 2022-02-24 Method and device for determining typesetting area based on cartoon translation

Publications (1)

Publication Number Publication Date
CN114549700A true CN114549700A (en) 2022-05-27

Family

ID=81676957

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210172124.2A Pending CN114549700A (en) 2022-02-24 2022-02-24 Method and device for determining typesetting area based on cartoon translation

Country Status (1)

Country Link
CN (1) CN114549700A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115063829A (en) * 2022-08-15 2022-09-16 万翼科技有限公司 Non-closed region identification method, device, equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115063829A (en) * 2022-08-15 2022-09-16 万翼科技有限公司 Non-closed region identification method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
JP4175413B2 (en) Image similarity calculation system, image search system, image similarity calculation method, and image similarity calculation program
JP4124494B2 (en) Replacement computer font supply method and apparatus
CN111062903A (en) Automatic processing method and system for image watermark, electronic equipment and storage medium
CN108197567B (en) Method, apparatus and computer readable medium for image processing
CN112418216A (en) Method for detecting characters in complex natural scene image
CN110796583A (en) Stylized visible watermark adding method
CN110738598A (en) Image adaptation method, electronic device and storage medium
CN114549700A (en) Method and device for determining typesetting area based on cartoon translation
CN115237522A (en) Page self-adaptive display method and device
CN107533760B (en) Image segmentation method and device
CN110796663B (en) Picture clipping method, device, equipment and storage medium
CN110363837B (en) Method and device for processing texture image in game, electronic equipment and storage medium
CN116862943A (en) Method and device for automatically replacing background of commodity photo
CN108154792B (en) Graphic character annotation method and device
CN111914046B (en) Generation method and device of target seating chart and computer equipment
CN107292840B (en) Image restoration method and device, computer-readable storage medium and terminal
CN113436298B (en) Method and device for automatically generating Chinese character stroke order animation and related components thereof
CN114549701A (en) Self-adaptive typesetting method and device based on cartoon translation
JP4349160B2 (en) Image similarity calculation system, image search system, image similarity calculation method, and image similarity calculation program
CN113780254A (en) Picture processing method and device, electronic equipment and computer storage medium
JP4396328B2 (en) Image similarity calculation system, image search system, image similarity calculation method, and image similarity calculation program
JP2001166754A (en) Display system
CN116932120B (en) Method and device for zooming visual page of map base map and electronic equipment
CN113139625B (en) Model training method, electronic equipment and storage medium thereof
CN114742923A (en) Picture layer self-adaptive stretching method and device for cartoon translation

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