CN110533674B - Method and terminal for removing margins of picture - Google Patents

Method and terminal for removing margins of picture Download PDF

Info

Publication number
CN110533674B
CN110533674B CN201910789881.2A CN201910789881A CN110533674B CN 110533674 B CN110533674 B CN 110533674B CN 201910789881 A CN201910789881 A CN 201910789881A CN 110533674 B CN110533674 B CN 110533674B
Authority
CN
China
Prior art keywords
book
subinterval
interval
area
margin
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910789881.2A
Other languages
Chinese (zh)
Other versions
CN110533674A (en
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.)
Fujian Jieyu Computer Technology Co ltd
Original Assignee
Fujian Jieyu Computer 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 Fujian Jieyu Computer Technology Co ltd filed Critical Fujian Jieyu Computer Technology Co ltd
Priority to CN201910789881.2A priority Critical patent/CN110533674B/en
Publication of CN110533674A publication Critical patent/CN110533674A/en
Application granted granted Critical
Publication of CN110533674B publication Critical patent/CN110533674B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30176Document

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Analysis (AREA)

Abstract

The invention discloses a method and a terminal for removing margins of a picture, which are used for obtaining a book image to be processed and obtaining an area where a book is located; judging whether a first interval exists in the area of the book, wherein the color value of the first interval is in the margin color range, the distance between two adjacent vertical lines is lower than a preset width threshold value, or the inclination angle difference of two sub-intervals exceeds a preset angle threshold value, and if so, marking the first interval as a margin; and removing the margins. According to the invention, the phenomenon of the margins is comprehensively considered through the three judgment conditions, so that the accuracy of margin removal is ensured.

Description

