Disclosure of Invention
The invention aims to provide an automatic conjugation method of Dunhuang relic images, which can give consideration to the tightness of broken edge and slag openings and the accuracy of the width of a grid unit formed after the broken edge conjugation, and greatly improve the efficiency and the accuracy of the Dunhuang relic image conjugation.
The invention adopts the following technical scheme:
an automatic conjugation method of Dunhuang relic images comprises the following steps:
a: manually determining reference lines at the upper side, the lower side, the left side and the right side of the Dunhuang relic image and a middle reference line adjacent to the reference line at the left side to obtain a Dunhuang relic reference image;
b: the positions of a position coordinate point U of an upper datum line, a position coordinate point D of a lower datum line, a position coordinate point L of a left datum line, a position coordinate point R of a right datum line and a position coordinate point M of a middle datum line in the Dunhuang relic reference image obtained in the step A are positioned by a computer;
c: utilizing a computer to calculate the width of the grid unit in the standard reference image of the Dunhuang relic;
d: selecting a Dunhuang relic image with known real physical size and acquiring the real physical width of the grid unit, obtaining the width of the grid unit of the Dunhuang relic benchmark reference image corresponding to the Dunhuang relic image according to the steps A to C, and calculating the width value of the grid unit of the Dunhuang relic benchmark reference image corresponding to the Dunhuang relic image to restore to the scaling ratio gamma of the real physical size; wherein γ is β2Beta is the multiple relation between the width value of the grid unit of the Dunhuang relic film image and the real physical width value of the grid unit of the Dunhuang relic film;
e: carrying out edge detection on the Dunhuang relic image to extract edge lines of the Dunhuang relic image so as to obtain edge line images corresponding to each Dunhuang relic image;
f: utilizing a computer to obtain an edge line framework in an edge line image corresponding to each Dunhuang copy book residue image, and obtaining an edge line framework image corresponding to each Dunhuang copy book residue image, wherein the edge line framework refers to a central pixel point in an edge line;
g: manually determining the left side and the right side broken edge part in the edge line skeleton image of each Dunhuang relic image to obtain an edge line skeleton labeling image corresponding to each Dunhuang relic image;
h: g, respectively carrying out time serialization processing on the left side and the right side broken edge parts of the edge line skeleton in the edge line skeleton labeling image obtained in the step G to obtain corresponding two-dimensional numerical value type time serialization data;
i: using the product obtained in step DScaling the proportion gamma and the multiple relation beta, and enabling the position coordinate point L of the datum line obtained in the step B to be as follows: (l)x,ly)、M:(mx,my)、R:(rx,ry)、U:(ux,uy) And D: (d)x,dy) And converting into a position coordinate point L' of the reference line restored to the true physical size: (l'x,l′y)、M′:(m′x,m′y)、R′:(r′x,r′y)、U′:(u′x,u′y) And D': (d'x,d′y) (ii) a Then the width G of the grid unit obtained in the step CwConverted into the width G 'of the mesh unit restored to the real physical size'w(ii) a And D, two-dimensional time-series data T corresponding to the broken edge parts on the left side and the right side of the edge line skeleton obtained in the step H are subjected tolAnd TrRespectively converting the two-dimensional time-series data into two-dimensional time-series data T 'corresponding to broken edge parts on the left side and the right side of the edge line skeleton after the actual physical dimensions are restored'lAnd T'r;T′l={(V′l1,W′l1),(V′l2,W′l2),(V′l3,W′l3),…,(V′li,W′li)},T′r={(V′r1,W′r1),(V′r2,W′r2),(V′r3,W′r3),…,(V′ri,W′ri) I is a positive integer, (V'li,W′li) And (V'ri,W′ri) Respectively representing the pixel positions of ith pixel data of the left and right broken edge parts restored to the real physical size;
j: two-dimensional time-series data T 'obtained in step I'lV 'of'liAnd T'rV 'of'riAnd a position coordinate point L' of the reference line: (l'x,l′y) And R': (r'x,r′y) Respectively carrying out normalization processing to correspondingly obtain normalized time-series edge curve data TlAnd T ″)rAnd normalized reference line relative position coordinates L ″: (l ″)x,l″y) And R': (r ″)x,r″y),T″l={(V″l1,W″l1),(V″l2,W′l2),(V″l3,W″l3),…,(V″li,W″li)},T″r={(V″r1,W″r1),(V″r2,W″r2),(V″r3,W″r3),…,(V″ri,W″ri)};
K: respectively obtaining the time-sequenced edge curve data T' of the broken edge parts of the edge line skeletons of the two Dunhuang relic film images to be conjugated according to the step J after normalization treatmentlAnd T ″)rThen calculating the time sequence matching degree S of the two Dunhuang relic film images, and putting the time sequence matching degree S into a set S;
l: for each Dunhuang left-reading image a, the time sequence matching degree is calculated in turn according to the method in the step K; and finally, sorting the images from large to small according to the time sequence matching degree values, and returning the front H images with the highest similarity to the Dunhuang relic image a by taking the priority of smaller sliding distance if the time sequence matching degrees are the same as each other as alternative images with higher conjugation degree with the Dunhuang relic image a.
In the step A: firstly, regarding Dunhuang relic images with book boundaries on the upper parts, a horizontal line of a first color with the width of 1 pixel is drawn at a book horizontal grid line on the upper side of the Dunhuang relic images by using a pixel pen as an upper reference line; for Dunhuang copy remains image with book boundary at the lower part, drawing a transverse line of a first color with the width of 1 pixel at the transverse grid line of the book at the lower side of the Dunhuang copy remains image by using a pixel pen as a lower side reference line;
then, drawing a vertical line of a second color with the width of 1 pixel as a left reference line by using a pixel pen at the position of a book vertical grid line which is closest to the left side broken edge and is not interrupted of the Dunhuang relic image, and drawing a vertical line of a second color with the width of 1 pixel as a right reference line by using a pixel pen at the position of a book vertical grid line which is closest to the right side broken edge and is not interrupted of the Dunhuang relic image;
and finally, judging whether a vertical grid line of the book, except the right reference line, is adjacent to the right side of the left reference line in the Dunhuang relic image, if so, drawing a vertical line of a second color with the width of 1 pixel at the vertical grid line of the book by using a pixel pen as a middle reference line.
In the step B: in the invention, the initial coordinates of the position coordinate point U, D, L, M and R of the datum line are both (0, 0), then all the pixel positions of the pixel data which accord with the pixel value of the second color are sequentially extracted from left to right on the horizontal straight line passing through the midpoint of the standard reference image of the Tonhuang relic in the vertical direction by utilizing the color characteristics, and if the pixel positions of the two pixel data are extracted, the pixel positions are sequentially stored as L: (l)x,ly) And R: (r)x,ry) If the pixel positions of the three pixel data are extracted, sequentially storing the pixel positions as L: (l)x,ly)、M:(mx,my) And R: (r)x,ry);
On the vertical straight line passing through the midpoint of the Dunhuang relic reference image in the horizontal direction, sequentially extracting the pixel positions of all pixel data conforming to the pixel value of the first color from top to bottom, and if the pixel positions of two pixel data are extracted, saving the pixel positions as U: (u)x,uy) And D: (d)x,dy) If only one pixel position of the pixel data is extracted, judging whether the pixel position of the pixel data is positioned on the upper part of the Dunhuang relic reference image, if so, saving the pixel position as U: (u)x,uy) Otherwise, saving as D: (d)x,dy)。
In the step C: according to the position coordinate point L of the left reference line in the Dunhuang relic reference image obtained in the step B: (l)x,ly) And a position coordinate point M of the middle datum line: (m)x,my) And the position coordinate point R of the right reference line: (r)x,ry) If the position coordinate point M of the middle reference line is (0, 0), the width G of the grid cellw=rx-lxOtherwise Gw=mx-lx。
In the step F: enhancing the edge line skeleton in the edge line image according to the pixel threshold Q for the obtained edge line image corresponding to each Dunhuang relic film image, and setting the non-edge line skeleton as the background to obtain the edge line skeleton image corresponding to each Dunhuang relic film image; and E, the edge line skeleton refers to a centered pixel point in the edge line with the width of 3 pixels obtained in the step E.
In the step H: respectively extracting the pixel positions of each pixel data of the broken edge parts on the left side and the right side of the edge line skeleton in the edge line skeleton labeling image obtained in the step G according to the sequence from top to bottom and from left to right, and then sequentially combining the pixel positions of the pixel data obtained in sequence to respectively form two-dimensional time-series data T corresponding to the broken edge part on the left side of the edge line skeletonlTwo-dimensional time-series data T corresponding to right-side broken edge portionrWherein, Tl={(Vl1,Wl1),(Vl2,Wl2),(Vl3,Wl3),…,(Vli,Wli)},Tr={(Vr1,Wr1),(Vr2,Wr2),(Vr3,Wr3),…,(Vri,Wri) I is a positive integer, (V)li,Wli) (V) pixel position of ith pixel data indicating a broken edge portion on the left side of the edge line skeletonri,Wri) And a pixel position of the ith pixel data of the broken edge part at the right side of the edge line skeleton.
In the step I: when the position coordinate points L, M, R, U and D of the reference line are converted into the position coordinate points L ', M ', R ', U ', and D ' of the reference line restored to the true physical size, the position coordinate point L of the reference line is: (l)x,ly) Abscissa l of (5)xDo an operationlxL is obtained from'xOrdinate lyDo operation lyL is obtained from'yAnd finally obtaining the position coordinate point L' of the datum line restored to the real physical size: (l'x,l′y) (ii) a Similarly, obtaining position coordinate points M' of the other reference lines: (m'x,m′y)、R′:(r′x,r′y)、U′:(u′x,u′y) And D': (d'x,d′y);
After grid cell width GwConverted to grid cell width G 'restored to true physical dimensions'wThen, the grid cell width G is setwDo operation GwBeta to give G'w;
In the two-dimensional time-series data TlAnd TrConversion into two-dimensional time-sequenced data T'lAnd T'rTime, two-dimensional time-series data TlV inliDo operation VliV is obtained from'li,WliDo operation WliW is obtained from'liTwo-dimensional time-serialized data TrV inriDo operation VriV is obtained from'ri,WriDo operation WriW is obtained from'ri。
Step J: in the normalization process, T 'is calculated first'lMiddle V'liMin (V'li) And T'rMiddle V'riMin (V'ri) Then two-dimensional time-serialized data T'lV 'of each data of'liAnd L ' in the position coordinate point L ' of the reference line 'xAll subtract min (V'li) Two-dimensional time-serialized data T'rV 'of each data'riAnd R ' in the position coordinate point R ' of the reference line 'xAll subtract min (V'ri) Respectively obtaining normalized time-series edge curve data T ″)lAnd T ″)rAnd the position coordinate point L ″ of the reference line: (l ″)x,l″y) And R': (r ″)x,r″y) (ii) a Wherein, W ″)li=W′li,W″ri=W′ri,l″y=l′y,r″y=r′y。
Step K: when calculating the time sequence matching degree of two Dunhuang relic images, firstly judging whether the upper part and/or the lower part of the Dunhuang relic images a and b have book boundaries:
if there is a book border on the upper and/or lower part of the dunhuang left-reading image a, and there is a book border on the upper and/or lower part of the dunhuang left-reading image b, the Dunhuang left image a and the Dunhuang left image b are respectively put into the left side and the right side of the virtual raster image, so that the transverse grid lines of the book existing in the Dunhuang left image a and the Dunhuang left image b are respectively aligned with the corresponding transverse grid lines in the virtual raster image, the horizontal grid lines of the books on the middle upper part and the lower part of the Dunhuang relic image a are respectively aligned with the horizontal grid lines on the middle upper part and the lower part of the virtual raster image, the horizontal grid lines of the books on the middle upper part and the lower part of the Dunhuang relic image b are respectively aligned with the horizontal grid lines on the middle upper part and the lower part of the virtual raster image, and the reference lines on the left side and the right side of the Dunhuang relic image a and the left side and the right side of the Dunhuang relic image b are respectively aligned with the vertical grid; keeping Dunhuang relic image a and b fixed in the virtual raster image, respectively calculating the normalized time-series edge curve data T ″' corresponding to Dunhuang relic image a and braAnd T ″)lbPartial curves T ″, which coincide in the vertical directionrasAnd T ″)lbsThe time sequence matching degree s between the images, the maximum distance d between the right side broken edge part of the Dunhuang relic film image a and the right side reference line of the Dunhuang relic film image a after restoring to the real physical sizeaAnd the minimum distance d between the broken edge part at the left side of the Dunhuang relic image b and the left reference line after the Dunhuang relic image b is restored to the real physical sizebRestoring each Dunhuang relic film image obtained in combination with the step I to the grid unit width G 'after the real physical size'wIf mod ((d)a+db),G′w) If more than N, the matching degree s of the time sequence is calculated by s multiplied by N to obtain s', and thenPutting the time sequence matching degree S' into the set S, otherwise, directly putting the time sequence matching degree S into the set S; finally, taking the maximum value in the set S as the maximum stitching degree between the Dunhuang relic images a and b;
if the upper part and/or the lower part of the Dunhuang left-handed book remnant image a has a book border and the Dunhuang left-handed book remnant image b has no book border, respectively placing the Dunhuang left-handed book remnant image a and the Dunhuang left-handed book remnant image b on the left side and the right side in the virtual raster image, respectively aligning the transverse grid lines of the book on the upper part and/or the lower part of the Dunhuang left-handed book remnant image a with the corresponding transverse grid lines in the virtual raster image, and respectively aligning the left-side reference lines and the right-side reference lines in the Dunhuang left-handed book remnant image a and the right-side reference lines in the Dunhuang left; keeping the Dunhuang relic image a fixed in the virtual raster image, and successively carrying out upper alignment and lower alignment on the broken edge parts of the Dunhuang relic images a and b; after the upper alignment and the lower alignment, the Dunhuang relic book remnant image b slides upwards in the virtual raster image in the set sliding range along the vertical direction by taking M pixels as a stride, then returns to the initial position, and finally slides downwards in the set sliding range along the vertical direction; after the initial position and each sliding of the Dunhuang relic image b, the normalized time-sequence edge curve data T' corresponding to the two Dunhuang relic images a and b is calculatedraAnd T ″)lbPartial curves T ″, which coincide in the vertical directionrasAnd T ″)lbsThe time sequence matching degree s between the images, the maximum distance d between the right side broken edge part of the Dunhuang relic film image a and the right side reference line of the Dunhuang relic film image a after restoring to the real physical sizeaAnd the minimum distance d between the broken edge part at the left side of the Dunhuang relic image b and the left reference line after the Dunhuang relic image b is restored to the real physical sizebRestoring each Dunhuang relic film image obtained in combination with the step I to the grid unit width G 'after the real physical size'wIf mod ((d)a+db),G′w) If the time sequence matching degree S is more than N, calculating the time sequence matching degree S by S multiplied by N to obtain S ', then putting the time sequence matching degree S' into the set S, or directly putting the time sequence matching degree S into the set SIn the set S; finally, taking the maximum value in the set S as the maximum stitching degree between the Dunhuang relic images a and b;
if the Dunhuang left-hand book remnant image a has no book border, and the Dunhuang left-hand book remnant image b has a book border on the upper part and/or the lower part thereof, the Dunhuang left-hand book remnant image a and the Dunhuang left-hand book remnant image b are respectively placed on the left side and the right side of the virtual raster image, and the horizontal grid lines of the book on the upper part and/or the lower part of the Dunhuang left-hand book remnant image b are respectively aligned with the corresponding horizontal grid lines in the virtual raster image, and the left-side and right-side reference lines in the Dunhuang left-hand book remnant image a and the Dunhuang left-hand book remnant image b are; keeping the Dunhuang relic image b fixed in the virtual raster image, and successively carrying out upper alignment and lower alignment on the broken edge parts of the Dunhuang relic image a and the Dunhuang relic image b; after the upper alignment and the lower alignment, the Dunhuang relic book remnant image a slides upwards in the virtual raster image in the set sliding range along the vertical direction by taking M pixels as a stride, then returns to the initial position, and finally slides downwards in the set sliding range along the vertical direction; after the initial position and each sliding of the Dunhuang relic image a, the normalized time-series edge curve data T' corresponding to the two Dunhuang relic images a and b is calculatedraAnd T ″)lbPartial curves T ″, which coincide in the vertical directionrasAnd T ″)lbsThe time sequence matching degree s between the images, the maximum distance d between the right side broken edge part of the Dunhuang relic film image a and the right side reference line of the Dunhuang relic film image a after restoring to the real physical sizeaAnd the minimum distance d between the broken edge part at the left side of the Dunhuang relic image b and the left reference line after the Dunhuang relic image b is restored to the real physical sizebRestoring each Dunhuang relic film image obtained in combination with the step I to the grid unit width G 'after the real physical size'wIf mod ((d)a+db),G′w) If the time sequence matching degree S is more than N, calculating the time sequence matching degree S by S multiplied by N to obtain S ', and then putting the time sequence matching degree S' into the set S, otherwise, directly putting the time sequence matching degree S into the set S; finally, the maximum value in the set S is used as the value between the Dunhuang relic images a and bMaximum degree of conjugation;
if the Dunhuang left and right images a and b have no book borders, respectively placing the Dunhuang left and right images a and b into the left and right sides of the virtual raster image, and respectively aligning the left and right reference lines in the Dunhuang left and right images a and b with the vertical grid lines in the virtual raster image; the broken edge parts of the Dunhuang left book images a and b are aligned up and down in sequence; after the upper alignment and the lower alignment, keeping the Dunhuang left book image a fixed in the virtual raster image, firstly sliding the Dunhuang left book image b upwards in the virtual raster image in a set sliding range along the vertical direction by taking M pixels as a stride, then returning to the initial position, and finally sliding downwards in the set sliding range along the vertical direction; after the initial position and each sliding of the Dunhuang relic image b, the normalized time-sequence edge curve data T' corresponding to the two Dunhuang relic images a and b is calculatedraAnd T ″)lbPartial curves T ″, which coincide in the vertical directionrasAnd T ″)lbsThe time sequence matching degree s between the images, the maximum distance d between the right side broken edge part of the Dunhuang relic film image a and the right side reference line of the Dunhuang relic film image a after restoring to the real physical sizeaAnd the minimum distance d between the broken edge part at the left side of the Dunhuang relic image b and the left reference line after the Dunhuang relic image b is restored to the real physical sizebRestoring each Dunhuang relic film image obtained in combination with the step I to the grid unit width G 'after the real physical size'wIf mod ((d)a+db),G′w) If the time sequence matching degree S is more than N, calculating the time sequence matching degree S by S multiplied by N to obtain S ', and then putting the time sequence matching degree S' into the set S, otherwise, directly putting the time sequence matching degree S into the set S; finally, taking the maximum value in the set S as the maximum stitching degree between the Dunhuang relic images a and b;
the virtual raster image is a blank image designed manually, the horizontal length of the virtual raster image is not less than the sum of the horizontal lengths of two Dunhuang relic images a and b to be judged whether to be conjugated or not, the vertical height is not less than the greater of the vertical heights of the two dunghuang relic images a and b to be judged whether or not to be able to be conjugated, and the virtual grid image is internally and uniformly provided with grids, the width of each grid is equal to the width of a grid unit after the Dunhuang relic image is restored to the real physical size, the height of each grid is equal to the distance between the transverse grid lines of the upper part and the lower part of the book after the complete document image is restored to the real physical size, M is 1, mod () is a remainder function, N is a grid width threshold value, N is a penalty coefficient, and the sliding range is that after the broken edge parts of the Dunhuang relic image a and b are aligned up and down, the broken edge parts are aligned from the upper end P pixel to the lower end P pixel of the alignment point.
The step K comprises the following specific steps:
k0: judging whether the upper part and/or the lower part of the two Dunhuang relic images a and b to be judged whether to be conjugated have book boundaries, and entering a step K1 if the Dunhuang relic images a and b do not have book boundaries; if there is a book border only on the upper and/or lower part of the Dunhuang left book remnant image a, proceed to step K2; if there is a book border only on the upper and/or lower part of the dunhuang left-hand book remnant image b, the process proceeds to step K3, if there is a book border on the upper and/or lower part of the dunhuang left-hand book remnant image a, and the process proceeds to step K4;
k1: creating a virtual raster image, respectively placing the Dunhuang relic images a and b into the left side and the right side in the virtual raster image, respectively aligning the reference lines of the left side and the right side in the Dunhuang relic images a and b with the vertical grid lines in the virtual raster image, and aligning the upper end point of the broken edge part of the Dunhuang relic image b with the upper end point of the broken edge part of the Dunhuang relic image a; then entering step K5;
k2: creating a virtual raster image, respectively placing the Dunhuang relic images a and b on the left side and the right side in the virtual raster image, respectively aligning the transverse grid lines of the books on the upper part and/or the lower part of the Dunhuang relic image a with the corresponding transverse grid lines in the virtual raster image, respectively aligning the reference lines on the left side and the right side in the Dunhuang relic images a and b with the vertical grid lines in the virtual raster image, and aligning the upper end point of the broken edge part of the Dunhuang relic image b with the upper end point of the broken edge part of the Dunhuang relic image a; then entering step K5;
k3: creating a virtual raster image, respectively placing the Dunhuang relic images a and b on the left side and the right side in the virtual raster image, respectively aligning the transverse grid lines of the books on the upper part and/or the lower part of the Dunhuang relic image b with the corresponding transverse grid lines in the virtual raster image, respectively aligning the reference lines on the left side and the right side in the Dunhuang relic images a and b with the vertical grid lines in the virtual raster image, and aligning the upper end point of the broken edge part of the Dunhuang relic image a with the upper end point of the broken edge part of the Dunhuang relic image b; then entering step K5;
k4: creating a virtual raster image, respectively placing the Dunhuang relic images a and b into the left side and the right side in the virtual raster image, respectively aligning the transverse grid lines of the books existing in the Dunhuang relic images a and b with the corresponding transverse grid lines in the virtual raster image, and respectively aligning the reference lines of the left side and the right side in the Dunhuang relic images a and b with the vertical grid lines in the virtual raster image; then entering step K5;
k5: under the current position of Dunhuang relic image b in virtual raster image, calculating the normalized time-sequence marginal curve data T' corresponding to Dunhuang relic image a and braAnd T ″)lbPartial curves T ″, which coincide in the vertical directionrasAnd T ″)lbsThe time series matching degree s between the two, and then the step K6 is carried out;
k6: the normalized time-series edge curve data T ″raAnd T ″)lbThe respective head and tail end points are directly connected to form the line length LaAnd Lb,max(La,Lb) The greater of the two; then T ″', andlbsthe head and tail end points of the line are directly connected, so that the length of the formed line is Lc(ii) a If L iscIf the length is larger than or equal to the length threshold, the step K7 is carried out; otherwise, go to step K8;
k7: first, a sub-curve T ″, is calculatedrasAnd T ″)lbsTime series matching degree s between: calculating a sub-curve T ″rasAnd T ″)lbsForming a difference array d by the obtained data differences in sequence according to the data differences of the abscissa of each corresponding position, and recording the number of elements with the median of the difference array d being less than or equal to the difference threshold as tc(ii) a Combining the length L of the line segment obtained in the step K6cAnd calculating to obtain the matching degree s of the time series as tc/Lc;
Then calculating the maximum distance d between the right side broken edge part of the Dunhuang relic film image a and the right side reference line of the Dunhuang relic film image a after restoring to the real physical sizeaAnd the minimum distance d between the broken edge part at the left side of the Dunhuang relic image b and the left reference line after the Dunhuang relic image b is restored to the real physical sizeb;
Finally, restoring each Dunhuang relic film image obtained in combination with the step I to the grid unit width G 'after the real physical size'wIf mod ((d)a+db),G′w) If the time sequence matching degree S is more than N, calculating the time sequence matching degree S by S multiplied by N to obtain S ', and then putting the time sequence matching degree S' into the set S, otherwise, directly putting the time sequence matching degree S into the set S; then entering step K9;
k8: sub-curve T ″)rasAnd T ″)lbsSetting the time sequence matching degree S between the sets as 0, and putting the value of S into a set S; then entering step K9;
k9, if there is book boundary on the upper and/or lower part of Dunhuang left-reading image a and there is book boundary on the upper and/or lower part of Dunhuang left-reading image b, then entering step L; if there is a book border only on the upper and/or lower part of the Dunhuang left book remnant image b, proceed to step K13; if the Dunhuang left book remnant image b has no book boundary, then go to step K10;
k10: sliding the Dunhuang left-reading image b upwards and downwards in the virtual raster image by taking 1 pixel as a stride and taking the upper end point of the broken edge part of the Dunhuang left-reading image a as a reference point respectively, wherein the sliding range does not exceed the upper end point and the lower end point of the broken edge part of the Dunhuang left-reading image a by P pixels; repeating the steps K5 to K8 after each movement until the Dunhuang relic image b slides to the boundary of the sliding range in the virtual raster image, namely the upper end point of the broken edge part of the image b is respectively superposed with two pixel points at the upper end and the lower end of the sliding range; then entering step K11;
k11: maintaining the Dunhuang left and right images a and b on the left and right sides of the virtual raster image, respectively, aligning the reference line positions of the left and right sides of the Dunhuang left and right images a and b with the vertical grid lines of the virtual raster image, aligning the lower end point of the broken edge part of the Dunhuang left and right images a with the lower end point of the broken edge part of the Dunhuang left and right images b, and sequentially performing the steps K5 to K8; after the step K8 is finished, directly entering the step K12;
k12: taking 1 pixel as a stride, sliding the Dunhuang left-reading image b upwards and downwards in the virtual raster image by taking the lower end point of the broken edge part of the Dunhuang left-reading image a as a reference point respectively, and the sliding range does not exceed the upper and lower P pixels of the lower end point of the broken edge part of the Chinese character image a; repeating the steps K5 to K8 after each movement until the Dunhuang relic image b slides to the boundary of the sliding range in the virtual raster image, namely the lower end point of the broken edge part of the image b is respectively superposed with two pixel points at the upper end and the lower end of the sliding range; then entering a step L;
k13: taking 1 pixel as a stride, sliding the Dunhuang left-reading image a upwards and downwards respectively in the virtual raster image by taking the upper endpoint of the broken edge part of the Dunhuang left-reading image b as a reference point, wherein the sliding range does not exceed the upper endpoint of the broken edge part of the Chinese character image b and P pixels are arranged above and below the upper endpoint of the broken edge part of the Chinese character image b, repeating the steps K5 to K8 after each movement until the Dunhuang left-reading image a slides to the boundary of the sliding range in the virtual raster image, namely the upper endpoint of the broken edge part of the image a is respectively superposed with two pixel points at the upper end and the lower end of the sliding range; then entering step K14;
k14: maintaining the Dunhuang left and right images a and b on the left and right sides of the virtual raster image, aligning the reference line positions of the left and right sides of the Dunhuang left and right images a and b with the vertical grid lines in the virtual raster image, aligning the book borders on the upper and lower parts of the Dunhuang left and right images b with the horizontal grid lines on the upper and lower parts of the virtual raster image, aligning the lower end point of the broken edge part of the Dunhuang left and right images a with the lower end point of the broken edge part of the Dunhuang left and right images b, and sequentially executing the steps K5 to K8; after the step K8 is finished, directly entering the step K15;
k15, sliding the Dunhuang left-reading image a upwards and downwards in the virtual raster image with the lower end point of the broken edge part of the Dunhuang left-reading image b as the reference point, and the sliding range does not exceed the upper end point of the broken edge part of the Chinese character image b and the upper and lower P pixels respectively; repeating the steps K5 to K8 after each movement until the Dunhuang relic image a slides to the boundary of the sliding range in the virtual raster image, namely the upper end point of the broken edge part of the image a is respectively superposed with two pixel points at the upper end and the lower end of the sliding range; then step L is entered.
The invention can give consideration to the tightness of the broken edge slag notch and the accuracy of the width of the grid unit formed after the broken edge conjugation, greatly improves the efficiency and the accuracy of the conjugation of the Dunhuang relic images, and effectively utilizes the information of the transverse grid lines and the vertical grid lines of the books in the Dunhuang relic images by putting the two Dunhuang relic images a and b to be judged whether the images can be conjugated into the provided virtual grid images, thereby reducing the error.
Detailed Description
The invention is described in detail below with reference to the following figures and examples:
as shown in fig. 1, the automatic conjugation method of the images of the relic of the dunhuang book of the invention comprises the following steps:
a: manually determining reference lines at the upper side, the lower side, the left side and the right side of the Dunhuang relic image and a middle reference line adjacent to the reference line at the left side to obtain a Dunhuang relic reference image;
firstly, regarding Dunhuang relic images with book boundaries on the upper parts, a horizontal line of a first color with the width of 1 pixel is drawn at a book horizontal grid line on the upper side of the Dunhuang relic images by using a pixel pen as an upper reference line; for Dunhuang copy remains image with book boundary at the lower part, drawing a transverse line of a first color with the width of 1 pixel at the transverse grid line of the book at the lower side of the Dunhuang copy remains image by using a pixel pen as a lower side reference line;
then, drawing a vertical line of a second color with the width of 1 pixel as a left reference line by using a pixel pen at the position of a book vertical grid line which is closest to the left side broken edge and is not interrupted of the Dunhuang relic image, and drawing a vertical line of a second color with the width of 1 pixel as a right reference line by using a pixel pen at the position of a book vertical grid line which is closest to the right side broken edge and is not interrupted of the Dunhuang relic image;
and finally, judging whether a vertical grid line of the book, except the right reference line, is adjacent to the right side of the left reference line in the Dunhuang relic image, if so, drawing a vertical line of a second color with the width of 1 pixel at the vertical grid line of the book by using a pixel pen as a middle reference line.
In the invention, the first color adopts green, and the second color adopts red;
b: the positions of a position coordinate point U of an upper datum line, a position coordinate point D of a lower datum line, a position coordinate point L of a left datum line, a position coordinate point R of a right datum line and a position coordinate point M of a middle datum line in the Dunhuang relic reference image obtained in the step A are positioned by a computer;
in the invention, the initial coordinates of the points U, D, L, M and R are both (0, 0), then all the pixel positions of the pixel data which accord with the second color pixel value are sequentially extracted from left to right on the horizontal straight line passing through the midpoint of the Dunhuang relic reference image in the vertical direction by utilizing the color characteristics, and if the pixel positions of the two pixel data are extracted, the pixel positions are sequentially stored as L: (l)x,ly) And R: (r)x,ry) If the pixel positions of the three pixel data are extracted, sequentially storing the pixel positions as L: (l)x,ly)、M:(mx,my) And R: (r)x,ry). In the present invention, the pixel value of the second color is (255, 0, 0).
On the vertical straight line passing through the midpoint of the Dunhuang relic reference image in the horizontal direction, sequentially extracting the pixel positions of all pixel data conforming to the pixel value of the first color from top to bottom, and if the pixel positions of two pixel data are extracted, saving the pixel positions as U: (u)x,uy) And D: (d)x,dy) If only one pixel position of the pixel data is extracted, judging whether the pixel position of the pixel data is positioned on the upper part of the Dunhuang relic reference image, if so, saving the pixel position as U: (u)x,uy) Otherwise, saving as D: (d)x,dy). In the present invention, the pixel value of the first color is (0, 255, 0).
To this end, the position of the upper datum line is a horizontal straight line passing through point U, the position of the lower datum line is a horizontal straight line passing through point D, the position of the left datum line is a vertical straight line passing through point L, the position of the right datum line is a vertical straight line passing through point R, and the position of the middle datum line is a vertical straight line passing through point M.
C: utilizing a computer to calculate the width of the grid unit in the standard reference image of the Dunhuang relic;
according to the position coordinate point L of the left reference line in the Dunhuang relic reference image obtained in the step B: (l)x,ly) And a position coordinate point M of the middle datum line: (m)x,my) And the position coordinate point R of the right reference line: (r)x,ry) If the position coordinate point M of the middle reference line is (0, 0), the width G of the grid cellw=rx-lxOtherwise Gw=mx-lx;
D: assuming that the grid cells in all the Dunhuang relic images are all of equal width, selecting a Dunhuang relic image with known real physical size and obtaining the real physical width of the grid cell, and obtaining the wide grid cell of the Dunhuang relic reference image corresponding to the Dunhuang relic image according to the steps A to CCalculating the degree of the zoom ratio gamma of restoring the width value of the grid unit of the standard reference image of the Dunhuang relic film corresponding to the Dunhuang relic film image to the real physical size; wherein γ is β2Beta is the multiple relation between the width value of the grid unit of the Dunhuang relic film image and the real physical width value of the grid unit of the Dunhuang relic film;
e: carrying out edge detection on the Dunhuang relic image to extract edge lines of the Dunhuang relic image so as to obtain edge line images corresponding to each Dunhuang relic image;
in the invention, the Canny operator edge detection algorithm is used for automatically extracting the edge line of each Dunhuang relic fragment image, and is a conventional technology in the field and is not described herein any more.
After the first round of edge line extraction is finished, manually checking whether the edge line of each extracted Dunhuang relic image conforms to the real condition, selecting the Dunhuang relic image corresponding to the non-conforming edge line as the Dunhuang relic image to be rechecked, then adjusting the parameter of the Canny operator edge detection algorithm, carrying out edge extraction again on the Dunhuang relic image to be rechecked, and manually checking whether the extracted edge line conforms to the real condition; manually describing the edge lines of Dunhuang relic film images of which the edge lines cannot be accurately extracted through a Canny operator edge detection algorithm and storing the edge lines; finally obtaining the edge line of the Dunhuang relic image which is consistent with the real situation;
and finally, independently storing the edge line corresponding to each Dunhuang relic book remnant image as an edge line image with a transparent background, 3 pixels of edge line width, red color and RGBA four channels of image format.
F: and acquiring an edge line framework in the edge line image corresponding to each Dunhuang copy book residue image by using a computer to obtain the edge line framework image corresponding to each Dunhuang copy book residue image, wherein the edge line framework refers to a central pixel point in the edge line.
In the invention, the edge line skeleton in the edge line image is enhanced according to the pixel threshold Q for the obtained edge line image corresponding to each Dunhuang relic film image, and the non-edge line skeleton is used as the background to obtain the edge line skeleton image corresponding to each Dunhuang relic film image. The edge line skeleton refers to a centered pixel point in the edge line with the width of 3 pixels obtained in the step E;
in this embodiment, the pixel threshold Q is 174, and by using the color characteristics, the pixel point whose pixel value is less than or equal to (174, 0, 0, 255) is automatically set to (0, 0, 0, 0), otherwise to (255, 0, 0, 255), and finally the edge line skeleton image corresponding to each of the images of the Dunhuang relics is obtained; the four values in parentheses are R, G, B and the values of the A four channels, respectively;
g: and manually determining the left side and the right side broken edge parts in the edge line skeleton image of each Dunhuang relic image to obtain an edge line skeleton labeling image corresponding to each Dunhuang relic image.
And manually observing the edge line skeleton image of each Dunhuang relic book image, respectively determining the starting point and the end point of the left side and the right side broken edge part of the edge line skeleton in the edge line skeleton image, respectively drawing a blue color block with the side length of 1 pixel by using a pixel pen, and storing the blue color block, and finally obtaining the edge line skeleton labeling image which is labeled with the starting point and the end point of the broken edge part and corresponds to each Dunhuang relic book image.
H: and G, respectively carrying out time serialization processing on the left side and the right side broken edge parts of the edge line skeleton in the edge line skeleton labeling image obtained in the step G to obtain corresponding two-dimensional numerical value type time serialization data.
Respectively extracting the pixel positions of each pixel data of the broken edge parts on the left side and the right side of the edge line skeleton in the edge line skeleton labeling image obtained in the step G according to the sequence from top to bottom and from left to right, and then sequentially combining the pixel positions of the pixel data obtained in sequence to respectively form two-dimensional time-series data T corresponding to the broken edge part on the left side of the edge line skeletonlTwo-dimensional time-series data T corresponding to right-side broken edge portionrWherein, Tl={(Vl1,Wl1),(Vl2,Wl2),(Vl3,Wl3),…,(Vli,Wli)},Tr={(Vr1,Wr1),(Vr2,Wr2),(Vr3,Wr3),…,(Vri,Wri) I is a positive integer, (V)li,Wli) (V) pixel position of ith pixel data indicating a broken edge portion on the left side of the edge line skeletonri,Wri) And a pixel position of the ith pixel data of the broken edge part at the right side of the edge line skeleton.
I: and D, utilizing the scaling gamma and the multiple relation beta obtained in the step D to convert the position coordinate point L of the datum line obtained in the step B into a coordinate point L: (l)x,ly)、M:(mx,my)、R:(rx,ry)、U:(ux,uy) And D: (d)x,dy) And converting into a position coordinate point L' of the reference line restored to the true physical size: (l'x,l′y)、M′:(m′x,m′y)、R′:(r′x,r′y)、U′:(u′x,u′y) And D': (d'x,d′y) (ii) a Then the width G of the grid unit obtained in the step CwConverted into the width G 'of the mesh unit restored to the real physical size'w(ii) a And D, two-dimensional time-series data T corresponding to the broken edge parts on the left side and the right side of the edge line skeleton obtained in the step H are subjected tolAnd TrRespectively converting the two-dimensional time-series data into two-dimensional time-series data T 'corresponding to broken edge parts on the left side and the right side of the edge line skeleton after the actual physical dimensions are restored'lAnd T'r;T′l={(V′l1,W′l1),(V′l2,W′l2),(V′l3,W′l3),…,(V′li,W′li)},T′r={(V′r1,W′r1),(V′r2,W′r2),(V′r3,W′r3),…,(V′ri,W′ri) I is a positive integer, (V'li,W′li) And (V'ri,W′ri) Respectively representing the pixel positions of ith pixel data of the left and right broken edge parts restored to the real physical size;
then checking the obtained reference line position restored to the real physical size with the reference line position in the corresponding Dunhuang relic image with the known real physical size, checking the obtained grid unit width restored to the real physical size with the grid unit width in the corresponding Dunhuang relic image with the known real physical size, and checking the obtained pixel position of the pixel data of the broken edge part restored to the real physical size with the corresponding broken edge part in the Dunhuang relic image with the known real physical size.
When the position coordinate points L, M, R, U and D of the reference line are converted into the position coordinate points L ', M ', R ', U ', and D ' of the reference line restored to the true physical size, the position coordinate point L of the reference line is: (l)x,ly) Abscissa l of (5)xDo operation lxL is obtained from'xOrdinate lyDo operation lyL is obtained from'yAnd finally obtaining the position coordinate point L' of the datum line restored to the real physical size: (l'x,l′y) (ii) a Similarly, obtaining position coordinate points M' of the other reference lines: (m'x,m′y)、R′:(r′x,r′y)、U′:(u′x,u′y) And D': (d'x,d′y)。
To this end, in the position of the reference line restored to the true physical size, the position of the upper reference line is a horizontal straight line passing through the point U ', the position of the lower reference line is a horizontal straight line passing through the point D ', the position of the left reference line is a vertical straight line passing through the point L ', the position of the right reference line is a vertical straight line passing through the point R ', and the position of the middle reference line is a vertical straight line passing through the point M '.
After grid cell width GwConverted to grid cell width G 'restored to true physical dimensions'wThen, the grid cell width G is setwDo operation GwBeta to give G'w;
In the two-dimensional time-series data TlAnd TrConversion into two-dimensional time-sequenced data T'lAnd T'rTime, two-dimensional time-series data TlV inliDo operation VliV is obtained from'li,WliDo operation WliW is obtained from'liTwo-dimensional time-serialized data TrV inriDo operation VriV is obtained from'ri,WriDo operation WriW is obtained from'ri。
J: two-dimensional time-series data T 'obtained in step I'lV 'of'liAnd T'rV 'of'riAnd a position coordinate point L' of the reference line: (l'x,l′y) And R': (r'x,r′y) Respectively carrying out normalization processing to correspondingly obtain normalized time-series edge curve data TlAnd T ″)rAnd normalized reference line relative position coordinates L ″: (l ″)x,l″y) And R': (r'x,r″y),T″l={(V″l1,W″l1),(V″l2,W′l2),(V″l3,W″l3),…,(V″li,W″li)},T″r={(V″r1,W″r1),(V″r2,W″r2),(V″r3,W″r3),…,(V″ri,W″ri)}。
In the present invention, T 'is first calculated in the normalization process'lMiddle V'liMin (V'li) And T'rMiddle V'riMin (V'ri) Then two-dimensional time-serialized data T'lV 'of each data of'liAnd L ' in the position coordinate point L ' of the reference line 'xAll subtract min (V'li) Two-dimensional time-serialized data T'rV 'of each data'riAnd R ' in the position coordinate point R ' of the reference line 'xAll subtract min (V'ri) Respectively obtaining normalized time-series edge curve data T ″)lAnd T ″)rAnd the position coordinate point L ″ of the reference line: (l ″)x,l″y) And R': (r ″)x,r″y) (ii) a Wherein, W ″)li=W′li,W″ri=W′ri,l″y=l′y,r″y=r′y。
K: respectively obtaining the time-sequenced edge curve data T' of the broken edge parts of the edge line skeletons of the two Dunhuang relic film images to be conjugated according to the step J after normalization treatmentlAnd T ″)rThen calculating the time sequence matching degree S of the two Dunhuang relic film images, and putting the time sequence matching degree S into a set S;
when calculating the time sequence matching degree of two Dunhuang relic images, firstly judging whether the upper part and/or the lower part of the Dunhuang relic images a and b have book boundaries:
if there is a book border on the upper and/or lower part of the dunhuang left-reading image a, and there is a book border on the upper and/or lower part of the dunhuang left-reading image b, the Dunhuang left image a and the Dunhuang left image b are respectively put into the left side and the right side of the virtual raster image, so that the transverse grid lines of the book existing in the Dunhuang left image a and the Dunhuang left image b are respectively aligned with the corresponding transverse grid lines in the virtual raster image, the horizontal grid lines of the books on the middle upper part and the lower part of the Dunhuang relic image a are respectively aligned with the horizontal grid lines on the middle upper part and the lower part of the virtual raster image, the horizontal grid lines of the books on the middle upper part and the lower part of the Dunhuang relic image b are respectively aligned with the horizontal grid lines on the middle upper part and the lower part of the virtual raster image, and the reference lines on the left side and the right side of the Dunhuang relic image a and the left side and the right side of the Dunhuang relic image b are respectively aligned with the vertical grid; keeping Dunhuang relic images a and b fixed in the virtual raster image, respectively calculating the normalized time-sequenced edges corresponding to the Dunhuang relic images a and bData T ″' of edge curveraAnd T ″)lbPartial curves T ″, which coincide in the vertical directionrasAnd T ″)lbsThe time sequence matching degree s between the images, the maximum distance d between the right side broken edge part of the Dunhuang relic film image a and the right side reference line of the Dunhuang relic film image a after restoring to the real physical sizeaAnd the minimum distance d between the broken edge part at the left side of the Dunhuang relic image b and the left reference line after the Dunhuang relic image b is restored to the real physical sizebRestoring each Dunhuang relic film image obtained in combination with the step I to the grid unit width G 'after the real physical size'wIf mod ((d)a+db),G′w) If the time sequence matching degree S is more than N, calculating the time sequence matching degree S by S multiplied by N to obtain S ', and then putting the time sequence matching degree S' into the set S, otherwise, directly putting the time sequence matching degree S into the set S; finally, the maximum value in the set S is taken as the maximum degree of engagement between the dunghuang relic images a and b.
If the upper part and/or the lower part of the Dunhuang left-handed book remnant image a has a book border and the Dunhuang left-handed book remnant image b has no book border, respectively placing the Dunhuang left-handed book remnant image a and the Dunhuang left-handed book remnant image b on the left side and the right side in the virtual raster image, respectively aligning the transverse grid lines of the book on the upper part and/or the lower part of the Dunhuang left-handed book remnant image a with the corresponding transverse grid lines in the virtual raster image, and respectively aligning the left-side reference lines and the right-side reference lines in the Dunhuang left-handed book remnant image a and the right-side reference lines in the Dunhuang left; keeping the Dunhuang relic image a fixed in the virtual raster image, and successively carrying out upper alignment and lower alignment on the broken edge parts of the Dunhuang relic images a and b; after the upper alignment and the lower alignment, the Dunhuang relic book remnant image b slides upwards in the virtual raster image in the set sliding range along the vertical direction by taking M pixels as a stride, then returns to the initial position, and finally slides downwards in the set sliding range along the vertical direction; after the initial position and each sliding of the Dunhuang relic image b, the normalized time-sequence edge curve data T' corresponding to the two Dunhuang relic images a and b is calculatedraAnd T ″)lbThe elements overlapping in the vertical directionCurve T ″)rasAnd T ″)lbsThe time sequence matching degree s between the images, the maximum distance d between the right side broken edge part of the Dunhuang relic film image a and the right side reference line of the Dunhuang relic film image a after restoring to the real physical sizeaAnd the minimum distance d between the broken edge part at the left side of the Dunhuang relic image b and the left reference line after the Dunhuang relic image b is restored to the real physical sizebRestoring each Dunhuang relic film image obtained in combination with the step I to the grid unit width G 'after the real physical size'wIf mod ((d)a+db),G′w) If the time sequence matching degree S is more than N, calculating the time sequence matching degree S by S multiplied by N to obtain S ', and then putting the time sequence matching degree S' into the set S, otherwise, directly putting the time sequence matching degree S into the set S; finally, the maximum value in the set S is taken as the maximum degree of engagement between the dunghuang relic images a and b.
If the Dunhuang left-hand book remnant image a has no book border, and the Dunhuang left-hand book remnant image b has a book border on the upper part and/or the lower part thereof, the Dunhuang left-hand book remnant image a and the Dunhuang left-hand book remnant image b are respectively placed on the left side and the right side of the virtual raster image, and the horizontal grid lines of the book on the upper part and/or the lower part of the Dunhuang left-hand book remnant image b are respectively aligned with the corresponding horizontal grid lines in the virtual raster image, and the left-side and right-side reference lines in the Dunhuang left-hand book remnant image a and the Dunhuang left-hand book remnant image b are; keeping the Dunhuang relic image b fixed in the virtual raster image, and successively carrying out upper alignment and lower alignment on the broken edge parts of the Dunhuang relic image a and the Dunhuang relic image b; after the upper alignment and the lower alignment, the Dunhuang relic book remnant image a slides upwards in the virtual raster image in the set sliding range along the vertical direction by taking M pixels as a stride, then returns to the initial position, and finally slides downwards in the set sliding range along the vertical direction; after the initial position and each sliding of the Dunhuang relic image a, the normalized time-series edge curve data T' corresponding to the two Dunhuang relic images a and b is calculatedraAnd T ″)lbPartial curves T ″, which coincide in the vertical directionrasAnd T ″)lbsTime sequence matching degree between s and DunhuangThe maximum distance d between the right side broken edge part of the book remnant image a and the right side reference line of the Dunhuang relic book remnant image a after the image a is restored to the real physical sizeaAnd the minimum distance d between the broken edge part at the left side of the Dunhuang relic image b and the left reference line after the Dunhuang relic image b is restored to the real physical sizebRestoring each Dunhuang relic film image obtained in combination with the step I to the grid unit width G 'after the real physical size'wIf mod ((d)a+db),G′w) If the time sequence matching degree S is more than N, calculating the time sequence matching degree S by S multiplied by N to obtain S ', and then putting the time sequence matching degree S' into the set S, otherwise, directly putting the time sequence matching degree S into the set S; finally, the maximum value in the set S is taken as the maximum degree of engagement between the dunghuang relic images a and b.
If the Dunhuang left and right images a and b have no book borders, respectively placing the Dunhuang left and right images a and b into the left and right sides of the virtual raster image, and respectively aligning the left and right reference lines in the Dunhuang left and right images a and b with the vertical grid lines in the virtual raster image; the broken edge parts of the Dunhuang left book images a and b are aligned up and down in sequence; after the upper alignment and the lower alignment, keeping the Dunhuang left book image a fixed in the virtual raster image, firstly sliding the Dunhuang left book image b upwards in the virtual raster image in a set sliding range along the vertical direction by taking M pixels as a stride, then returning to the initial position, and finally sliding downwards in the set sliding range along the vertical direction; after the initial position and each sliding of the Dunhuang relic image b, the normalized time-sequence edge curve data T' corresponding to the two Dunhuang relic images a and b is calculatedraAnd T ″)lbPartial curves T ″, which coincide in the vertical directionrasAnd T ″)lbsThe time sequence matching degree s between the images, the maximum distance d between the right side broken edge part of the Dunhuang relic film image a and the right side reference line of the Dunhuang relic film image a after restoring to the real physical sizeaAnd the minimum distance d between the broken edge part at the left side of the Dunhuang relic image b and the left reference line after the Dunhuang relic image b is restored to the real physical sizebRestoring each Dunhuang relic film image obtained in combination with the step I to the grid unit width G 'after the real physical size'wIf mod ((d)a+db),G′w) If the time sequence matching degree S is more than N, calculating the time sequence matching degree S by S multiplied by N to obtain S ', and then putting the time sequence matching degree S' into the set S, otherwise, directly putting the time sequence matching degree S into the set S; finally, the maximum value in the set S is taken as the maximum degree of engagement between the dunghuang relic images a and b.
In said step K, the virtual raster image is a blank image designed manually, the horizontal length of the virtual raster image is not less than the sum of the horizontal lengths of the two Dunhuang relic images a and b to be judged whether to be conjugated, the vertical height is not less than the larger value of the vertical heights of the two Dunhuang relic images a and b to be judged whether to be conjugated, and the virtual raster image is internally and uniformly provided with grids, the width of the grids is equal to the unit width of the grids after the Dunhuang relic images are restored to the real physical size, the height of the grids is equal to the distance between the transverse grid lines of the upper and lower books after the complete relic images are restored to the real physical size, M is 1, mod () is a remainder function, N is a grid width threshold, N is a penalty coefficient, the sliding range is after the broken edge parts of the Dunhuang relic images a and b are aligned up and down, from the upper P pixels to the lower P pixels of the alignment point.
The step K comprises the following specific steps:
k0: judging whether the upper part and/or the lower part of the two Dunhuang relic images a and b to be judged whether to be conjugated have book boundaries, and entering a step K1 if the Dunhuang relic images a and b do not have book boundaries; if there is a book border only on the upper and/or lower part of the Dunhuang left book remnant image a, proceed to step K2; if there is a book border only on the upper and/or lower part of the dunhuang left-hand book remnant image b, the process proceeds to step K3, if there is a book border on the upper and/or lower part of the dunhuang left-hand book remnant image a, and the process proceeds to step K4;
k1: creating a virtual raster image, respectively placing the Dunhuang relic images a and b into the left side and the right side in the virtual raster image, respectively aligning the reference lines of the left side and the right side in the Dunhuang relic images a and b with the vertical grid lines in the virtual raster image, and aligning the upper end point of the broken edge part of the Dunhuang relic image b with the upper end point of the broken edge part of the Dunhuang relic image a; then entering step K5;
k2: creating a virtual raster image, respectively placing the Dunhuang relic images a and b on the left side and the right side in the virtual raster image, respectively aligning the transverse grid lines of the books on the upper part and/or the lower part of the Dunhuang relic image a with the corresponding transverse grid lines in the virtual raster image, respectively aligning the reference lines on the left side and the right side in the Dunhuang relic images a and b with the vertical grid lines in the virtual raster image, and aligning the upper end point of the broken edge part of the Dunhuang relic image b with the upper end point of the broken edge part of the Dunhuang relic image a; then entering step K5;
k3: creating a virtual raster image, respectively placing the Dunhuang relic images a and b on the left side and the right side in the virtual raster image, respectively aligning the transverse grid lines of the books on the upper part and/or the lower part of the Dunhuang relic image b with the corresponding transverse grid lines in the virtual raster image, respectively aligning the reference lines on the left side and the right side in the Dunhuang relic images a and b with the vertical grid lines in the virtual raster image, and aligning the upper end point of the broken edge part of the Dunhuang relic image a with the upper end point of the broken edge part of the Dunhuang relic image b; then entering step K5;
k4: creating a virtual raster image, respectively placing the Dunhuang relic images a and b into the left side and the right side in the virtual raster image, respectively aligning the transverse grid lines of the books existing in the Dunhuang relic images a and b with the corresponding transverse grid lines in the virtual raster image, and respectively aligning the reference lines of the left side and the right side in the Dunhuang relic images a and b with the vertical grid lines in the virtual raster image; then entering step K5;
k5: under the current position of Dunhuang relic image b in virtual raster image, calculating the normalized time-sequence marginal curve data T' corresponding to Dunhuang relic image a and braAnd T ″)lbPartial curves T ″, which coincide in the vertical directionrasAnd T ″)lbsThe time series matching degree s between the two, and then the step K6 is carried out;
k6: the normalized time-series edge curve data T ″raAnd T ″)lbThe respective head and tail end points are directly connected to form the line length LaAnd Lb,max(La,Lb) The greater of the two; then T ″', andlbsthe head and tail end points of the line are directly connected, so that the length of the formed line is Lc(ii) a If L iscIf the length is larger than or equal to the length threshold, the step K7 is carried out; otherwise, go to step K8;
in this embodiment, the length threshold is max (L)a,Lb) 77% of the value;
k7: first, a sub-curve T ″, is calculatedrasAnd T ″)lbsTime series matching degree s between: calculating a sub-curve T ″rasAnd T ″)lbsForming a difference array d by the obtained data differences in sequence according to the data differences of the abscissa of each corresponding position, and recording the number of elements with the median of the difference array d being less than or equal to the difference threshold as tc(ii) a Combining the length L of the line segment obtained in the step K6cAnd calculating to obtain the matching degree s of the time series as tc/Lc;
Then calculating the maximum distance d between the right side broken edge part of the Dunhuang relic film image a and the right side reference line of the Dunhuang relic film image a after restoring to the real physical sizeaAnd the minimum distance d between the broken edge part at the left side of the Dunhuang relic image b and the left reference line after the Dunhuang relic image b is restored to the real physical sizeb;
Finally, restoring each Dunhuang relic film image obtained in combination with the step I to the grid unit width G 'after the real physical size'wIf mod ((d)a+db),G′w) If the time sequence matching degree S is more than N, calculating the time sequence matching degree S by S multiplied by N to obtain S ', and then putting the time sequence matching degree S' into the set S, otherwise, directly putting the time sequence matching degree S into the set S; then entering step K9;
in this embodiment, the difference threshold is 2.2;
k8: sub-curve T ″)rasAnd T ″)lbsSetting the time sequence matching degree S between the sets as 0, and putting the value of S into a set S; then entering step K9;
k9: if there is book boundary on the upper and/or lower part of Dunhuang left-hand book image a and there is book boundary on the upper and/or lower part of Dunhuang left-hand book image b, then go to step L; if there is a book border only on the upper and/or lower part of the Dunhuang left book remnant image b, proceed to step K13; if the Dunhuang left book remnant image b has no book boundary, then go to step K10;
k10: sliding the Dunhuang left-reading image b upwards and downwards in the virtual raster image by taking 1 pixel as a stride and taking the upper end point of the broken edge part of the Dunhuang left-reading image a as a reference point respectively, wherein the sliding range does not exceed the upper end point and the lower end point of the broken edge part of the Dunhuang left-reading image a by P pixels; repeating the steps K5 to K8 after each movement until the Dunhuang relic image b slides to the boundary of the sliding range in the virtual raster image, namely the upper end point of the broken edge part of the image b is respectively superposed with two pixel points at the upper end and the lower end of the sliding range; then entering step K11;
k11: maintaining the Dunhuang left and right images a and b on the left and right sides of the virtual raster image, respectively, aligning the reference line positions of the left and right sides of the Dunhuang left and right images a and b with the vertical grid lines of the virtual raster image, aligning the lower end point of the broken edge part of the Dunhuang left and right images a with the lower end point of the broken edge part of the Dunhuang left and right images b, and sequentially performing the steps K5 to K8; after the step K8 is finished, directly entering the step K12;
k12: taking 1 pixel as a stride, sliding the Dunhuang left-reading image b upwards and downwards in the virtual raster image by taking the lower end point of the broken edge part of the Dunhuang left-reading image a as a reference point respectively, and the sliding range does not exceed the upper and lower P pixels of the lower end point of the broken edge part of the Chinese character image a; repeating the steps K5 to K8 after each movement until the Dunhuang relic image b slides to the boundary of the sliding range in the virtual raster image, namely the lower end point of the broken edge part of the image b is respectively superposed with two pixel points at the upper end and the lower end of the sliding range; then entering a step L;
k13: taking 1 pixel as a stride, sliding the Dunhuang left-reading image a upwards and downwards respectively in the virtual raster image by taking the upper endpoint of the broken edge part of the Dunhuang left-reading image b as a reference point, wherein the sliding range does not exceed the upper endpoint of the broken edge part of the Chinese character image b and P pixels are arranged above and below the upper endpoint of the broken edge part of the Chinese character image b, repeating the steps K5 to K8 after each movement until the Dunhuang left-reading image a slides to the boundary of the sliding range in the virtual raster image, namely the upper endpoint of the broken edge part of the image a is respectively superposed with two pixel points at the upper end and the lower end of the sliding range; then entering step K14;
k14: maintaining the Dunhuang left and right images a and b on the left and right sides of the virtual raster image, aligning the reference line positions of the left and right sides of the Dunhuang left and right images a and b with the vertical grid lines in the virtual raster image, aligning the book borders on the upper and lower parts of the Dunhuang left and right images b with the horizontal grid lines on the upper and lower parts of the virtual raster image, aligning the lower end point of the broken edge part of the Dunhuang left and right images a with the lower end point of the broken edge part of the Dunhuang left and right images b, and sequentially executing the steps K5 to K8; after the step K8 is finished, directly entering the step K15;
k15, sliding the Dunhuang left-reading image a upwards and downwards in the virtual raster image with the lower end point of the broken edge part of the Dunhuang left-reading image b as the reference point, and the sliding range does not exceed the upper end point of the broken edge part of the Chinese character image b and the upper and lower P pixels respectively; repeating the steps K5 to K8 after each movement until the Dunhuang relic image a slides to the boundary of the sliding range in the virtual raster image, namely the upper end point of the broken edge part of the image a is respectively superposed with two pixel points at the upper end and the lower end of the sliding range; then entering a step L;
l: for Dunhuang left-hand book remnant image a, calculating the time sequence matching degree in turn with each Dunhuang left-hand book remnant image in the folder to be compared according to the method in step K; and finally, sorting the images from large to small according to the time sequence matching degree values, and returning the front H images with the highest matching degree with the time sequence of the Dunhuang relic image a by taking the priority of smaller sliding distance if the time sequence matching degrees are the same as each other as the alternative images with higher conjugation degree with the Dunhuang relic image a.
In this example, H is 5.