Summary of the invention
Technical matters to be solved by this invention provides a kind of ancient books image repair method and device, position by bookbinding hole the page of ancient books document, select respectively to bind hole image block on every side in batches and screen the back filling, save great amount of manpower and time, improved the performance of image repair.
The invention discloses a kind of ancient books image repair method, comprise the steps:
Step 1: demarcate and respectively to bind the hole in the document template page or leaf image;
Step 2: according to respectively binding the bookbinding hole in other pages image in the location positioning document of demarcating in the hole in the masterplate page or leaf image, with document in respectively bind in the regional adjacent image block of demarcating in the hole and screen;
Step 3: the image block that screening is obtained is filled to the image-region that each binds the place, hole.
Respectively bind image-region adjacent eight rectangular neighborhoods of hole image block on every side for bookbinding place, hole in the described step 2, the length of side of each rectangular neighborhood is associated with the image-region at bookbinding place, hole.
Respectively bind when screening in the image block around the hole image block that the image block of pixel value variance minimum in the image block around each bookbinding hole is obtained as screening in the described step 2.
When being filled to the image-region at bookbinding place, hole in the described step 3, screening image block that obtains and the image-region of binding the place, hole are carried out boundary treatment.
Described boundary treatment is handled for sprouting wings.
The invention also discloses a kind of ancient books image fixing apparatus, comprise as lower module:
Demarcating module is demarcated and respectively to be bound the hole in the document template page or leaf image;
The screening module, according to respectively binding the bookbinding hole in other pages image in the location positioning document of demarcating in the hole in the masterplate page or leaf image, with document in respectively bind in the regional adjacent image block of demarcating in the hole and screen;
Packing module, the image block that screening is obtained is filled to the image-region that each binds the place, hole.
A kind of ancient books image repair method of the present invention and device, its advantage is: position by the bookbinding hole to the page of ancient books document, select respectively to bind hole image block on every side in batches and screen the back filling, great amount of manpower and time have been saved, improved the effect and the performance of image repair, be of great significance and value for the subsequent treatment and the image applications of various application systems.
Embodiment
For above-mentioned purpose of the present invention, feature and advantage can be become apparent more, the present invention is further detailed explanation below in conjunction with the drawings and specific embodiments.
The invention discloses a kind of ancient books image repair method, as shown in Figure 1, comprise the steps:
Step 1: demarcate and respectively to bind the hole in the document template page or leaf image;
Ancient books text to papery scans, and obtains the electronic document of ancient books text, contains the bookbinding hole that stays when disassembling the ancient books text of papery in each image in the electronic document.In the present embodiment, contain six bookbinding holes in every page of image, choose and include the optional position of binding the hole, manually the bookbinding hole in the masterplate page or leaf image of document is demarcated, in the present embodiment, the masterplate page or leaf of document is the homepage of document, demarcates and respectively binds the position of hole in document front figure picture.
In the present embodiment, as shown in Figure 2, the position at the place, bookbinding hole in the front figure picture is contained the rectangle of binding the hole with one and is demarcated, with upper left corner coordinate, the width of rectangle with highly represent to bind the hole.Error when binding the hole in order to reduce to demarcate writes down the wide of books and height simultaneously, when handling big image in different resolution, binds the near image border of Kongzui according to the wide of books and height location like this apart from each, and the nearest bookbinding hole of location and image border.The upper left corner of image is with (0,0) expression, the coordinate in the upper left corner of respectively binding the hole in the image for (x, y), width is w, highly is h.
Step 2: according to respectively binding the bookbinding hole in other pages image in the location positioning document of demarcating in the hole in the masterplate page or leaf image, with document in respectively bind in the regional adjacent image block of demarcating in the hole and screen;
Because other pages image is bound in the masterplate page or leaf image of document and the document, so the relative position of bookbinding hole and page area remains unchanged in each page of ancient books text, so can be according to the position in the bookbinding hole in other pages image in the location positioning document of respectively binding the hole in the masterplate page or leaf image.
Image-region to each bookbinding place, hole carries out graphical analysis respectively.As shown in Figure 3, screen in the image block around the bookbinding hole, each image block of binding around the hole is eight adjacent rectangular neighborhoods of image-region at bookbinding place, hole, and the length of side of each rectangular neighborhood is associated with the image-region at bookbinding place, hole.In the present embodiment, the image-region at bookbinding place, hole comprises the external quadrilateral in this bookbinding hole, eight rectangular neighborhoods of the image-region at this place, bookbinding hole are followed successively by neighborhood 1 to the length of side of 8, eight rectangular neighborhoods of neighborhood and are associated with the length of side of the image-region at bookbinding place, hole respectively.
When in each bookbinding image block around hole, screening, respectively neighborhood 1 to neighborhood 8 screen successively, choose in each neighborhood textural characteristics with the textural characteristics of the image-region at bookbinding place, hole nearest like neighborhood.In the present embodiment, because the zone of the variance minimum of pixel value is the most smooth zone in eight rectangular neighborhoods on image-region four limits at bookbinding place, hole, so the minimum method of employing variance is screened the textural characteristics of each rectangular neighborhood, get the variance of pixel value in each rectangular neighborhood of each calculated for pixel values in eight rectangular neighborhoods respectively, the image block that the rectangular neighborhood of the variance minimum of pixel value in eight rectangular neighborhoods is obtained as screening.
Step 3: the image block that screening is obtained is filled to the image-region that each binds the place, hole.
The image block of choosing after the screening is filled the image-region at bookbinding place, hole, and boundary treatment is carried out on the border of the image-region at bookbinding place, hole and the border of the image block after the screening, and described boundary treatment is handled for sprouting wings.
To the processing of sprouting wings between the border of the image-region at bookbinding place, hole and the border of image block after the screening, eliminated the vestige on border between the image-region at bookbinding hole place and the image block after the screening, played the effect of gradual change, the image-region at bookbinding place, hole and the image block after the screening are connected naturally, the image-region that has guaranteed to bind the hole place with screen after the textural characteristics of image block identical.In the present embodiment, screening image block that obtains and the image-region of binding the place, hole are merged by integration percentage P, each pixel in the image block that the statistics screening obtains and the distance D on its border, then
Fill the pixel value of the image-region at bookbinding place, hole before pixel value=fillings of image-region at bookbinding place, hole, back * (1-P)+the screen pixel value * P of the image block that obtains
Wherein, the variation of the image block frontier distance that obtains of each pixel in the image block that obtains with screening of integration percentage P and screening changes.As D 〉=10 the time, integration percentage P is 100%; When D<=9, integration percentage P is (D * 10) %.Merge the image-region that obtains filling bookbinding place, hole, back afterwards by integration percentage
Shown in Fig. 4 a, Fig. 4 b, Fig. 4 b is filled to the picture behind the image-region of binding the place, hole for the image block that screening is obtained, and as can be seen from the figure, repair with being flattened in the bookbinding hole.
Because each bookbinding hole relative position in each page of document is fixed, after then the bookbinding hole in the masterplate page or leaf image of document is demarcated and is finished, other page-images that can repair document successively according to the bookbinding relative position of hole in masterplate page or leaf image, thus whole ancient books repaired.
The invention also discloses a kind of ancient books image fixing apparatus, comprise as lower module:
Demarcating module is demarcated and respectively to be bound the hole in the document template page or leaf image;
The screening module, according to respectively binding the bookbinding hole in other pages image in the location positioning document of demarcating in the hole in the masterplate page or leaf image, with document in respectively bind in the regional adjacent image block of demarcating in the hole and screen;
Packing module, the image block that screening is obtained is filled to the image-region that each binds the place, hole.
A kind of ancient books image repair method of the present invention and device, position by bookbinding hole the page of ancient books document, select respectively to bind hole image block on every side in batches and screen the back filling, great amount of manpower and time have been saved, improved the effect and the performance of image repair, be of great significance and value for the subsequent treatment and the image applications of various application systems.