Method and terminal for removing margins of picture
Technical Field
The present invention relates to the field of scanning devices, and in particular, to a method and a terminal for removing a margin of a picture.
Background
With the development of science and technology, more and more knowledge and materials have been shared on the internet, so that it is required to convert the conventional paper-based stored data to electronic stored data.
Because the book can appear crooked phenomenon when spreading out for the margin can appear in the both sides of book, along with the increase of the book page number and book thickness, the margin of book both sides also can be wider and wider. For the electronization of books, book information is usually recognized by shooting an image of a book, and at this time, there is a possibility that a margin phenomenon exists in the book image, and the margin does not contain the book information, but occupies an image size, which affects picture recognition efficiency.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: the method and the terminal for removing the margins of the picture can remove the margins of the book image.
In order to solve the technical problems, the invention adopts the technical scheme that:
a method for removing margins of a picture comprises the following steps:
s1, acquiring a book image to be processed to obtain an area where the book is located;
s2, judging whether a first interval exists in the area where the book is located, wherein the color value is in the margin color range, the distance between two adjacent vertical lines is lower than a preset width threshold value, or the inclination angle difference of two sub-intervals exceeds a preset angle threshold value, and if so, marking the first interval as a margin;
and S3, removing the margins.
In order to solve the technical problem, the invention adopts another technical scheme as follows:
a terminal for removing margins from pictures, comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps:
s1, acquiring a book image to be processed to obtain an area where the book is located;
s2, judging whether a first interval exists in the area where the book is located, wherein the color value is in the margin color range, the distance between two adjacent vertical lines is lower than a preset width threshold value, or the inclination angle difference of two sub-intervals exceeds a preset angle threshold value, and if so, marking the first interval as a margin;
and S3, removing the margins.
The invention has the beneficial effects that: a method and terminal for removing page margin of a picture, after obtaining a book image to be processed, determining the area of the book; by judging whether a first interval exists in the area where the book is located, wherein the color value is in the margin color range, or the distance between two adjacent vertical lines is lower than a preset width threshold value, or the inclination angle difference between two sub-intervals exceeds a preset angle threshold value, if the first interval exists, the position of the first interval is the position of the margin of the book image, and then the margin is removed. Through the three judgment conditions, the phenomenon of the margins is comprehensively considered, and the accuracy of margin removal is ensured.
Drawings
Fig. 1 is a schematic flowchart of a method for removing a margin from a picture according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a terminal for removing a margin from a picture according to an embodiment of the present invention.
Description of reference numerals:
1. a terminal for removing margins of a picture; 2. a processor; 3. a memory.
Detailed Description
In order to explain technical contents, achieved objects, and effects of the present invention in detail, the following description is made with reference to the accompanying drawings in combination with the embodiments.
Referring to fig. 1, a method for removing a margin of a picture includes the steps of:
s1, acquiring a book image to be processed to obtain an area where the book is located;
s2, judging whether a first interval exists in the area where the book is located, wherein the color value is in the margin color range, the distance between two adjacent vertical lines is lower than a preset width threshold value, or the inclination angle difference of two sub-intervals exceeds a preset angle threshold value, and if so, marking the first interval as a margin;
and S3, removing the margins.
From the above description, the beneficial effects of the present invention are: after acquiring an image of a book to be processed, determining an area where the book is located; by judging whether a first interval exists in the area where the book is located, wherein the color value is in the margin color range, or the distance between two adjacent vertical lines is lower than a preset width threshold value, or the inclination angle difference between two sub-intervals exceeds a preset angle threshold value, if the first interval exists, the position of the first interval is the position of the margin of the book image, and then the margin is removed. Through the three judgment conditions, the phenomenon of the margins is comprehensively considered, and the accuracy of margin removal is ensured.
The accuracy comprises the accuracy degree of the margin judged by the system as the actual margin and the coincidence degree of the range of the margin judged by the system and the range of the actual margin.
Further, the step S2 is specifically:
judging whether a first interval with the distance between two adjacent vertical lines lower than a preset width threshold exists in the area where the book is located, and if so, marking the first interval as a margin;
otherwise, judging whether a first interval with the inclination angle difference of two sub-intervals exceeding a preset angle threshold exists in the area of the book, and if so, marking the first interval as a margin;
otherwise, judging whether a first interval with the color value in the margin color range exists in the area of the book, and if so, marking the first interval as a margin.
From the above description, it can be known that the vertical line information is firstly determined, then the smoothness of the book edge is determined, and then the determination is performed according to the color difference. The method can determine the page margin information quickly by judging in advance through the factors with obvious characteristics and high identification accuracy, thereby improving the identification efficiency of the page margin.
Further, the step S2, determining whether there is a first interval in which the distance between two adjacent vertical lines in the area where the book is located is lower than a preset width threshold, specifically includes:
acquiring vertical lines through an edge detection algorithm, sequentially calculating the distance between every two adjacent vertical lines, taking the vertical line closest to the center of the area where the book is located in all the vertical lines with the adjacent distance being lower than a preset width threshold value as an end line, taking a side boundary line, close to the end line, of the area where the book is located as an initial line, and taking an interval between the initial line and the end line as a first interval;
and if the distance between the two first intervals is smaller than a preset gap threshold value, combining the two first intervals into one.
It should be noted that, after the area where the book is located is determined, the center of the area where the book is located may be taken as one half of the lateral position of the book, or the center of the book may be determined by other methods in consideration of the unequal number of pages on the two sides. Meanwhile, the area of the book comprises four side boundary lines, namely an upper boundary line, a lower boundary line, a left boundary line and a right boundary line.
From the above description, it can be seen that the side edges of each page are stacked as margins on both sides of the book when the book is unfolded. For the side edges on the margins, the side edges are basically closely adjacent and are multiple, so that the margins are determined, and the accuracy of margin removal is ensured; meanwhile, in order to ensure that the page margin range can be accurately defined when the fault appears on the same side of a partial book after the partial book is spread out, and simultaneously avoid the situation that the page margins on the two sides are mixed up into one page margin, a preset gap threshold value is set, and the preset gap threshold value is the page margin on the same side, so that the position information of the partial book is combined.
Further, the step S2 of "determining whether there is a first section in which the difference between the tilt angles of the two sub-sections exceeds the preset angle threshold" includes:
judging whether the book image to be processed belongs to a laser flattening image, if so, acquiring laser beams of the laser flattening image in the area where the book is located, taking any one of the laser beams projected on the book as a parallel reference line, otherwise, acquiring boundary lines of the upper side and the lower side of the area where the book is located, and taking the boundary lines of the upper side and the lower side as the parallel reference lines;
and judging whether the difference between the inclination angle of a certain subinterval and the inclination angle of an adjacent subinterval of the parallel reference line exceeds a preset angle threshold, if so, taking one subinterval with the inclination angle difference exceeding the preset angle threshold as a critical subinterval, and determining the interval from the side boundary line of the book area close to the critical subinterval as a first interval.
As can be seen from the above description, if the image is laser-flattened, the change of the inclination angle of the whole book in one direction can be obtained according to the position information of the laser beam; if the image is other normal images, because no laser beam is used as a parallel reference line of the book, boundary lines on the upper side and the lower side are selected as the parallel reference lines. When the difference of the inclination angles exceeds a preset angle threshold value, the subintervals close to the left and right boundary lines are within the page range, and the subintervals far away from the left and right boundary lines are within the page range, so that the positions of the pages are determined, and the accuracy of removing the pages is ensured.
Further, in the step S2, "determining whether the parallel reference line has a difference between the inclination angle of a certain subinterval and the inclination angle of an adjacent subinterval that exceeds a preset angle threshold, if so, taking one of the subintervals with the difference exceeding the preset angle threshold as a critical subinterval, and determining a section from a side boundary line of the area where the book is located, which is close to the critical subinterval, to the critical subinterval as a first section" specifically includes:
sequentially intercepting a first subinterval and a second subinterval from a quarter position of a boundary line of the parallel datum line close to the left side and the right side to a direction far away from the center of the area where the book is located, wherein the length of the subinterval is between 3 pixels and 10 pixels;
calculating the inclination angles of the parallel datum lines in a first subinterval and a second subinterval, judging whether the difference between the inclination angle of the first subinterval and the inclination angle of the second subinterval exceeds a preset angle threshold, if so, taking the first subinterval as a critical subinterval, otherwise, continuously obtaining the next subinterval until the difference between the inclination angle of one subinterval and the inclination angle of the previous subinterval exceeds the preset angle threshold, and taking the subinterval close to the center of the area where the book is located in the two subintervals with the inclination angle difference exceeding the preset angle threshold as the critical subinterval;
and determining an interval from a side boundary line of the area where the book is located, which is close to the critical subinterval, to the critical subinterval as a first interval.
From the above description, the margins are respectively arranged at the left side and the right side, and the image proportion occupied by the margins is usually only a small part of the margin, so that the margins are intercepted from the quarter position, that is, the accuracy of final margin removal is not influenced, and the margin removal efficiency is improved; sub-intervals are divided by several pixels and then compared one by one to approach the side boundary line. The interval size is set to ensure that the position of the inclination angle change can be accurately identified, so that the position of the margin is accurately determined.
Referring to fig. 2, a terminal for removing a margin of a picture includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the computer program to implement the following steps:
s1, acquiring a book image to be processed to obtain an area where the book is located;
s2, judging whether a first interval exists in the area where the book is located, wherein the color value is in the margin color range, the distance between two adjacent vertical lines is lower than a preset width threshold value, or the inclination angle difference of two sub-intervals exceeds a preset angle threshold value, and if so, marking the first interval as a margin;
and S3, removing the margins.
From the above description, the beneficial effects of the present invention are: after acquiring an image of a book to be processed, determining an area where the book is located; by judging whether a first interval exists in the area where the book is located, wherein the color value is in the margin color range, or the distance between two adjacent vertical lines is lower than a preset width threshold value, or the inclination angle difference between two sub-intervals exceeds a preset angle threshold value, if the first interval exists, the position of the first interval is the position of the margin of the book image, and then the margin is removed. Through the three judgment conditions, the phenomenon of the margins is comprehensively considered, and the accuracy of margin removal is ensured.
Further, the step S2 is specifically:
judging whether a first interval with the distance between two adjacent vertical lines lower than a preset width threshold exists in the area where the book is located, and if so, marking the first interval as a margin;
otherwise, judging whether a first interval with the inclination angle difference of two sub-intervals exceeding a preset angle threshold exists in the area of the book, and if so, marking the first interval as a margin;
otherwise, judging whether a first interval with the color value in the margin color range exists in the area of the book, and if so, marking the first interval as a margin.
From the above description, it can be known that the vertical line information is firstly determined, then the smoothness of the book edge is determined, and then the determination is performed according to the color difference. The method can determine the page margin information quickly by judging in advance through the factors with obvious characteristics and high identification accuracy, thereby improving the identification efficiency of the page margin.
Further, the step S2, determining whether there is a first interval in which the distance between two adjacent vertical lines in the area where the book is located is lower than a preset width threshold, specifically includes:
acquiring vertical lines through an edge detection algorithm, sequentially calculating the distance between every two adjacent vertical lines, taking the vertical line closest to the center of the area where the book is located in all the vertical lines with the adjacent distance being lower than a preset width threshold value as an end line, taking a side boundary line, close to the end line, of the area where the book is located as an initial line, and taking an interval between the initial line and the end line as a first interval;
and if the distance between the two first intervals is smaller than a preset gap threshold value, combining the two first intervals into one.
From the above description, it can be seen that the side edges of each page are stacked as margins on both sides of the book when the book is unfolded. For the side edges on the margins, the side edges are basically closely adjacent and are multiple, so that the margins are determined, and the accuracy of margin removal is ensured; in order to ensure that the page margin range can be accurately defined when the fault occurs on the same side of a partial book after the partial book is spread out, and simultaneously avoid the situation that the page margins on the two sides are mixed into one page margin, a preset gap threshold value is set, and the preset gap threshold value is the page margin on the same side, so that the position information of the partial book is combined.
Further, the step S2 of "determining whether there is a first section in which the difference between the tilt angles of the two sub-sections exceeds the preset angle threshold" includes:
judging whether the book image to be processed belongs to a laser flattening image, if so, acquiring laser beams of the laser flattening image in the area where the book is located, taking any one of the laser beams projected on the book as a parallel reference line, otherwise, acquiring boundary lines of the upper side and the lower side of the area where the book is located, and taking the boundary lines of the upper side and the lower side as the parallel reference lines;
and judging whether the difference between the inclination angle of a certain subinterval and the inclination angle of an adjacent subinterval of the parallel reference line exceeds a preset angle threshold, if so, taking one subinterval with the inclination angle difference exceeding the preset angle threshold as a critical subinterval, and determining the interval from the side boundary line of the book area close to the critical subinterval as a first interval.
As can be seen from the above description, if the image is laser-flattened, the change of the inclination angle of the whole book in one direction can be obtained according to the position information of the laser beam; if the image is other normal images, because no laser beam is used as a parallel reference line of the book, boundary lines on the upper side and the lower side are selected as the parallel reference lines. When the difference of the inclination angles exceeds a preset angle threshold value, the subintervals close to the left and right boundary lines are within the page range, and the subintervals far away from the left and right boundary lines are within the page range, so that the positions of the pages are determined, and the accuracy of removing the pages is ensured.
Further, in the step S2, "determining whether the parallel reference line has a difference between the inclination angle of a certain subinterval and the inclination angle of an adjacent subinterval that exceeds a preset angle threshold, if so, taking one of the subintervals with the difference exceeding the preset angle threshold as a critical subinterval, and determining a section from a side boundary line of the area where the book is located, which is close to the critical subinterval, to the critical subinterval as a first section" specifically includes:
sequentially intercepting a first subinterval and a second subinterval from a quarter position of a boundary line of the parallel datum line close to the left side and the right side to a direction far away from the center of the area where the book is located, wherein the length of the subinterval is between 3 pixels and 10 pixels;
calculating the inclination angles of the parallel datum lines in a first subinterval and a second subinterval, judging whether the difference between the inclination angle of the first subinterval and the inclination angle of the second subinterval exceeds a preset angle threshold, if so, taking the first subinterval as a critical subinterval, otherwise, continuously obtaining the next subinterval until the difference between the inclination angle of one subinterval and the inclination angle of the previous subinterval exceeds the preset angle threshold, and taking the subinterval close to the center of the area where the book is located in the two subintervals with the inclination angle difference exceeding the preset angle threshold as the critical subinterval;
and determining an interval from a side boundary line of the area where the book is located, which is close to the critical subinterval, to the critical subinterval as a first interval.
From the above description, the margins are respectively arranged at the left side and the right side, and the image proportion occupied by the margins is usually only a part of the margin, so that the margins are intercepted from the quarter position, that is, the accuracy of final margin removal is not influenced, and the margin removal efficiency is improved; sub-intervals are divided by several pixels and then compared one by one to approach the side boundary line. The interval size is set to ensure that the position of the inclination angle change can be accurately identified, so that the position of the margin is accurately determined.
Referring to fig. 1, a first embodiment of the present invention is:
a method for removing margins of a picture comprises the following steps:
s1, acquiring a book image to be processed to obtain an area where the book is located; in this embodiment, after the area where the book is located is determined, a place other than the book may be set to appear black or another color different from the book color.
S2, judging whether a first interval exists in the area of the book, wherein the color value of the first interval is in the margin color range, the distance between two adjacent vertical lines is lower than a preset width threshold value, or the inclination angle difference of two sub-intervals exceeds a preset angle threshold value, and if so, marking the first interval as a margin;
and S3, removing the margins.
In this embodiment, step S2 specifically includes:
judging whether a first interval with the distance between two adjacent vertical lines lower than a preset width threshold exists in the area where the book is located, and if so, marking the first interval as a margin; the plurality of vertical lines are arranged in parallel and densely, the characteristics are obviously easy to obtain, and the difference between the characteristics and the page interface is large, so that the vertical lines are firstly identified and judged;
otherwise, judging whether a first interval with the inclination angle difference of two sub-intervals exceeding a preset angle threshold exists in the area of the book, and if so, marking the first interval as a margin; wherein, the margin and the page interface form an obvious included angle, the included angle is judged by the inclination angle of the subinterval, the junction of the margin and the page interface is found, and the margin is the margin close to the outer side;
otherwise, judging whether a first interval with the color value in the margin color range exists in the area of the book, and if so, marking the first interval as a margin. Finally, the margins are distinguished through colors so as to define the positions of the margins as much as possible.
In this embodiment, the step S2, "determining whether there is a first interval in which the distance between two adjacent vertical lines in the area where the book is located is lower than the preset width threshold" specifically includes:
acquiring vertical lines through an edge detection algorithm, sequentially calculating the distance between every two adjacent vertical lines, taking the vertical line closest to the center of the area where the book is located in all the vertical lines with the adjacent distance being lower than a preset width threshold value as an end line, taking a side boundary line, close to the end line, of the area where the book is located as an initial line, and taking an interval between the initial line and the end line as a first interval; in this embodiment, the edge detection algorithm includes, but is not limited to, Sobel operator, Laplacian operator, and Canny operator, and the simple understanding of the termination line is the innermost vertical line, wherein the first interval includes an interval between the innermost vertical line of the left region and the left boundary line, and an interval between the innermost vertical line of the right region and the right boundary line; the side boundary line includes an upper boundary line, a lower boundary line, a left boundary line, and a right boundary line.
And if the distance between the two first intervals is smaller than the preset gap threshold value, combining the two first intervals into one.
The two subintervals may be margins on two sides, but the margins on the two sides are far away, while the margins on the same side are close, and the two conditions are distinguished by a preset gap threshold value so as to ensure the accuracy of position definition of the margins.
Specifically, the step S2 of "determining whether there is a first section in the area where the book is located where the difference between the tilt angles of the two sub-sections exceeds the preset angle threshold" includes:
judging whether the book image to be processed belongs to a laser flattening image, if so, acquiring laser beams of the laser flattening image in the area of the book, taking any one of the laser beams projected on the book as a parallel reference line, otherwise, acquiring boundary lines on the upper side and the lower side of the area of the book, and taking the boundary lines on the upper side and the lower side as the parallel reference lines; in this embodiment, at least two laser beams are selected, and the laser beams are disposed on the upper and lower sides as much as possible.
And judging whether the difference between the inclination angle of a certain subinterval and the inclination angle of an adjacent subinterval of the parallel reference line exceeds a preset angle threshold, if so, taking one subinterval with the inclination angle difference exceeding the preset angle threshold as a critical subinterval, and determining the interval from the side boundary line of the area where the book is located, which is close to the critical subinterval, to the critical subinterval as a first interval. At least two parallel reference lines are arranged, and critical subintervals can be obtained respectively through connection to obtain a dividing boundary line, and the outer part is a margin.
Specifically, in step S2, "determining whether there is a difference between the tilt angle of a certain subinterval and the tilt angle of an adjacent subinterval of the parallel reference line that exceeds a preset angle threshold, if yes, taking one of the subintervals with the difference exceeding the preset angle threshold as a critical subinterval, and determining the interval between the side boundary line of the area where the book is located and the critical subinterval as the first interval" specifically includes:
sequentially intercepting a first subinterval and a second subinterval from a quarter position of a boundary line of the parallel datum line close to the left side and the right side to a direction far away from the center of the area where the book is located, wherein the length of the subinterval is between 3 pixels and 10 pixels; preferably five pixels or six pixels in the present embodiment.
Calculating the inclination angles of the parallel datum lines in the first subintervals and the second subintervals, judging whether the difference between the inclination angle of the first subintervals and the inclination angle of the second subintervals exceeds a preset angle threshold value, if so, taking the first subintervals as critical subintervals, otherwise, continuously acquiring the next subintervals until the difference between the inclination angle of one subinterval and the inclination angle of the previous subinterval exceeds the preset angle threshold value, and taking the subinterval close to the center of the area where the book is located in the two subintervals with the inclination angle difference exceeding the preset angle threshold value as the critical subintervals;
and determining the interval from the side boundary line close to the critical subinterval on the area where the book is positioned as a first interval. The critical subinterval of the left area reaches the left boundary line, and the critical subinterval of the right area reaches the right boundary line, so that the first interval is respectively arranged in the left area and the right area and corresponds to the two sides of the book.
Referring to fig. 1, the second embodiment of the present invention is:
on the basis of the foregoing embodiment, the step S2 further includes:
if the color value of the area where the book is located is in the margin color range, the distance between two adjacent vertical lines is not smaller than the preset width threshold value, and the first interval with the inclination angle difference of two sub-intervals exceeding the preset angle threshold value does not exist, multiplying the ratio numerical values obtained by converting the three actual numerical values and the preset threshold value by the respective weight values to obtain weight fraction values, judging whether the weight fraction values are larger than the weight threshold value, and if so, considering the area as the margin. Thereby further improving the accuracy of the margin removal.
Referring to fig. 2, a third embodiment of the present invention is:
a terminal 1 for removing margins of pictures comprises a memory 3, a processor 2 and a computer program stored on the memory 3 and capable of running on the processor 2, wherein the processor executes the computer program 2 to realize the steps of the first embodiment.
Referring to fig. 2, a fourth embodiment of the present invention is:
a terminal 1 for removing margins of pictures, on the basis of the third embodiment, when a processor 2 executes a computer program, the steps of the second embodiment are implemented.
In summary, according to the method and the terminal for removing the margins of the picture, provided by the invention, after the book image to be processed is obtained, the area where the book is located is determined; the vertical line information is judged firstly, then the smoothness of the edge of the book is judged, and then the judgment is carried out according to the color difference, namely the judgment is carried out in advance through the factors with obvious characteristics and high identification accuracy, so that the page edge information can be determined quickly, and the identification efficiency of the page edge is improved. The margins are determined by the closely adjacent vertical lines which are multiple, so that the accuracy of margin removal is ensured; and a preset gap threshold value is set to ensure that the margin range can be accurately defined when the faults can appear on the same side of a part of books after the books are spread out, and simultaneously the margins on the two sides are prevented from being mixed into one margin. The laser flattening image and other normal images are distinguished to find a proper parallel reference line, so that the position of the margin is determined according to the inclination angle difference corresponding to each subinterval of the parallel reference line, and the accuracy of removing the margin is guaranteed. On the basis, intercepting is started from the quarter position, so that the efficiency of removing the margins can be further improved; and the sub-intervals are divided by adopting a plurality of pixels to ensure that the position of the inclination angle change can be accurately identified, so that the position of the margin is accurately determined. The efficiency and the accuracy of margin removal can be guaranteed through the scheme.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all equivalent changes made by using the contents of the present specification and the drawings, or applied directly or indirectly to the related technical fields, are included in the scope of the present invention.

