Method and device for determining typesetting area based on comic translation
By using multiple sets of expansion step values and area progressive expansion methods in the comic translation tool, the best layout area for comic translation is automatically determined, which solves the problem of rough determination of layout areas in existing tools and relies on manual correction, achieving more efficient and accurate translation process.
Patent Information
- Application Number
- CN202210172124.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-24
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2042-02-24
AI Technical Summary
The existing comic translation tools have rough problems in determining the layout area, relying on manual adjustment and subjective judgment, and require frequent correction.
By presetting multiple sets of expansion step values in different directions, the initial translation area is expanded based on the region progressive expansion method, the candidate expansion area area is calculated, and the expansion step value with the largest area is selected as the target translation area.
It realizes that the machine automatically determines the best drawing area, standardizes the layout standards, reduces the influence of subjective factors during the translation process, reduces manual participation, and saves manpower.
Smart Images

Figure CN114549700B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, apparatus, computer device and storage medium for determining a typesetting area based on comic translation. Background Art
[0002] Anyone who has read comics will be familiar with the term "Chinese translation team". For a long time, the work of comic translation has always followed a set of processes with a long cycle and a large amount of repetitive labor.
[0003] The tools used by the comic translation team are mostly Photoshop (abbreviated as "PS"). As a professional photo editing software, PS has a high learning cost and does not fully match the needs of comic translation. The comic translation team needs to manually extract and translate the text information in the picture, erase the original text in the picture, and then embed the translation one by one, adjust the font and layout to suit the original picture and then export it. With the continuous development of the domestic comic market, the comic translation field has gradually developed related tools to assist manual translation, which mainly involve original text detection of comic files, quick text erasure, translation of different languages, multiple font style selection, etc., to help humans reduce the complicated work of operating PS step by step.
[0004] Although existing translation tools have reduced some of the manual work, they still require manual correction of the translation results. Existing comic translation tools still have the following problems in typesetting:
[0005] The existing technology mainly adds a text editing area to the original text area and directly fills the translation, or performs simple grid division according to the number of translated words; the text area needs to be adjusted manually, and the grid division method has a great impact on the typesetting of words with a large length span such as English, resulting in the problem of rough determination of the typesetting area; and the expansion of the translation area relies on manual subjective judgment: adding a text editing area and then manually stretching it to adapt, or directly using the original text area for typesetting.
[0006] Therefore, there is an urgent need for a typesetting area determination method and device that can automatically determine the optimal drawing area through a machine. Summary of the invention
[0007] The embodiments of the present invention provide a method, device, computer equipment and storage medium for determining typesetting areas based on comic translation, so as to solve the problems that the typesetting area determination of existing comic translation tools is rough, the extension of the translation area relies on manual subjective judgment, and manual correction is time-consuming and laborious.
[0008] In order to achieve the above-mentioned purpose, a first aspect of an embodiment of the present invention provides a method for determining a typesetting area based on comic translation, comprising:
[0009] Presetting multiple groups of expansion step values in different directions, wherein the expansion step values are used to gradually expand the translation area in the horizontal and / or vertical directions;
[0010] Based on the region progressive expansion method and each group of expansion step values, the initial translation region is expanded to obtain a candidate expansion region, and the area of the candidate expansion region is calculated;
[0011] The expansion step value with the largest expansion area is selected, and the candidate expansion area corresponding to the step value is used as the target translation typesetting area.
[0012] Optionally, in a possible implementation of the first aspect, based on the region progressive expansion method and each group of expansion step values, the initial translation region is expanded to obtain a candidate expansion region, and the area of the candidate expansion region is calculated, including:
[0013] Obtaining the rectangular coordinates of the initial translation area, the rectangular coordinates being the coordinates of the four top, bottom, left and right vertices of the initial translation area, and calculating the pixel mean of the initial translation area according to the rectangular coordinates;
[0014] Select any side boundary of the initial translation area, wherein the side boundaries include: a left boundary, an upper boundary, a right boundary, and a lower boundary;
[0015] Expanding the side boundary outward toward the corresponding side direction based on the expansion step value to obtain a current expansion area, and calculating a pixel mean value of the current expansion area according to the rectangular coordinates of the current expansion area;
[0016] According to the pixel averages of the current extension area and the initial translation area, the side boundary coordinate values of the candidate extension area are determined, and the side boundary coordinate values include: an upper side boundary ordinate, a lower side boundary ordinate, a left side boundary abscissa, and a right side boundary abscissa.
[0017] Optionally, in a possible implementation manner of the first aspect, determining the lateral boundary coordinate value of the candidate extended area according to the pixel averages of the current extended area and the initial translation area includes:
[0018] If the pixel mean difference between the current extension area and the initial translation area is greater than a preset threshold, the corresponding side boundary coordinate value of the initial translation area is used as the side boundary coordinate value of the candidate extension area;
[0019] If the pixel mean difference between the current extended area and the initial translation area is less than or equal to a preset threshold, the corresponding side boundary coordinate value of the current extended area is used as the side boundary coordinate value of the candidate extended area.
[0020] Optionally, in a possible implementation manner of the first aspect, the method further includes:
[0021] Based on the expansion step value, the initial translation area is expanded in four directions, upward, downward, left and right, respectively, to obtain four side boundary coordinate values of the candidate expansion area;
[0022] The area of the candidate extension region is calculated based on the four side boundary coordinate values.
[0023] Optionally, in a possible implementation manner of the first aspect, calculating the pixel mean of the initial translation area according to the rectangular coordinates includes:
[0024] According to the rectangular coordinates of the initial translation area, the original image is cut out at the corresponding position using an existing computer image processing library;
[0025] Based on the pixel representation of the image after the cutout processing, the mean value of all pixels in the image is calculated using the existing computer data processing library.
[0026] A second aspect of an embodiment of the present invention provides a device for determining a typesetting area based on comic translation, comprising:
[0027] An expansion step value setting module, used to pre-set multiple groups of expansion step values in different directions, wherein the expansion step values are used to gradually expand the translation area in the horizontal and / or vertical directions;
[0028] A candidate extension region area calculation module is used to expand the initial translation region to obtain a candidate extension region based on the region progressive expansion method and each group of expansion step values, and calculate the area of the candidate extension region;
[0029] The target translation typesetting area determination module is used to select the extension step value with the largest extension area, and use the candidate extension area corresponding to the step value as the target translation typesetting area.
[0030] Optionally, in a possible implementation manner of the second aspect, it is characterized in that the candidate extension region area calculation module includes:
[0031] The initial translation area pixel mean calculation module is used to obtain the rectangular coordinates of the initial translation area, the rectangular coordinates are the coordinates of the four top, bottom, left and right vertices of the initial translation area, and calculate the pixel mean of the initial translation area according to the rectangular coordinates;
[0032] A side boundary selection module, used to select any side boundary of the initial translation area, wherein the side boundaries include: a left boundary, an upper boundary, a right boundary, and a lower boundary;
[0033] A current extended area pixel mean calculation module, used to expand the side boundary outward in the corresponding side direction based on the extension step value to obtain the current extended area, and calculate the pixel mean of the current extended area according to the rectangular coordinates of the current extended area;
[0034] The side boundary coordinate value determination module is used to determine the side boundary coordinate value of the candidate extension area according to the pixel average of the current extension area and the initial translation area, and the side boundary coordinate value includes: the upper side boundary ordinate, the lower side boundary ordinate, the left side boundary abscissa, and the right side boundary abscissa.
[0035] Optionally, in a possible implementation manner of the second aspect, it is characterized in that the lateral boundary coordinate value determination module includes:
[0036] A first side boundary coordinate value determination module, configured to use the corresponding side boundary coordinate value of the initial translation area as the side boundary coordinate value of the candidate extension area if the pixel mean difference between the current extension area and the initial translation area is greater than a preset threshold;
[0037] The second side boundary coordinate value determination module is used to use the corresponding side boundary coordinate value of the current extension area as the side boundary coordinate value of the candidate extension area if the pixel mean difference between the current extension area and the initial translation area is less than or equal to a preset threshold.
[0038] According to a third aspect of an embodiment of the present invention, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program executable on the processor, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.
[0039] According to a fourth aspect of an embodiment of the present invention, a readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, it is used to implement the steps of the method of the first aspect of the present invention and various possible designs of the first aspect.
[0040] The method, device, computer equipment and storage medium for determining typesetting areas based on comic translation provided by the present invention pre-set multiple groups of expansion step values in different directions, and the expansion step values are used for progressive expansion of the translation area in the horizontal and / or vertical directions; based on the area progressive expansion method and each group of expansion step values, the initial translation area is expanded to obtain a candidate expansion area, and the area of the candidate expansion area is calculated; the expansion step value with the largest area of the expansion area is selected, and the candidate expansion area corresponding to the step value is used as the target translation typesetting area. The present invention can standardize typesetting standards, reduce the influence of subjective factors in the translation process, and realize automatic determination of the best drawing area by the machine; and reduce manual participation and save manpower. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 A comic bubble style presentation
[0042] Figure 2 A flowchart of a first implementation of a method for determining a typesetting area based on comic translation;
[0043] Figure 3 It is a schematic diagram of the expansion of the multi-scale step area;
[0044] Figure 4 A schematic diagram of the candidate expansion area;
[0045] Figure 5 This is a structural diagram of a first implementation of a device for determining a typesetting area based on comics translation. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0047] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in sequences other than those illustrated or described herein.
[0048] It should be understood that in various embodiments of the present invention, the size of the sequence number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0049] It should be understood that in the present invention, "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products or apparatuses.
[0050] It should be understood that in the present invention, "plurality" refers to two or more than two. "And / or" is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "Contains A, B and C", "Contains A, B, C" means that A, B, and C are all included, "Contains A, B or C" means that one of A, B, and C is included, and "Contains A, B and / or C" means that any one, any two, or any three of A, B, and C are included.
[0051] It should be understood that in the present invention, "B corresponding to A", "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 based on A. Determining B based on A does not mean determining B based only on A, but B can also be determined based on A and / or other information. A and B match when the similarity between A and B is greater than or equal to a preset threshold.
[0052] Depending on the context, "if" as used herein may be interpreted as "when" or "when" or "in response to determining" or "in response to detecting."
[0053] The technical solution of the present invention is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0054] The purpose of the present invention is to automatically determine the best drawing area, that is, to determine the maximum translation typesetting area, by a machine. The expansion of the translation area can also expand the translation at the same time. A common premise in the field of comic translation is that the larger the translation size is, the better the visual effect will be on the basis of meeting the minimum font size. Most of the translations will be placed in solid-color bubbles of different styles. Different bubbles are displayed as follows: Figure 1 shown.
[0055] Embodiment 1:
[0056] The present invention provides a method for determining a typesetting area based on comic translation, such as Figure 2 The flow chart shown includes:
[0057] Step S1: presetting a plurality of groups of expansion step values in different directions, wherein the expansion step values are used for progressively expanding the translation area in the horizontal and / or vertical directions.
[0058] In this step, it is necessary to pre-set the multi-scale step size groups that expand in the horizontal and vertical directions, that is, scale_anchors = [(a1, b1), (a2, b2), ..., (an, bn)], where a represents the step size of the progressive expansion in the horizontal direction, and b represents the step size of the progressive expansion in the vertical direction. Selecting different scale step size groups will have different external expansion effects on the initial translation area, as shown in the following example. Figure 3 As shown in FIG. 1 , the solid rectangular area in the first bubble chart is the initial translation drawing area, and the subsequent three bubbles represent the final expansion areas (dashed rectangles) obtained by using different scale expansion steps, and si represents the area of the corresponding area.
[0059] Step S2: Based on the region progressive expansion method and each group of expansion step values, the initial translation region is expanded to obtain a candidate expansion region, and the area of the candidate expansion region is calculated.
[0060] In step S2, after obtaining multiple groups of expansion step values (scale_anchors), the expansion step value (ai, bi) of each group is selected in turn, and the initial translation area is expanded using a progressive expansion method based on the mean change of regional pixels to obtain the current expansion area coordinates and area based on the current step value.
[0061] Step S3: Select the extension step value with the largest extension area, and use the candidate extension area corresponding to the step value as the target translation typesetting area.
[0062] In this step, the coordinates and area of the extended area based on each set of step values are obtained in turn, and the set of step values with the largest area and the corresponding extended area coordinates are used as the final translation typesetting area.
[0063] In one embodiment, based on the region progressive expansion method and each group of expansion step values, the initial translation region is expanded to obtain a candidate expansion region, and the area of the candidate expansion region is calculated, including:
[0064] Step S21, obtaining the rectangular coordinates of the initial translation area, the rectangular coordinates are the coordinates of the four vertex positions of the initial translation area, that is, box=[(x1,y1),(x2,y1),(x2,y2),(x1,y2)]; and calculating the pixel mean crop_mean of the initial translation area according to the rectangular coordinates, the specific process is as follows: first, according to the rectangular coordinates of the initial translation area, using the existing computer image processing library, the original image is subjected to a cutout process at the corresponding position; then, based on the pixel representation of the image after the cutout process, using the existing computer data processing library, the mean of all pixels in the image is calculated.
[0065] Step S22, selecting any side boundary of the initial translation area, the side boundaries include: a left boundary, an upper boundary, a right boundary, and a lower boundary; expanding the side boundary outward in the corresponding side direction based on the expansion step value to obtain a current expansion area, and calculating the pixel mean (crop_mean_left / top / right / down) of the current expansion area according to the rectangular coordinates of the current expansion area. The specific process is as follows: first, according to the rectangular coordinates of the current expansion area, using an existing computer image processing library, performing a cropping process on the corresponding position of the original image; then, based on the pixel representation of the image after the cropping process, using an existing computer data processing library, calculating the mean of all pixels in the image.
[0066] In this step, the current extended area is obtained by expanding the side boundary of the selected initial translation area in the corresponding side direction, where "expanding in the corresponding side direction" means: expanding in the same direction as the side boundary, for example: when the upper side boundary of the initial translation area rectangle is currently selected, the side boundary will be expanded upward; similarly, the upper side boundary - the upper side, the lower side boundary - the lower side, the left side boundary - the left side, and the right side boundary - the right side. Wherein "expanding the side boundary in the corresponding side direction based on the expansion step value to obtain the current extended area" means: when the upper side boundary of the initial translation area rectangle and the expansion step value (a, b) are selected, the corresponding coordinate point of the boundary is [(x1, y1), (x2, y1)], and the new coordinates obtained by expanding upward are [(x1, y1-b), (x2, y1-b)], and then the new rectangular coordinates can be obtained as [(x1, y1-b), (x2, y1-b), (x2, y2), (x1, y2)].
[0067] Step S23: Determine the side boundary coordinate values of the candidate extension area according to the pixel mean values of the current extension area and the initial translation area, wherein the side boundary coordinate values include: an upper side boundary ordinate, a lower side boundary ordinate, a left side boundary abscissa, and a right side boundary abscissa.
[0068] In step S23, a region expansion stop threshold (expand_threshold>=0) is preset. If the pixel mean difference between the current expansion region and the initial translation region is greater than the region expansion stop threshold, the corresponding side boundary coordinate value of the initial translation region is used as the side boundary coordinate value of the candidate expansion region. If the pixel mean difference between the current expansion region and the initial translation region is less than or equal to the preset threshold, the corresponding side boundary coordinate value of the current expansion region is used as the side boundary coordinate value of the candidate expansion region.
[0069] Take the upper boundary of the rectangular area and the expansion step value (a, b) selected for expansion in the above step S22 as an example for explanation: the upper boundary of the initial translation area is expanded upward to obtain the current expansion area, and the pixel mean crop_mean_top of the current expansion area; then the pixel mean of the current expansion area is subjected to difference processing with the pixel mean of the initial translation area, that is, (crop_mean_top-crop_mean); if the difference processing result is greater than the area expansion stop threshold, that is, abs(crop_mean_top-crop_mean)>expand_threshold, then the upper boundary ordinate is determined to be y1 and no longer expanded, that is, "the corresponding side boundary coordinate value of the initial translation area is used as the side boundary coordinate value of the candidate expansion area"; otherwise, the upper boundary ordinate y1 of the area is updated to be y1=y1-a, that is, "the corresponding side boundary coordinate value of the current expansion area is used as the side boundary coordinate value of the candidate expansion area". If the region is expanded "upward expansion in the upper direction", the upper boundary ordinate value of the candidate expansion region needs to be determined; similarly, if it is "downward expansion in the lower direction", the lower boundary ordinate value of the candidate expansion region needs to be determined; if it is "leftward expansion in the left direction", the left boundary ordinate value of the candidate expansion region needs to be determined; if it is "rightward expansion in the right direction", the right boundary ordinate value of the candidate expansion region needs to be determined. Among them, the above abs is a calculation language, which means taking the absolute value.
[0070] Step S24: based on the expansion step value, the initial translation region is expanded in four directions, upward, downward, left and right, respectively, to obtain four side boundary coordinate values of the candidate expansion region; and the area of the candidate expansion region is calculated based on the four side boundary coordinate values.
[0071] In step S24, according to the above steps S22-S23, the initial translation area is expanded in the four directions of up, down, left and right respectively, and then four boundary coordinate values are determined. These four boundary coordinate values can form a rectangular area (i.e., the candidate expansion area), and the area of the rectangular area is calculated. Figure 4 As shown, when the four boundary coordinate values are determined, a rectangular area will naturally be formed.
[0072] The method for determining a typesetting area based on comic translation provided by the present invention, the method, device, computer equipment and storage medium for determining a typesetting area based on comic translation provided by the present invention, by presetting multiple groups of expansion step values in different directions, the expansion step values are used for the translation area to gradually expand in the horizontal and / or vertical directions; based on the area progressive expansion method and each group of expansion step values, the initial translation area is expanded to obtain a candidate expansion area, and the area of the candidate expansion area is calculated; the expansion step value with the largest area of the expansion area is selected, and the candidate expansion area corresponding to the step value is used as the target translation typesetting area. The present invention can standardize the typesetting standard, reduce the influence of subjective factors in the translation process, and realize the automatic determination of the best drawing area by the machine; and reduce manual participation and save manpower.
[0073] In addition, this application can adapt to bubbles of different shapes, prevent the expansion area obtained by the fixed step size from not meeting the actual drawing requirements, and enable the machine to automatically determine the optimal drawing area. And note that this method does not limit the area inside the bubble to be a solid color, and does not limit the original text area to have bubbles. In actual situations, more than 95% of the translations have bubble matches, and even if there is no bubble match, the probability that the corresponding translation background area is a solid color is extremely low.
[0074] Embodiment 2:
[0075] The embodiment of the present invention also provides a device for determining a typesetting area based on comic translation, such as Figure 5 As shown, including:
[0076] An expansion step value setting module, used to pre-set multiple groups of expansion step values in different directions, wherein the expansion step values are used to gradually expand the translation area in the horizontal and / or vertical directions;
[0077] A candidate extension region area calculation module is used to expand the initial translation region to obtain a candidate extension region based on the region progressive expansion method and each group of expansion step values, and calculate the area of the candidate extension region;
[0078] The target translation typesetting area determination module is used to select the extension step value with the largest extension area, and use the candidate extension area corresponding to the step value as the target translation typesetting area.
[0079] In one embodiment, the candidate extension region area calculation module includes:
[0080] The initial translation area pixel mean calculation module is used to obtain the rectangular coordinates of the initial translation area, the rectangular coordinates are the coordinates of the four top, bottom, left and right vertices of the initial translation area, and calculate the pixel mean of the initial translation area according to the rectangular coordinates;
[0081] A side boundary selection module, used to select any side boundary of the initial translation area, wherein the side boundaries include: a left boundary, an upper boundary, a right boundary, and a lower boundary;
[0082] A current extended area pixel mean calculation module, used to expand the side boundary outward in the corresponding side direction based on the extension step value to obtain the current extended area, and calculate the pixel mean of the current extended area according to the rectangular coordinates of the current extended area;
[0083] The side boundary coordinate value determination module is used to determine the side boundary coordinate value of the candidate extension area according to the pixel average of the current extension area and the initial translation area, and the side boundary coordinate value includes: the upper side boundary ordinate, the lower side boundary ordinate, the left side boundary abscissa, and the right side boundary abscissa.
[0084] In one embodiment, the lateral boundary coordinate value determination module includes:
[0085] A first side boundary coordinate value determination module, configured to use the corresponding side boundary coordinate value of the initial translation area as the side boundary coordinate value of the candidate extension area if the pixel mean difference between the current extension area and the initial translation area is greater than a preset threshold;
[0086] The second side boundary coordinate value determination module is used to use the corresponding side boundary coordinate value of the current extension area as the side boundary coordinate value of the candidate extension area if the pixel mean difference between the current extension area and the initial translation area is less than or equal to a preset threshold.
[0087] The typesetting area determination device based on comic translation provided by the present invention, the typesetting area determination method, device, computer equipment and storage medium based on comic translation provided by the present invention, by presetting multiple groups of expansion step values in different directions, the expansion step value is used for the translation area to gradually expand in the horizontal and / or vertical direction; based on the area progressive expansion method and each group of expansion step values, the initial translation area is expanded to obtain a candidate expansion area, and the area of the candidate expansion area is calculated; the expansion step value with the largest expansion area is selected, and the candidate expansion area corresponding to the step value is used as the target translation typesetting area. The present invention can standardize the typesetting standard, reduce the influence of subjective factors in the translation process, and realize the automatic determination of the best drawing area by the machine; and reduce manual participation and save manpower.
[0088] Embodiment 3:
[0089] 1.1 Region progressive expansion method based on the change of background area pixel mean
[0090] The main steps are as follows:
[0091] 1) The four clockwise points of the initial translation area rectangular coordinates are expressed as box = [(x1, y1), (x2, y1), (x2, y2), (x1, y2)], (x1, y1) is the horizontal and vertical coordinates of the upper left vertex, and the pixel mean of the current area is obtained as crop_mean, and the expansion stop threshold expand_threshold> = 0 is set
[0092] 2) Set the horizontal expansion step size to a and the vertical expansion step size to b, where a and b are both positive integers or 0, and they cannot be 0 at the same time.
[0093] 3) Select the left boundary of the rectangular area, the corresponding coordinate point of the boundary is [(x1,y1), (x1,y2)], expand to the left to get the new coordinates [(x1-a,y1), (x1-a,y2)], get the new rectangular coordinates [(x1-a,y1), (x2,y1), (x2,y2), (x1-a,y2)], and calculate the pixel mean of the current expansion area as crop_mean_left. If abs(crop_mean_left-crop_mean)>expand_threshold, determine the horizontal coordinate of the left boundary to be x1 and no longer expand; otherwise update the horizontal coordinate of the left boundary of the area x1=x1-a
[0094] 4) Select the upper boundary of the rectangular area, the corresponding coordinate point of the boundary is [(x1,y1), (x2,y1)], expand upward to obtain the new coordinates [(x1,y1-b), (x2,y1-b)], and obtain the new rectangular coordinates [(x1,y1-b), (x2,y1-b), (x2,y2), (x1,y2)], and calculate the pixel mean of the current expansion area as crop_mean_top. If abs(crop_mean_top-crop_mean)>expand_threshold, determine that the upper boundary ordinate is y1 and no longer expand; otherwise update the upper boundary ordinate of the region and = y1-b
[0095] 5) Select the right edge of the rectangular area, the corresponding coordinate point of the edge is [(x2,y1), (x2,y2)], expand to the right to get the new coordinates [(x2+a,y1), (x2+a,y2)], get the new rectangular coordinates [(x1,y1), (x2+a,y1), (x2+a,y2), (x1,y2)], and calculate the pixel mean of the current expansion area as crop_mean_right. If abs(crop_mean_right-crop_mean)>expand_threshold, determine the horizontal coordinate of the right edge to be x2 and no longer expand; otherwise update the horizontal coordinate of the right edge of the area x2=x2+a
[0096] 6) Select the lower boundary of the rectangular area, the corresponding coordinate point of the boundary is [(x2,y2), (x1,y2)], expand to the lower side to obtain the new coordinates [(x2,y2+b), (x1,y2+b)], and obtain the new rectangular coordinates [(x1,y1), (x2,y1), (x2,y2+b), (x1,y2+b)], and calculate the pixel mean of the current expansion area as crop_mean_down. If abs(crop_mean_down-crop_mean)>expand_threshold, the vertical coordinate of the lower boundary is determined to be y2 and no longer expand; otherwise, the horizontal coordinate of the lower boundary of the updated area y2=y2+b
[0097] 7) Repeat the process from 3) to 6) until the expansion stops in all four directions, and the best translation area is obtained.
[0098] Note that each time you expand, you need to determine whether the expanded coordinates overflow the image boundaries. If so, stop expanding in the current direction.
[0099] 1.2. Method for determining the maximum translation area by multi-scale expansion steps in different directions
[0100] Based on the method proposed in 1.1, the optimal rendering translation area can be obtained by expanding the coordinates of the initial translation area. On this basis, a multi-scale step-size optimal rendering area search method is proposed.
[0101] The main steps of the proposed method are as follows:
[0102] 1) Set the multi-scale step size of horizontal and vertical expansion scale_anchors = [(a1, b1), (a2, b2), ..., (an, bn)], where a represents the step size of progressive expansion in the horizontal direction and b represents the step size of progressive expansion in the vertical direction
[0103] 2) Loop scale_anchors, select the i-th group of steps (ai, bi), and use the progressive expansion method based on the mean change of regional pixels in 1.1 to obtain the coordinates and area of the extended translation region based on the current step size
[0104] 3) One set of step sizes will maximize the area expansion, and the coordinates of the expanded area corresponding to this step size are the final translation typesetting area.
[0105] Among them, the readable storage medium can be a computer storage medium or a communication medium. The communication medium includes any medium that facilitates the transmission of a computer program from one place to another. The computer storage medium can be any available medium that can be accessed by a general or special-purpose computer. For example, a readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application-specific integrated circuit (ASIC). In addition, the ASIC can be located in a user device. Of course, the processor and the readable storage medium can also exist in a communication device as discrete components. The readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.
[0106] The present invention also provides a program product, which includes an execution instruction, which is stored in a readable storage medium. At least one processor of a device can read the execution instruction from the readable storage medium, and at least one processor executes the execution instruction so that the device implements the methods provided in the above various embodiments.
[0107] In the above-mentioned terminal or server embodiment, it should be understood that the processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the present invention can be directly embodied as being executed by a hardware processor, or can be executed by a combination of hardware and software modules in the processor.
[0108] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for determining typesetting areas based on comic translation, characterized in that: include: Presetting multiple groups of expansion step values in different directions, wherein the expansion step values are used to gradually expand the translation area in the horizontal and / or vertical directions; Based on the region progressive expansion method and each group of expansion step values, the initial translation region is expanded to obtain a candidate expansion region, and the area of the candidate expansion region is calculated, including: obtaining the rectangular coordinates of the initial translation region, the rectangular coordinates are the coordinates of the four vertex positions of the upper, lower, left and right of the initial translation region, and calculating the pixel mean of the initial translation region according to the rectangular coordinates; selecting any side boundary of the initial translation region, the side boundaries include: a left boundary, an upper boundary, a right boundary, and a lower boundary; based on the expansion step value, the side boundary is expanded outward in the corresponding side direction to obtain the current expansion region, and the current expansion region is calculated according to the rectangular coordinates of the current expansion region. ; according to the pixel means of the current extension area and the initial translation area, determining the side boundary coordinate value of the candidate extension area, including: if the pixel mean difference between the current extension area and the initial translation area is greater than a preset threshold, then the corresponding side boundary coordinate value of the initial translation area is used as the side boundary coordinate value of the candidate extension area; if the pixel mean difference between the current extension area and the initial translation area is less than or equal to the preset threshold, then the corresponding side boundary coordinate value of the current extension area is used as the side boundary coordinate value of the candidate extension area; the side boundary coordinate value includes: an upper side boundary ordinate, a lower side boundary ordinate, a left side boundary abscissa, and a right side boundary abscissa; The expansion step value with the largest expansion area is selected, and the candidate expansion area corresponding to the step value is used as the target translation typesetting area.
2. The method for determining typesetting areas based on comic translation according to claim 1, characterized in that: The method further comprises: Based on the expansion step value, the initial translation area is expanded in four directions, upward, downward, left and right, respectively, to obtain four side boundary coordinate values of the candidate expansion area; The area of the candidate extension region is calculated based on the four side boundary coordinate values.
3. The method for determining typesetting areas based on comic translation according to claim 1, characterized in that: Calculating the pixel mean of the initial translation area according to the rectangular coordinates includes: According to the rectangular coordinates of the initial translation area, the original image is cut out at the corresponding position using an existing computer image processing library; Based on the pixel representation of the image after the cutout processing, the mean value of all pixels in the image is calculated using the existing computer data processing library.
4. A device for determining typesetting areas based on comic translation, characterized in that: include: An expansion step value setting module, used to pre-set multiple groups of expansion step values in different directions, wherein the expansion step values are used to gradually expand the translation area in the horizontal and / or vertical directions; The candidate extension area calculation module is used to expand the initial translation area to obtain the candidate extension area based on the area progressive expansion method and each group of expansion step values, and calculate the area of the candidate extension area; it is also used to obtain the rectangular coordinates of the initial translation area, the rectangular coordinates are the coordinates of the four vertex positions of the initial translation area, and calculate the pixel mean of the initial translation area according to the rectangular coordinates; Select any side boundary of the initial translation area, the side boundaries include: left boundary, upper boundary, right boundary, and lower boundary; expand the side boundary outward in the corresponding side direction based on the expansion step value to obtain the current extension area, and calculate the pixel mean of the current extension area according to the rectangular coordinates of the current extension area; determine the side boundary coordinate value of the candidate extension area according to the pixel mean of the current extension area and the initial translation area; and further use, if the difference between the pixel mean of the current extension area and the initial translation area is greater than a preset threshold, then use the corresponding side boundary coordinate value of the initial translation area as the side boundary coordinate value of the candidate extension area; if the difference between the pixel mean of the current extension area and the initial translation area is less than or equal to the preset threshold, then use the corresponding side boundary coordinate value of the current extension area as the side boundary coordinate value of the candidate extension area; the side boundary coordinate value includes: upper side boundary ordinate, lower side boundary ordinate, left side boundary abscissa, and right side boundary abscissa; The target translation typesetting area determination module is used to select the extension step value with the largest extension area, and use the candidate extension area corresponding to the step value as the target translation typesetting area.
5. A computer device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 3 are implemented.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Paper characteristic identification method and relative device
CN102779275A
Image detection method and device
CN108921838A