Claims (4)

1. A method for removing margins of a picture is characterized by comprising the following steps:
s1, acquiring a book image to be processed to obtain an area where the book is located;
s2, judging whether a first interval with the distance between two adjacent vertical lines lower than a preset width threshold exists in the area where the book is located, and if so, marking the first interval as a margin;
otherwise, judging whether a first interval with the inclination angle difference of two sub-intervals exceeding a preset angle threshold exists in the area of the book, and if so, marking the first interval as a margin;
otherwise, judging whether a first interval with the color value in the margin color range exists in the area of the book, and if so, marking the first interval as a margin;
s3, removing the margins;
the step S2 of "determining whether there is a first section in which the difference between the inclination angles of the two subintervals exceeds the preset angle threshold" specifically includes:
judging whether the book image to be processed belongs to a laser flattening image, if so, acquiring laser beams of the laser flattening image in the area where the book is located, taking any one of the laser beams projected on the book as a parallel reference line, otherwise, acquiring boundary lines of the upper side and the lower side of the area where the book is located, and taking the boundary lines of the upper side and the lower side as the parallel reference lines;
sequentially intercepting a first subinterval and a second subinterval from a quarter position of a boundary line of the parallel datum line close to the left side and the right side to a direction far away from the center of the area where the book is located, wherein the length of the subinterval is between 3 pixels and 10 pixels;
calculating the inclination angles of the parallel datum lines in a first subinterval and a second subinterval, judging whether the difference between the inclination angle of the first subinterval and the inclination angle of the second subinterval exceeds a preset angle threshold, if so, taking the first subinterval as a critical subinterval, otherwise, continuously obtaining the next subinterval until the difference between the inclination angle of one subinterval and the inclination angle of the previous subinterval exceeds the preset angle threshold, and taking the subinterval close to the center of the area where the book is located in the two subintervals with the inclination angle difference exceeding the preset angle threshold as the critical subinterval;
and determining an interval from a side boundary line of the area where the book is located, which is close to the critical subinterval, to the critical subinterval as a first interval.
2. The method for removing the margins of the picture according to claim 1, wherein the step S2 of determining whether the book has a first interval in which the distance between two adjacent vertical lines is lower than a preset width threshold in the area of the book specifically includes:
acquiring vertical lines through an edge detection algorithm, sequentially calculating the distance between every two adjacent vertical lines, taking the vertical line closest to the center of the area where the book is located in all the vertical lines with the adjacent distance being lower than a preset width threshold value as an end line, taking a side boundary line, close to the end line, of the area where the book is located as an initial line, and taking an interval between the initial line and the end line as a first interval;
and if the distance between the two first intervals is smaller than a preset gap threshold value, combining the two first intervals into one.
3. A terminal for removing margins from pictures, comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor executes the computer program to implement the following steps:
s1, acquiring a book image to be processed to obtain an area where the book is located;
s2, judging whether a first interval with the distance between two adjacent vertical lines lower than a preset width threshold exists in the area where the book is located, and if so, marking the first interval as a margin;
otherwise, judging whether a first interval with the inclination angle difference of two sub-intervals exceeding a preset angle threshold exists in the area of the book, and if so, marking the first interval as a margin;
otherwise, judging whether a first interval with the color value in the margin color range exists in the area of the book, and if so, marking the first interval as a margin;
s3, removing the margins;
the step S2 of "determining whether there is a first section in which the difference between the inclination angles of the two subintervals exceeds the preset angle threshold" specifically includes:
judging whether the book image to be processed belongs to a laser flattening image, if so, acquiring laser beams of the laser flattening image in the area where the book is located, taking any one of the laser beams projected on the book as a parallel reference line, otherwise, acquiring boundary lines of the upper side and the lower side of the area where the book is located, and taking the boundary lines of the upper side and the lower side as the parallel reference lines;
sequentially intercepting a first subinterval and a second subinterval from a quarter position of a boundary line of the parallel datum line close to the left side and the right side to a direction far away from the center of the area where the book is located, wherein the length of the subinterval is between 3 pixels and 10 pixels;
calculating the inclination angles of the parallel datum lines in a first subinterval and a second subinterval, judging whether the difference between the inclination angle of the first subinterval and the inclination angle of the second subinterval exceeds a preset angle threshold, if so, taking the first subinterval as a critical subinterval, otherwise, continuously obtaining the next subinterval until the difference between the inclination angle of one subinterval and the inclination angle of the previous subinterval exceeds the preset angle threshold, and taking the subinterval close to the center of the area where the book is located in the two subintervals with the inclination angle difference exceeding the preset angle threshold as the critical subinterval;
and determining an interval from a side boundary line of the area where the book is located, which is close to the critical subinterval, to the critical subinterval as a first interval.
4. The terminal for removing margins of a picture according to claim 3, wherein in the step S2, "determining whether there is a first interval in which the distance between two adjacent vertical lines in the area of the book is lower than a preset width threshold" specifically includes:
acquiring vertical lines through an edge detection algorithm, sequentially calculating the distance between every two adjacent vertical lines, taking the vertical line closest to the center of the area where the book is located in all the vertical lines with the adjacent distance being lower than a preset width threshold value as an end line, taking a side boundary line, close to the end line, of the area where the book is located as an initial line, and taking an interval between the initial line and the end line as a first interval;
and if the distance between the two first intervals is smaller than a preset gap threshold value, combining the two first intervals into one.
CN201910789881.2A 2019-08-26 2019-08-26 Method and terminal for removing margins of picture Active CN110533674B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910789881.2A CN110533674B (en) 2019-08-26 2019-08-26 Method and terminal for removing margins of picture

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910789881.2A CN110533674B (en) 2019-08-26 2019-08-26 Method and terminal for removing margins of picture

Publications (2)

Publication Number Publication Date
CN110533674A CN110533674A (en) 2019-12-03
CN110533674B true CN110533674B (en) 2022-05-03

Family

ID=68662823

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910789881.2A Active CN110533674B (en) 2019-08-26 2019-08-26 Method and terminal for removing margins of picture

Country Status (1)

Country Link
CN (1) CN110533674B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103905689A (en) * 2012-12-24 2014-07-02 三星电子株式会社 Image scanning apparatus, method for image compensation and computer-readable recording medium
CN105979117A (en) * 2016-04-28 2016-09-28 大连成者科技有限公司 Laser line-based curved page image flattening method
CN106778608A (en) * 2010-07-06 2017-05-31 星火有限公司 Method and system for lifting reading experience
CN107516085A (en) * 2017-09-01 2017-12-26 山西同方知网数字出版技术有限公司 A kind of method that black surround is automatically removed based on file and picture
CN108875616A (en) * 2018-06-07 2018-11-23 广东数相智能科技有限公司 A kind of Books Chaotic Frame detection method, electronic equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106778608A (en) * 2010-07-06 2017-05-31 星火有限公司 Method and system for lifting reading experience
CN103905689A (en) * 2012-12-24 2014-07-02 三星电子株式会社 Image scanning apparatus, method for image compensation and computer-readable recording medium
CN105979117A (en) * 2016-04-28 2016-09-28 大连成者科技有限公司 Laser line-based curved page image flattening method
CN107516085A (en) * 2017-09-01 2017-12-26 山西同方知网数字出版技术有限公司 A kind of method that black surround is automatically removed based on file and picture
CN108875616A (en) * 2018-06-07 2018-11-23 广东数相智能科技有限公司 A kind of Books Chaotic Frame detection method, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN110533674A (en) 2019-12-03

Similar Documents

Publication Publication Date Title
EP2547111B1 (en) Method and apparatus for processing multi-view image using hole rendering
US8611641B2 (en) Method and apparatus for detecting disparity
Zhao et al. Detecting digital image splicing in chroma spaces
US8660373B2 (en) PDF de-chunking and object classification
JP2010171976A (en) Method and system for correcting distorted document image
EP2668770A1 (en) Image processing apparatus and method of supplementing pixel value
EP0526197B1 (en) Image processing
US20150339827A1 (en) Image processing apparatus, method, and medium
CN101286230B (en) Image processing apparatus and method thereof
US8306335B2 (en) Method of analyzing digital document images
EP2735998A1 (en) Image processing apparatus
US20140140608A1 (en) Image processing apparatus and method for color-depth demosaicing
US8526759B2 (en) Method of filling a hole in a virtual view image warped from a two-dimensional image
JP6543025B2 (en) Image processing apparatus and image processing method
KR20120138642A (en) Image processing method and image processing apparatus
CN110533674B (en) Method and terminal for removing margins of picture
CN103106405B (en) Line segmentation method and line segmentation system for document images
US9858512B2 (en) Image processing apparatus with an improved detection of ruled lines
CN106846419B (en) Method and device for determining portrait outline in image
EP3331232B1 (en) Image processing device
US9667832B2 (en) Image processing apparatus
JP6272219B2 (en) Image processing apparatus, image processing method, and program
US7474804B2 (en) Method for automatically correcting skew image
US10970817B2 (en) Image magnifying apparatus
CN107020845A (en) The image processing apparatus and image processing method of time needed for estimation print processing

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant