[go: up one dir, main page]

CN102890818B - Method and device for reassembling joint photographic experts group (JPG) picture fragments based on thumbnail - Google Patents

Method and device for reassembling joint photographic experts group (JPG) picture fragments based on thumbnail Download PDF

Info

Publication number
CN102890818B
CN102890818B CN201210277280.1A CN201210277280A CN102890818B CN 102890818 B CN102890818 B CN 102890818B CN 201210277280 A CN201210277280 A CN 201210277280A CN 102890818 B CN102890818 B CN 102890818B
Authority
CN
China
Prior art keywords
fragment
mrow
head
mtd
head fragment
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
CN201210277280.1A
Other languages
Chinese (zh)
Other versions
CN102890818A (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.)
Xiamen Meiya Pico Information Co Ltd
Original Assignee
Xiamen Meiya Pico Information 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 Xiamen Meiya Pico Information Co Ltd filed Critical Xiamen Meiya Pico Information Co Ltd
Priority to CN201210277280.1A priority Critical patent/CN102890818B/en
Publication of CN102890818A publication Critical patent/CN102890818A/en
Application granted granted Critical
Publication of CN102890818B publication Critical patent/CN102890818B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Image Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a method for reassembling joint photographic experts group (JPG) picture fragments based on a thumbnail. The method comprises the following steps of: amplifying the thumbnail of the original JPG picture in the currently acquired head fragment to reach the same size of the original JPG picture; predicting a picture pixel value of the first row of the next fragment of the current head fragment according to a pixel value of an ith row of the original JPG picture, which is recorded by an ending part of a sector where the current head fragment is positioned, and a pixel value of an (i+1)th row of the amplified picture of the thumbnail of the original JPG picture, wherein i is the row number of the original JPG picture row in the original JPG picture, which is recorded by the ending part of the sector where the current head fragment is positioned; and selecting a non-head fragment as the next fragment of the current head fragment from a non-head fragment set, wherein the difference between the pixel value of the first row of the non-head fragment and the pixel value of the first row of the next fragment of the current head fragment, which is predicted in the previous step, is the smallest. By the method for reassembling the JPG picture fragments, reassembly accuracy and reassembly speed are high.

Description

Method and device for recombining fragments of JPG (joint photographic experts group) picture based on thumbnail
Technical Field
The invention relates to the technical field of information security and computer application, in particular to a method and a device for recombining fragments of a JPG (joint picture group) picture based on a thumbnail.
Background
Conventional data recovery techniques rely on file system meta-information such as file allocation tables, directory structures, etc., but in many cases, this meta-information may be lost due to overwriting or human manipulation, in which case conventional data recovery techniques will not recover the file. File reorganization has gained wide attention in recent years as a further development of conventional data recovery.
The picture is one of the most powerful electronic evidences, the recombination technology of the picture is often the key research object of a data recovery expert, and the recombination technology of the JPG picture compression format is the key research object of the most popular picture format. The most difficult problem in the JPG picture recombination technology is the fragment recombination problem. Fragmentation of JPG pictures is a particularly difficult problem if just by enumerating all the combination types.
At present, the recombination technology of JPG picture fragments is mainly realized by edge pixel matching and decoding verification of a picture, but an error exists because the edge pixel matching method of the picture predicts the initial edge pixel of the next fragment by the edge pixel of the known picture fragment. Therefore, the limitation of the existing edge pixel matching algorithm results in that when the existing JPG picture fragment recombination technology is adopted to recombine JPG picture fragments, even if all the JPG picture fragments are found, correct pictures cannot be recombined frequently. For example, the situation that the adrot Recovery recombines the JPG picture by adopting the foreign comparison famous JPG picture fragment recombination software often occurs: when the thumbnail is used to view the picture recombination result, the picture is correct, but when the picture is opened, the picture is wrong (not a complete original picture).
In view of this, a JPG picture fragment reassembly method capable of more accurately determining a next fragment of a current picture fragment is needed to improve the accuracy of JPG picture fragment reassembly.
Disclosure of Invention
The invention provides a method and a device for recombining JPG picture fragments based on thumbnails, which are used for solving the problem of low recombination accuracy of the conventional JPG picture fragment recombination technology.
The invention provides a method for recombining fragments of a JPG (joint picture group) picture based on a thumbnail, which comprises the following steps:
step 1: according to the head signature of the JPG picture, acquiring head fragments of the JPG picture from a storage medium to be restored and forming a head fragment set, and simultaneously acquiring non-head fragments of the JPG picture from the storage medium to be restored and forming a non-head fragment set;
step 2: is the head fragment set or the non-head fragment set determined to be an empty set? If yes, ending the process, otherwise, continuing to execute the step 3;
and step 3: taking any one head fragment from the head fragment set and deleting the taken head fragment from the head fragment set; acquiring a thumbnail of an original JPG picture from a current head fragment, and amplifying the thumbnail of the original JPG picture into a picture with the same size as the original JPG picture according to size information of the original JPG picture recorded in the current head fragment to obtain an enlarged image of the thumbnail of the original JPG picture;
and 4, step 4: predicting the picture pixel value of the line 1 of the next fragment of the current head fragment according to the pixel value of the line i of the original JPG picture recorded at the ending part of the sector where the current head fragment is located and the pixel value of the line (i +1) of the enlarged image of the original JPG picture; wherein i is the line number of the original JPG picture line recorded at the ending part of the sector where the current head fragment is located in the original JPG picture, i is more than or equal to 1 and less than or equal to H, i is a positive integer, and H is the height of the original JPG picture corresponding to the current head fragment;
and 5: selecting a non-head fragment with the smallest difference between the pixel value of the 1 st line and the pixel value of the 1 st line of the next fragment of the current head fragment predicted in the previous step from the non-head fragment set as the next fragment of the current head fragment;
step 6: merging a current head fragment with a next fragment of the current head fragment and deleting the next fragment of the current head fragment from the set of non-head fragments; determine whether the file obtained by merging the current header fragment with the next fragment of the current header fragment is a complete JPG picture file? If yes, outputting the complete JPG picture file, and returning to execute the step 2; otherwise, replacing the current head fragment with the file obtained after merging and returning to execute the step 4.
Preferably, the step 4 of predicting the picture pixel value of the line 1 of the next fragment of the current head fragment according to the pixel value of the line i of the original JPG picture recorded at the end portion of the sector where the current head fragment is located and the pixel value of the line (i +1) of the enlarged image of the thumbnail of the original JPG picture includes: adopting the pixel value P (i, j) of the ith row and jth column of the original JPG picture recorded at the end part of the sector where the current head fragment is positioned and the thumbnail of the original JPG pictureThe weighted average of the pixel values P' (i +1, j) of the (i +1) th row and j column of the enlarged image of (b) is taken as the pixel value P (i +1, j) of the 1 st row and j column of the next patch of the current head patch; j is more than or equal to 1 and less than or equal to W, j is a positive integer, and W is the width of the original JPG picture corresponding to the current head fragment; the pixel value P (i, j) is weighted by alphaiThe pixel value P' (i +1, j) is weighted by βi,αiAnd betaiThe calculation method comprises the following steps:
<math> <mrow> <msub> <mi>&alpha;</mi> <mi>i</mi> </msub> <mo>=</mo> <mfenced open='{' close=''> <mtable> <mtr> <mtd> <mfrac> <mrow> <munderover> <mi>&Sigma;</mi> <mrow> <mi>j</mi> <mo>=</mo> <mn>1</mn> </mrow> <mi>W</mi> </munderover> <mi>f</mi> <mrow> <mo>(</mo> <mi>j</mi> <mo>)</mo> </mrow> </mrow> <mi>W</mi> </mfrac> <mo>,</mo> <mi>i</mi> <mo>=</mo> <mn>2,3</mn> <mo>,</mo> <mo>.</mo> <mo>.</mo> <mo>.</mo> <mo>,</mo> <mi>H</mi> </mtd> </mtr> <mtr> <mtd> <mn>0</mn> <mo>,</mo> <mi>i</mi> <mo>=</mo> <mn>1</mn> </mtd> </mtr> </mtable> </mfenced> <mo>,</mo> </mrow> </math>
<math> <mrow> <msub> <mi>&beta;</mi> <mi>i</mi> </msub> <mo>=</mo> <mfrac> <mrow> <munderover> <mi>&Sigma;</mi> <mrow> <mi>j</mi> <mo>=</mo> <mn>1</mn> </mrow> <mi>W</mi> </munderover> <mi>g</mi> <mrow> <mo>(</mo> <mi>j</mi> <mo>)</mo> </mrow> </mrow> <mi>W</mi> </mfrac> <mo>,</mo> <mi>i</mi> <mo>=</mo> <mn>1,2</mn> <mo>,</mo> <mo>.</mo> <mo>.</mo> <mo>.</mo> <mo>,</mo> <mi>H</mi> <mo>,</mo> </mrow> </math>
wherein, <math> <mrow> <mi>f</mi> <mrow> <mo>(</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <mfenced open='{' close=''> <mtable> <mtr> <mtd> <mn>1</mn> <mo>,</mo> </mtd> <mtd> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>-</mo> <mn>1</mn> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mtd> </mtr> <mtr> <mtd> <mn>0</mn> <mo>,</mo> </mtd> <mtd> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>&NotEqual;</mo> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>-</mo> <mn>1</mn> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mtd> </mtr> </mtable> </mfenced> <mo>,</mo> <mi>g</mi> <mrow> <mo>(</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <mfenced open='{' close=''> <mtable> <mtr> <mtd> <mn>1</mn> <mo>,</mo> </mtd> <mtd> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <msup> <mi>P</mi> <mo>&prime;</mo> </msup> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mtd> </mtr> <mtr> <mtd> <mn>0</mn> <mo>,</mo> </mtd> <mtd> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>&NotEqual;</mo> <msup> <mi>P</mi> <mo>&prime;</mo> </msup> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mtd> </mtr> </mtable> </mfenced> <mo>;</mo> </mrow> </math> and when alpha isiiWhen 0, P (i +1, j) is 0.
And when the current head fragment does not have the 1 st line of pixel information of the original JPG picture, predicting the 1 st line of pixels of the enlarged image of the thumbnail of the original JPG picture corresponding to the current head fragment as the 1 st line of pixels of the original JPG picture.
Preferably, the step 5 of selecting a non-head fragment in the non-head fragment set, of which the difference between the pixel value of the 1 st line and the pixel value of the 1 st line of the next fragment of the current head fragment predicted in the previous step is the smallest, as the next fragment of the current head fragment includes: computing an nth non-head in the set of non-head fragmentsThe difference C between the pixel value of row 1 of the partial fragment and the pixel value of row 1 of the next fragment of the current head fragment predicted in step 4nWhere N is 0,1, …, N is the number of non-head fragments in the non-head fragment set, Qn(1, j) is the pixel value of the nth non-head fragment in the non-head fragment set at row 1 and column j, and P (i +1, j) is the pixel value of the next fragment at row 1 and column j of the current head fragment; c is to be1,C2,…,CNThe non-head fragment corresponding to the smallest one of the head fragments is taken as the next fragment of the current head fragment.
Preferably, the determining whether the file obtained by merging the current header fragment with the next fragment of the current header fragment in step 6 is a complete JPG picture file includes: determine whether the last two bytes of the file obtained after merging are 0xFFD 9? And if so, the file obtained after merging is a complete JPG picture file, otherwise, the file obtained after merging is not a complete JPG picture file.
The invention also provides a JPG picture fragment recombination device based on the thumbnail, which comprises a fragment acquisition and storage module, a judgment module, a selection module, a prediction module, a matching module and a merging module;
the fragment acquiring and storing module is used for acquiring head fragments of the JPG picture from a storage medium to be restored according to the head signature of the JPG picture, forming a head fragment set for storage, and simultaneously acquiring non-head fragments of the JPG picture from the storage medium to be restored, forming a non-head fragment set for storage; the head fragment set and the non-head fragment set are provided for the judging module and the matching module, and the head fragment set is provided for the selecting module; in addition, the fragment acquiring and storing module is further configured to delete the next fragment of the current head fragment from the non-head fragment set according to the deletion request of the merging module, and resend the new non-head fragment set to the determining module and the matching module;
the judging module is used for judging whether the head fragment set or the non-head fragment set provided by the fragment acquiring and storing module is an empty set, and if not, informing the selecting module to select the head fragments;
the selection module is used for selecting one head fragment from the head fragment set provided by the fragment acquisition and storage module according to the head fragment selection notice sent by the judgment module and deleting the selected head fragment from the head fragment set; acquiring a thumbnail of an original JPG picture from a current head fragment, amplifying the thumbnail of the original JPG picture into a picture with the same size as the original JPG picture according to the size information of the original JPG picture recorded in the current head fragment, and providing the current head fragment and the enlarged image of the thumbnail of the original JPG picture for the prediction module;
the prediction module is configured to receive the current head fragment provided by the selection module or the merging module and the enlarged image of the thumbnail of the original JPG picture provided by the selection module, predict a picture pixel value of the line 1 of the next fragment of the current head fragment according to a pixel value of the line i of the original JPG picture recorded at the end portion of the sector where the current head fragment is located and a pixel value of the line (i +1) of the enlarged image of the thumbnail of the original JPG picture, and provide the current head fragment and the picture pixel value of the line 1 of the next fragment of the current head fragment to the matching module; wherein i is the number of rows of the original JPG picture recorded at the ending part of the sector where the current head fragment is located in the original JPG picture, i is a positive integer, i is more than or equal to 1 and less than or equal to H, and H is the height of the original JPG picture corresponding to the current head fragment;
the matching module is used for selecting a non-head fragment with the smallest difference between the pixel value of the 1 st line and the pixel value of the 1 st line of the next fragment of the current head fragment predicted by the prediction module from the non-head fragment set provided by the fragment acquisition and storage module as the next fragment of the current head fragment, and providing the next fragment of the current head fragment and the current head fragment sent by the prediction module to the merging module;
the merging module is configured to merge the current head fragment provided by the matching module with a next fragment of the current head fragment, and send a deletion request for deleting the next fragment of the current head fragment from the non-head fragment set to the fragment acquiring and storing module; in addition, the method is further used for outputting the complete JPG picture file obtained after merging, or replacing the current header fragment with the incomplete JPG picture file obtained after merging and providing the current header fragment after replacement to the prediction module.
Preferably, the prediction module uses a weighted average value of the pixel value P (i, j) of the ith row and jth column of the original JPG picture recorded at the end of the sector where the current head fragment is located and the pixel value P' (i +1, j) of the (i +1) th row and jth column of the enlarged image of the thumbnail of the original JPG picture as the pixel value P (i +1, j) of the jth row and jth column of the next fragment of the current head fragment; j is more than or equal to 1 and less than or equal to W, j is a positive integer, and W is the width of the original JPG picture corresponding to the current head fragment; the pixel value P (i, j) is weighted by alphaiThe pixel value P' (i +1, j) is weighted by βi
<math> <mrow> <msub> <mi>&alpha;</mi> <mi>i</mi> </msub> <mo>=</mo> <mfenced open='{' close=''> <mtable> <mtr> <mtd> <mfrac> <mrow> <munderover> <mi>&Sigma;</mi> <mrow> <mi>j</mi> <mo>=</mo> <mn>1</mn> </mrow> <mi>W</mi> </munderover> <mi>f</mi> <mrow> <mo>(</mo> <mi>j</mi> <mo>)</mo> </mrow> </mrow> <mi>W</mi> </mfrac> <mo>,</mo> <mi>i</mi> <mo>=</mo> <mn>2,3</mn> <mo>,</mo> <mo>.</mo> <mo>.</mo> <mo>.</mo> <mo>,</mo> <mi>H</mi> </mtd> </mtr> <mtr> <mtd> <mn>0</mn> <mo>,</mo> <mi>i</mi> <mo>=</mo> <mn>1</mn> </mtd> </mtr> </mtable> </mfenced> <mo>,</mo> </mrow> </math>
<math> <mrow> <msub> <mi>&beta;</mi> <mi>i</mi> </msub> <mo>=</mo> <mfrac> <mrow> <munderover> <mi>&Sigma;</mi> <mrow> <mi>j</mi> <mo>=</mo> <mn>1</mn> </mrow> <mi>W</mi> </munderover> <mi>g</mi> <mrow> <mo>(</mo> <mi>j</mi> <mo>)</mo> </mrow> </mrow> <mi>W</mi> </mfrac> <mo>,</mo> <mi>i</mi> <mo>=</mo> <mn>1,2</mn> <mo>,</mo> <mo>.</mo> <mo>.</mo> <mo>.</mo> <mo>,</mo> <mi>H</mi> <mo>,</mo> </mrow> </math>
Wherein, <math> <mrow> <mi>f</mi> <mrow> <mo>(</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <mfenced open='{' close=''> <mtable> <mtr> <mtd> <mn>1</mn> <mo>,</mo> </mtd> <mtd> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>-</mo> <mn>1</mn> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mtd> </mtr> <mtr> <mtd> <mn>0</mn> <mo>,</mo> </mtd> <mtd> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>&NotEqual;</mo> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>-</mo> <mn>1</mn> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mtd> </mtr> </mtable> </mfenced> <mo>,</mo> <mi>g</mi> <mrow> <mo>(</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <mfenced open='{' close=''> <mtable> <mtr> <mtd> <mn>1</mn> <mo>,</mo> </mtd> <mtd> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <msup> <mi>P</mi> <mo>&prime;</mo> </msup> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mtd> </mtr> <mtr> <mtd> <mn>0</mn> <mo>,</mo> </mtd> <mtd> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>&NotEqual;</mo> <msup> <mi>P</mi> <mo>&prime;</mo> </msup> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mtd> </mtr> </mtable> </mfenced> <mo>;</mo> </mrow> </math> and when alpha isiiWhen the current header fragment does not have the line 1 pixel information of the original JPG picture, the prediction module adopts the line 1 pixel of the enlarged image of the thumbnail of the original JPG picture as the line 1 pixel of the original JPG picture.
Preferably, the matching module calculates a difference C between the pixel value of the 1 st row of the nth non-head fragment in the set of non-head fragments and the pixel value of the 1 st row of the next fragment of the current head fragment predicted by the prediction modulenAnd C is1,C2,…,CNThe non-head fragment corresponding to the smallest one of the head fragments is taken as the next fragment of the current head fragment;
wherein,n is 0,1, …, N is the number of non-head fragments in the non-head fragment set, Qn(1, j) is the pixel value of the nth non-head fragment in the non-head fragment set at row 1 and column j, and P (i +1, j) is the pixel value of the next fragment at row 1 and column j of the current head fragment.
The method for reconstructing the JPG picture fragments based on the thumbnail creatively combines the known pixel information of the original JPG picture in the head fragments with the thumbnail of the original JPG picture, utilizes the existing picture information to predict the edge pixels of the current picture fragments to the greatest extent, has the characteristics of high accuracy and high reconstruction speed, does not need manual intervention in the reconstruction process, has high automation degree, and solves the problem of misjudgment in the reconstruction process of the JPG picture fragments caused by errors predicted under certain conditions when the edge pixels are predicted only by the head fragments or only the thumbnails in the existing reconstruction technologies. In addition, the JPG picture edge pixel prediction method related in the thumbnail-based JPG picture fragment recombination scheme provided by the invention not only can be used in a picture fragment recombination technology, but also can be used in a picture repairing technology.
Drawings
Fig. 1 is a flowchart of a method for reorganizing JPG picture fragments based on thumbnails according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a JPG picture fragment reorganizing device based on a thumbnail according to an embodiment of the present invention.
Detailed Description
In order to solve the problem of low accuracy of the JPG picture fragment recombination caused by the limitation of an edge pixel matching algorithm in the prior art, the embodiment of the invention provides a novel JPG picture fragment recombination scheme, wherein the scheme comprehensively adopts the local pixel information of the original JPG picture which is acquired currently and the pixel information in the thumbnail of the original JPG picture to predict the edge pixel of the current picture fragment (namely, predict the next fragment of the current picture fragment). The following describes the embodiments of the present invention in detail with reference to the accompanying drawings.
Fig. 1 is a flowchart of a method for reorganizing JPG picture fragments based on thumbnails according to an embodiment of the present invention, where the method includes the following steps:
s1: and according to the head signature of the JPG picture, acquiring the head fragments of the JPG picture from the storage medium to be restored and forming a head fragment set, and simultaneously acquiring the non-head fragments of the JPG picture from the storage medium to be restored and forming a non-head fragment set.
Wherein, because the first two bytes of the JPG picture file are fixed as 0xFFD8, the three four bytes have 9 forms: 0xFFE0, 0xFFE1, 0xFFE2, 0xFFE8, 0xFFFE b, 0 xfffee, 0xFFFE, 0xFFC4, 0XFFDB, and therefore this step searches for a fragment in any one of the form of one-two bytes of 0xFFD8 and three-four bytes of 0xFFE0, 0xFFE1, 0xFFE2, 0xFFE8, 0 xfffeb, 0 xfffee, 0xFFFE, 0 xfffc 4, 0XFFDB on a storage medium to be restored as a JPG picture header fragment and constitutes a header fragment set, and a header signature fragment on a storage medium to be restored without a JPG picture is regarded as a non-header fragment and constitutes a non-header fragment set.
S2: is it determined whether a head fragment set or a non-head fragment set is an empty set? If so, the process ends, otherwise, the process continues to S3.
S3: taking any one head fragment from the head fragment set and deleting the head fragment from the head fragment set; and obtaining a thumbnail of the original JPG picture corresponding to the current head fragment from the current head fragment, and enlarging the thumbnail of the original JPG picture corresponding to the current head fragment into a picture with the same size as the original JPG picture according to the size information of the original JPG picture recorded in the current head fragment to obtain an enlarged image of the thumbnail of the original JPG picture corresponding to the current head fragment.
S4: and predicting the picture pixel value of the line 1 of the next fragment of the current head fragment according to the pixel value of the line i of the original JPG picture recorded at the ending part of the sector where the current head fragment is located and the pixel value of the line (i +1) of the enlarged image of the original JPG picture. Wherein i is the number of lines of the original JPG picture recorded at the ending part of the sector where the current head fragment is located in the original JPG picture, i is a positive integer, i is more than or equal to 1 and less than or equal to H, and H is the height of the original JPG picture corresponding to the current head fragment. In this step, when there is no pixel information of the 1 st line of the original JPG picture in the current header fragment, the pixel value of the 1 st line of the enlarged image of the thumbnail of the original JPG picture is used as the pixel value of the 1 st line of the original JPG picture.
S5: and selecting a non-head fragment with the smallest difference between the pixel value of the 1 st line in the non-head fragment set and the pixel value of the 1 st line of the next fragment of the current head fragment predicted in the previous step as the next fragment of the current head fragment.
S6: merging the current head fragment with a next fragment of the current head fragment, and deleting the next fragment of the current head fragment from the set of non-head fragments. Specifically, merging in this step refers to connecting the next fragment of the current header fragment to the end of the current header fragment.
S7: determine whether the file obtained by merging the current header fragment with the next fragment of the current header fragment is a complete JPG picture file? If yes, go to S8; otherwise, go to execution S9.
In step S7, specifically, it is determined whether the last two bytes of the file obtained by merging the current header fragment and the next fragment of the current header fragment are 0xFFD9 (file end identifier of JPG picture), and if yes, it is determined that the file obtained by merging is a complete JPG picture file.
S8: the complete JPG picture file is output and execution returns to S2.
S9: the current header fragment is replaced with the merged file and execution returns to S4. Namely: and taking the file obtained after combination as the current head fragment, and continuously matching the current head fragment with the next fragment by adopting the process until obtaining the complete original JPG picture file corresponding to the current head fragment.
Preferably, in the process shown in fig. 1, the specific implementation manner of S4 is: defining P (i, j) as the pixel value of the ith row and the jth column of the original JPG picture recorded at the ending part of the sector where the current head fragment is located, and P' (i, j) as the pixel value of the ith row and the jth column of the enlarged image of the original JPG picture, wherein j is a positive integer, j is more than or equal to 1 and less than or equal to W, and W is the width of the original JPG picture corresponding to the current head fragment. Since the current head fragment is known, i is the number of rows in the original JPG picture recorded at the end portion of the sector where the current head fragment is located, i.e. the i-th row and the previous picture data in the original JPG picture corresponding to the current head fragment have been restored, and now the pixel value of the (i +1) th row (i.e. the 1 st row of the next fragment of the current head fragment) in the original JPG picture is to be predicted, in the embodiment of the present invention, the weighted average value of the pixel value P (i, j) of the j-th row of the i-th row of the original JPG picture recorded at the end portion of the sector where the current head fragment is located and the pixel value P' (i +1, j) of the j-th row of the (i +1) th column of the enlarged image of the (i +1) th row of the thumbnail of the original JPG picture is used as the pixel value P (i +1, j) of the j-th row of the:
<math> <mrow> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>+</mo> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <mfenced open='{' close=''> <mtable> <mtr> <mtd> <mfrac> <mrow> <msub> <mi>&alpha;</mi> <mi>i</mi> </msub> <mo>&times;</mo> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>+</mo> <msub> <mi>&beta;</mi> <mi>i</mi> </msub> <mo>&times;</mo> <msup> <mi>P</mi> <mo>&prime;</mo> </msup> <mrow> <mo>(</mo> <mi>i</mi> <mo>+</mo> <mn>1</mn> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mrow> <mrow> <msub> <mi>&alpha;</mi> <mi>i</mi> </msub> <mo>+</mo> <msub> <mi>&beta;</mi> <mi>i</mi> </msub> </mrow> </mfrac> <mo>,</mo> <msub> <mi>&alpha;</mi> <mi>i</mi> </msub> <mo>+</mo> <msub> <mi>&beta;</mi> <mi>i</mi> </msub> <mo>&NotEqual;</mo> <mn>0</mn> </mtd> </mtr> <mtr> <mtd> <mn>0</mn> <mo>,</mo> <msub> <mi>&alpha;</mi> <mi>i</mi> </msub> <mo>+</mo> <msub> <mi>&beta;</mi> <mi>i</mi> </msub> <mo>=</mo> <mn>0</mn> </mtd> </mtr> </mtable> </mfenced> <mo>-</mo> <mo>-</mo> <mo>-</mo> <mrow> <mo>(</mo> <mn>1</mn> <mo>)</mo> </mrow> </mrow> </math>
in formula (1), the pixel value P (i, j) is weighted by αiThe reliability is used for representing the reliability of predicting the pixel value of the (i +1) th line of the original JPG picture by using the pixel value of the ith line of the original JPG picture; the pixel value P' (i +1, j) is weighted by βiAnd a reliability alpha for indicating that the pixels on the (i +1) th line of the original image are predicted by the pixels on the (i +1) th line of the enlarged image of the thumbnail of the original JPG pictureiAnd betaiCalculated using the following equations (2) and (3), respectively:
<math> <mrow> <msub> <mi>&alpha;</mi> <mi>i</mi> </msub> <mo>=</mo> <mfenced open='{' close=''> <mtable> <mtr> <mtd> <mfrac> <mrow> <munderover> <mi>&Sigma;</mi> <mrow> <mi>j</mi> <mo>=</mo> <mn>1</mn> </mrow> <mi>W</mi> </munderover> <mi>f</mi> <mrow> <mo>(</mo> <mi>j</mi> <mo>)</mo> </mrow> </mrow> <mi>W</mi> </mfrac> <mo>,</mo> <mi>i</mi> <mo>=</mo> <mn>2,3</mn> <mo>,</mo> <mo>.</mo> <mo>.</mo> <mo>.</mo> <mo>,</mo> <mi>H</mi> </mtd> </mtr> <mtr> <mtd> <mn>0</mn> <mo>,</mo> <mi>i</mi> <mo>=</mo> <mn>1</mn> </mtd> </mtr> </mtable> </mfenced> <mo>-</mo> <mo>-</mo> <mo>-</mo> <mrow> <mo>(</mo> <mn>2</mn> <mo>)</mo> </mrow> </mrow> </math>
<math> <mrow> <msub> <mi>&beta;</mi> <mi>i</mi> </msub> <mo>=</mo> <mfrac> <mrow> <munderover> <mi>&Sigma;</mi> <mrow> <mi>j</mi> <mo>=</mo> <mn>1</mn> </mrow> <mi>W</mi> </munderover> <mi>g</mi> <mrow> <mo>(</mo> <mi>j</mi> <mo>)</mo> </mrow> </mrow> <mi>W</mi> </mfrac> <mo>,</mo> <mi>i</mi> <mo>=</mo> <mn>1,2</mn> <mo>,</mo> <mo>.</mo> <mo>.</mo> <mo>.</mo> <mo>,</mo> <mi>H</mi> <mo>-</mo> <mo>-</mo> <mo>-</mo> <mrow> <mo>(</mo> <mn>3</mn> <mo>)</mo> </mrow> </mrow> </math>
in equations (2) and (3):
<math> <mrow> <mi>f</mi> <mrow> <mo>(</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <mfenced open='{' close=''> <mtable> <mtr> <mtd> <mn>1</mn> <mo>,</mo> </mtd> <mtd> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>-</mo> <mn>1</mn> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mtd> </mtr> <mtr> <mtd> <mn>0</mn> <mo>,</mo> </mtd> <mtd> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>&NotEqual;</mo> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>-</mo> <mn>1</mn> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mtd> </mtr> </mtable> </mfenced> <mo>-</mo> <mo>-</mo> <mo>-</mo> <mrow> <mo>(</mo> <mn>4</mn> <mo>)</mo> </mrow> </mrow> </math>
<math> <mrow> <mi>g</mi> <mrow> <mo>(</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <mfenced open='{' close=''> <mtable> <mtr> <mtd> <mn>1</mn> <mo>,</mo> </mtd> <mtd> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <msup> <mi>P</mi> <mo>&prime;</mo> </msup> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mtd> </mtr> <mtr> <mtd> <mn>0</mn> <mo>,</mo> </mtd> <mtd> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>&NotEqual;</mo> <msup> <mi>P</mi> <mo>&prime;</mo> </msup> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mtd> </mtr> </mtable> </mfenced> <mo>-</mo> <mo>-</mo> <mo>-</mo> <mrow> <mo>(</mo> <mn>5</mn> <mo>)</mo> </mrow> </mrow> </math>
it is worth mentioning, as previously mentioned: when the current header fragment does not have the line 1 pixel information of the original JPG picture, let P (1, j) be P' (1, j), that is, at this time, the line 1 pixel of the enlarged image of the thumbnail of the original JPG picture is adopted as the line 1 pixel of the predicted original JPG picture. In addition, since P (0, j) does not exist, let α in formula (2)10, namely: when calculating P (2, j), the pixels in line 2 of the enlarged image of the thumbnail of the original JPG picture are still used as the pixels in line 2 of the predicted original JPG picture.
Preferably, the specific implementation manner of step S5 is:
(1) first, the difference C between the row 1 pixel value of each non-head fragment in the non-head fragment set and the row 1 pixel value of the next fragment of the current head fragment predicted in step 4 is calculatedn
<math> <mrow> <msub> <mi>C</mi> <mi>n</mi> </msub> <mo>=</mo> <munderover> <mi>&Sigma;</mi> <mrow> <mi>j</mi> <mo>=</mo> <mn>1</mn> </mrow> <mi>L</mi> </munderover> <mo>|</mo> <msub> <mi>Q</mi> <mi>n</mi> </msub> <mrow> <mo>(</mo> <mn>1</mn> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>-</mo> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>+</mo> <mn>1</mn> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>|</mo> <mo>-</mo> <mo>-</mo> <mo>-</mo> <mrow> <mo>(</mo> <mn>6</mn> <mo>)</mo> </mrow> </mrow> </math>
Wherein N is 0,1, …, and N is the number of non-head fragments in the non-head fragment set;
(2) c is to be1,C2,…,CNThe non-head fragment corresponding to the smallest one of the head fragments is taken as the next fragment of the current head fragment.
Wherein P (i +1, j) is calculated by formula (1), and is the pixel value of the 1 st row and j column of the next fragment of the current head fragment predicted in step 4, Qn(1, j) is the pixel value of the 1 st row and j column of the nth non-header fragment in the non-header fragment set. CnThe smaller the value of (a) indicates that the difference between the pixel of the 1 st row of the nth non-head fragment in the non-head fragment set and the pixel of the 1 st row of the next fragment of the current head fragment predicted in step 4 is smaller, i.e. the probability that the next fragment of the current head fragment is the nth non-head fragment in the non-head fragment set is larger.
Corresponding to the method for reorganizing the JPG picture fragments based on the thumbnail provided by the embodiment of the present invention, the embodiment of the present invention further provides a device for reorganizing the JPG picture fragments based on the thumbnail, as shown in fig. 2, the device includes a fragment obtaining and storing module 21, a judging module 22, a selecting module 23, a predicting module 24, a matching module 25, and a merging module 26.
The fragment acquiring and storing module 21 is configured to acquire a head fragment of the JPG picture from a storage medium to be restored according to a head signature of the JPG picture, form a head fragment set for storage, and simultaneously acquire a non-head fragment of the JPG picture from the storage medium to be restored, form a non-head fragment set for storage; the fragment acquiring and storing module 21 is further configured to provide the head fragment set and the non-head fragment set to the determining module 22 and the matching module 25, and provide the head fragment set to the selecting module 23; in addition, the fragment acquiring and storing module 21 is further configured to delete the next fragment of the current head fragment from the non-head fragment set according to the deletion request sent by the merging module 26, and resend the new non-head fragment set to the determining module 22 and the matching module 25.
The judging module 22 is configured to judge whether the head fragment set or the non-head fragment set provided by the fragment acquiring and storing module 21 is an empty set, and if not, notify the selecting module 23 to select the head fragment.
A selecting module 23, configured to select any one of the head fragments from the head fragment set provided by the fragment acquiring and storing module 21 according to the head fragment selection notification sent by the determining module 22, and delete the selected head fragment from the head fragment set; and obtains the thumbnail of the original JPG picture from the current header fragment, enlarges the thumbnail of the original JPG picture into a picture having the same size as the original JPG picture according to the size information of the original JPG picture recorded in the current header fragment, and provides the enlarged images of the current header fragment and the thumbnail of the original JPG picture to the prediction module 24.
A prediction module 24, configured to receive the current head fragment provided by the selection module 23 or the merging module 26 and the enlarged image of the thumbnail of the original JPG picture provided by the selection module 23, predict a picture pixel value of the line 1 of the next fragment of the current head fragment according to a pixel value of the line i of the original JPG picture recorded at the end of the sector where the current head fragment is located and a pixel value of the line (i +1) of the enlarged image of the thumbnail of the original JPG picture, and provide the current head fragment and the picture pixel value of the line 1 of the next fragment of the current head fragment to the matching module 25; and i is the line number of the original JPG picture line recorded at the ending part of the sector where the current head fragment is located in the original JPG picture, i is more than or equal to 1 and less than or equal to H, i is a positive integer, and H is the height of the original JPG picture corresponding to the current head fragment.
And a matching module 25, configured to select a non-head fragment with a smallest difference between the pixel value of the row 1 in the non-head fragment set provided by the fragment obtaining and storing module 21 and the pixel value of the row 1 in the next fragment of the current head fragment predicted by the prediction module 24 as a next fragment of the current head fragment, and provide the next fragment of the current head fragment and the current head fragment sent by the prediction module 24 to the merging module 26.
A merging module 26, configured to merge the current head fragment provided by the matching module 25 with a next fragment of the current head fragment, and send a delete request for deleting the next fragment of the current head fragment from the non-head fragment set to the fragment acquiring and storing module 21; the merging module 26 is further configured to output the merged complete JPG picture file, or replace the current header fragment with the merged incomplete JPG picture file and provide the replaced current header fragment to the prediction module 24.
Preferably, the prediction module 24 uses a weighted average of the pixel value P (i, j) of the ith row and jth column of the original JPG picture recorded at the end of the sector where the current head fragment is located and the pixel value P' (i +1, j) of the (i +1) th row and jth column of the enlarged image of the thumbnail of the original JPG picture as the pixel value P (i +1, j) of the jth row and jth column of the next fragment of the current head fragment; j is more than or equal to 1 and less than or equal to W, j is a positive integer, and W is the width of the original JPG picture corresponding to the current head fragment; the pixel value P (i, j) is weighted by alphaiThe pixel value P' (i +1, j) is weighted by βi,αiAnd betaiThe above equations (2) and (3) are used for calculation, and will not be described in detail.
Preferably, matching module 25 calculates a difference C between the pixel value of row 1 of the nth non-head fragment in the set of non-head fragments and the pixel value of row 1 of the next fragment of the current head fragment predicted by prediction module 24nAnd C is1,C2,…,CNThe smallest one corresponds toAs the next fragment to the current head fragment; wherein, CnCalculated using equation (6) provided previously.
The picture fragment recombination scheme based on the thumbnail creatively combines the known pixel information of the original JPG picture in the head fragment with the thumbnail of the original JPG picture, utilizes the existing picture information to predict the edge pixel of the current picture fragment to the greatest extent, has the characteristics of high accuracy and high recombination speed, does not need manual intervention in the recombination process, has high automation degree, and solves the problem of misjudgment in the JPG picture fragment recombination process caused by errors predicted under certain conditions when the edge pixel is predicted only by the head fragment or only the thumbnail in some existing recombination technologies. In addition, the picture edge pixel prediction method related in the picture fragment reorganization scheme based on the thumbnail provided by the invention can be used in not only the picture fragment reorganization technology, but also the picture restoration technology.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (8)

1. A method for recombining fragments of a JPG picture based on a thumbnail is characterized by comprising the following steps:
step 1: according to the head signature of the JPG picture, acquiring head fragments of the JPG picture from a storage medium to be restored and forming a head fragment set, and simultaneously acquiring non-head fragments of the JPG picture from the storage medium to be restored and forming a non-head fragment set;
step 2: is the head fragment set or the non-head fragment set determined to be an empty set? If yes, ending the process, otherwise, continuing to execute the step 3;
and step 3: taking any one head fragment from the head fragment set and deleting the taken head fragment from the head fragment set; acquiring a thumbnail of an original JPG picture from a current head fragment, and amplifying the thumbnail of the original JPG picture into a picture with the same size as the original JPG picture according to size information of the original JPG picture recorded in the current head fragment to obtain an enlarged image of the thumbnail of the original JPG picture;
and 4, step 4: predicting the picture pixel value of the line 1 of the next fragment of the current head fragment according to the pixel value of the line i of the original JPG picture recorded at the ending part of the sector where the current head fragment is located and the pixel value of the line (i +1) of the enlarged image of the original JPG picture; wherein i is the line number of the original JPG picture line recorded at the ending part of the sector where the current head fragment is located in the original JPG picture, i is more than or equal to 1 and less than or equal to H, i is a positive integer, and H is the height of the original JPG picture corresponding to the current head fragment;
and 5: selecting a non-head fragment with the smallest difference between the pixel value of the 1 st line and the pixel value of the 1 st line of the next fragment of the current head fragment predicted in the previous step from the non-head fragment set as the next fragment of the current head fragment;
step 6: merging a current head fragment with a next fragment of the current head fragment and deleting the next fragment of the current head fragment from the set of non-head fragments; determine whether the file obtained by merging the current header fragment with the next fragment of the current header fragment is a complete JPG picture file? If yes, outputting the complete JPG picture file, and returning to execute the step 2; otherwise, replacing the current head fragment with the file obtained after merging and returning to execute the step 4.
2. The method as claimed in claim 1, wherein the step 4 of predicting the pixel value of the picture at the row 1 of the next fragment of the current head fragment according to the pixel value at the row i of the original JPG picture recorded at the end of the sector where the current head fragment is located and the pixel value at the row (i +1) of the enlarged image of the thumbnail of the original JPG picture comprises:
adopting a weighted average value of pixel values P (i, j) of the ith row and jth column of the original JPG picture recorded at the ending part of the sector where the current head fragment is located and pixel values P' (i +1, j) of the (i +1) th row and jth column of the enlarged image of the thumbnail of the original JPG picture as the pixel values P (i +1, j) of the 1 st row and jth column of the next fragment of the current head fragment;
j is more than or equal to 1 and less than or equal to W, j is a positive integer, and W is the width of the original JPG picture corresponding to the current head fragment; the pixel value P (i, j) is weighted by alphaiThe pixel value P' (i +1, j) is weighted by βi,αiAnd betaiThe calculation method comprises the following steps:
<math> <mrow> <msub> <mi>&alpha;</mi> <mi>i</mi> </msub> <mo>=</mo> <mfenced open='{' close=''> <mtable> <mtr> <mtd> <mfrac> <mrow> <munderover> <mi>&Sigma;</mi> <mrow> <mi>j</mi> <mo>=</mo> <mn>1</mn> </mrow> <mi>W</mi> </munderover> <mi>f</mi> <mrow> <mo>(</mo> <mi>j</mi> <mo>)</mo> </mrow> </mrow> <mi>W</mi> </mfrac> <mo>,</mo> </mtd> <mtd> <mi>i</mi> <mo>=</mo> <mn>2,3</mn> <mo>,</mo> <mo>.</mo> <mo>.</mo> <mo>.</mo> <mo>,</mo> <mi>H</mi> </mtd> </mtr> <mtr> <mtd> <mn>0</mn> <mo>,</mo> </mtd> <mtd> <mi>i</mi> <mo>=</mo> <mn>1</mn> </mtd> </mtr> </mtable> </mfenced> <mo>,</mo> </mrow> </math>
<math> <mrow> <msub> <mi>&beta;</mi> <mi>i</mi> </msub> <mo>=</mo> <mfrac> <mrow> <munderover> <mi>&Sigma;</mi> <mrow> <mi>j</mi> <mo>=</mo> <mn>1</mn> </mrow> <mi>W</mi> </munderover> <mi>g</mi> <mrow> <mo>(</mo> <mi>j</mi> <mo>)</mo> </mrow> </mrow> <mi>W</mi> </mfrac> <mo>,</mo> <mi>i</mi> <mo>=</mo> <mn>1,2</mn> <mo>,</mo> <mo>.</mo> <mo>.</mo> <mo>.</mo> <mo>,</mo> <mi>H</mi> <mo>,</mo> </mrow> </math>
wherein, <math> <mrow> <mi>f</mi> <mrow> <mo>(</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <mfenced open='{' close=''> <mtable> <mtr> <mtd> <mn>1</mn> <mo>,</mo> </mtd> <mtd> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>-</mo> <mn>1</mn> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mtd> </mtr> <mtr> <mtd> <mn>0</mn> <mo>,</mo> </mtd> <mtd> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>&NotEqual;</mo> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>-</mo> <mn>1</mn> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mtd> </mtr> </mtable> </mfenced> <mo>,</mo> <mi>g</mi> <mrow> <mo>(</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <mfenced open='{' close=''> <mtable> <mtr> <mtd> <mn>1</mn> <mo>,</mo> </mtd> <mtd> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <msup> <mi>P</mi> <mo>&prime;</mo> </msup> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mtd> </mtr> <mtr> <mtd> <mn>0</mn> <mo>,</mo> </mtd> <mtd> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>&NotEqual;</mo> <msup> <mi>P</mi> <mo>&prime;</mo> </msup> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mtd> </mtr> </mtable> </mfenced> <mo>;</mo> </mrow> </math> and when alpha isiiWhen 0, P (i +1, j) is 0.
3. The method as claimed in claim 2, wherein when there is no line 1 pixel information of the original JPG picture in the current header fragment, the line 1 pixel of the enlarged image of the original JPG picture thumbnail corresponding to the current header fragment is predicted as the line 1 pixel of the original JPG picture.
4. The method as claimed in claim 3, wherein the step 5 of selecting a non-head fragment in the non-head fragment set, of which the difference between the pixel value of the 1 st line and the pixel value of the 1 st line of the next fragment of the current head fragment predicted in the previous step is the smallest, as the next fragment of the current head fragment comprises:
calculating the difference C between the pixel value of the line 1 of the nth non-head fragment in the set of non-head fragments and the pixel value of the line 1 of the next fragment of the current head fragment predicted in step 4nWhere N is 0,1, …, N is the number of non-head fragments in the non-head fragment set, Qn(1, j) is the pixel value of the nth non-head fragment in the non-head fragment set at row 1 and column j, and P (i +1, j) is the pixel value of the next fragment at row 1 and column j of the current head fragment;
c is to be1,C2,…,CNThe non-head fragment corresponding to the smallest one of the head fragments is taken as the next fragment of the current head fragment.
5. The method as claimed in any one of claims 1 to 4, wherein the step of determining whether the file obtained by merging the current header fragment with the next fragment of the current header fragment is a complete JPG picture file in step 6 comprises:
determine whether the last two bytes of the file obtained after merging are 0xFFD 9? And if so, the file obtained after merging is a complete JPG picture file, otherwise, the file obtained after merging is not a complete JPG picture file.
6. A JPG picture fragment recombination device based on a thumbnail is characterized by comprising a fragment acquisition and storage module, a judgment module, a selection module, a prediction module, a matching module and a merging module;
the fragment acquiring and storing module is used for acquiring head fragments of the JPG picture from a storage medium to be restored according to the head signature of the JPG picture, forming a head fragment set for storage, and simultaneously acquiring non-head fragments of the JPG picture from the storage medium to be restored, forming a non-head fragment set for storage; the head fragment set and the non-head fragment set are provided for the judging module and the matching module, and the head fragment set is provided for the selecting module; in addition, the fragment acquiring and storing module is further configured to delete the next fragment of the current head fragment from the non-head fragment set according to the deletion request of the merging module, and resend the new non-head fragment set to the determining module and the matching module;
the judging module is used for judging whether the head fragment set or the non-head fragment set provided by the fragment acquiring and storing module is an empty set, and if not, informing the selecting module to select the head fragments;
the selection module is used for selecting one head fragment from the head fragment set provided by the fragment acquisition and storage module according to the head fragment selection notice sent by the judgment module and deleting the selected head fragment from the head fragment set; acquiring a thumbnail of an original JPG picture from a current head fragment, amplifying the thumbnail of the original JPG picture into a picture with the same size as the original JPG picture according to the size information of the original JPG picture recorded in the current head fragment, and providing the current head fragment and the enlarged image of the thumbnail of the original JPG picture for the prediction module;
the prediction module is configured to receive the current head fragment provided by the selection module or the merging module and the enlarged image of the thumbnail of the original JPG picture provided by the selection module, predict a picture pixel value of the line 1 of the next fragment of the current head fragment according to a pixel value of the line i of the original JPG picture recorded at the end portion of the sector where the current head fragment is located and a pixel value of the line (i +1) of the enlarged image of the thumbnail of the original JPG picture, and provide the current head fragment and the picture pixel value of the line 1 of the next fragment of the current head fragment to the matching module; wherein i is the number of rows of the original JPG picture recorded at the ending part of the sector where the current head fragment is located in the original JPG picture, i is a positive integer, i is more than or equal to 1 and less than or equal to H, and H is the height of the original JPG picture corresponding to the current head fragment;
the matching module is used for selecting a non-head fragment with the smallest difference between the pixel value of the 1 st line and the pixel value of the 1 st line of the next fragment of the current head fragment predicted by the prediction module from the non-head fragment set provided by the fragment acquisition and storage module as the next fragment of the current head fragment, and providing the next fragment of the current head fragment and the current head fragment sent by the prediction module to the merging module;
the merging module is configured to merge the current head fragment provided by the matching module with a next fragment of the current head fragment, and send a deletion request for deleting the next fragment of the current head fragment from the non-head fragment set to the fragment acquiring and storing module; in addition, the method is further used for outputting the complete JPG picture file obtained after merging, or replacing the current header fragment with the incomplete JPG picture file obtained after merging and providing the current header fragment after replacement to the prediction module.
7. The apparatus of claim 6, wherein the prediction module employs a weighted average of the pixel value P (i, j) of the ith row and jth column of the original JPG picture recorded at the end of the sector where the current header fragment is located and the pixel value P' (i +1, j) of the (i +1) th row and jth column of the enlarged image of the original JPG picture as the pixel value P (i +1, j) of the 1 st row and jth column of the next fragment of the current header fragment; j is more than or equal to 1 and less than or equal to W, j is a positive integer, and W is the width of the original JPG picture corresponding to the current head fragment; pixel valueP (i, j) has a weight of αiThe pixel value P' (i +1, j) is weighted by βi
<math> <mrow> <msub> <mi>&alpha;</mi> <mi>i</mi> </msub> <mo>=</mo> <mfenced open='{' close=''> <mtable> <mtr> <mtd> <mfrac> <mrow> <munderover> <mi>&Sigma;</mi> <mrow> <mi>j</mi> <mo>=</mo> <mn>1</mn> </mrow> <mi>W</mi> </munderover> <mi>f</mi> <mrow> <mo>(</mo> <mi>j</mi> <mo>)</mo> </mrow> </mrow> <mi>W</mi> </mfrac> <mo>,</mo> </mtd> <mtd> <mi>i</mi> <mo>=</mo> <mn>2,3</mn> <mo>,</mo> <mo>.</mo> <mo>.</mo> <mo>.</mo> <mo>,</mo> <mi>H</mi> </mtd> </mtr> <mtr> <mtd> <mn>0</mn> <mo>,</mo> </mtd> <mtd> <mi>i</mi> <mo>=</mo> <mn>1</mn> </mtd> </mtr> </mtable> </mfenced> <mo>,</mo> </mrow> </math>
<math> <mrow> <msub> <mi>&beta;</mi> <mi>i</mi> </msub> <mo>=</mo> <mfrac> <mrow> <munderover> <mi>&Sigma;</mi> <mrow> <mi>j</mi> <mo>=</mo> <mn>1</mn> </mrow> <mi>W</mi> </munderover> <mi>g</mi> <mrow> <mo>(</mo> <mi>j</mi> <mo>)</mo> </mrow> </mrow> <mi>W</mi> </mfrac> <mo>,</mo> <mi>i</mi> <mo>=</mo> <mn>1,2</mn> <mo>,</mo> <mo>.</mo> <mo>.</mo> <mo>.</mo> <mo>,</mo> <mi>H</mi> <mo>,</mo> </mrow> </math>
Wherein, <math> <mrow> <mi>f</mi> <mrow> <mo>(</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <mfenced open='{' close=''> <mtable> <mtr> <mtd> <mn>1</mn> <mo>,</mo> </mtd> <mtd> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>-</mo> <mn>1</mn> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mtd> </mtr> <mtr> <mtd> <mn>0</mn> <mo>,</mo> </mtd> <mtd> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>&NotEqual;</mo> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>-</mo> <mn>1</mn> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mtd> </mtr> </mtable> </mfenced> <mo>,</mo> <mi>g</mi> <mrow> <mo>(</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <mfenced open='{' close=''> <mtable> <mtr> <mtd> <mn>1</mn> <mo>,</mo> </mtd> <mtd> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>=</mo> <msup> <mi>P</mi> <mo>&prime;</mo> </msup> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mtd> </mtr> <mtr> <mtd> <mn>0</mn> <mo>,</mo> </mtd> <mtd> <mi>P</mi> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> <mo>&NotEqual;</mo> <msup> <mi>P</mi> <mo>&prime;</mo> </msup> <mrow> <mo>(</mo> <mi>i</mi> <mo>,</mo> <mi>j</mi> <mo>)</mo> </mrow> </mtd> </mtr> </mtable> </mfenced> <mo>;</mo> </mrow> </math> and when alpha isiiWhen the current header fragment does not have the line 1 pixel information of the original JPG picture, the prediction module adopts the line 1 pixel of the enlarged image of the thumbnail of the original JPG picture as the line 1 pixel of the original JPG picture.
8. The thumbnail-based JPG picture fragment reorganizing apparatus of claim 7, wherein the matching module calculates a difference C of pixel values of line 1 of an nth non-head fragment in the set of non-head fragments and pixel values of line 1 of a next fragment of a current head fragment predicted by the prediction modulenAnd C is1,C2,…,CNThe non-head fragment corresponding to the smallest one of the head fragments is taken as the next fragment of the current head fragment;
wherein,n=0,1,…, N, N is the number of non-head fragments in the non-head fragment set, Qn(1, j) is the pixel value of the nth non-head fragment in the non-head fragment set at row 1 and column j, and P (i +1, j) is the pixel value of the next fragment at row 1 and column j of the current head fragment.
CN201210277280.1A 2012-08-06 2012-08-06 Method and device for reassembling joint photographic experts group (JPG) picture fragments based on thumbnail Active CN102890818B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210277280.1A CN102890818B (en) 2012-08-06 2012-08-06 Method and device for reassembling joint photographic experts group (JPG) picture fragments based on thumbnail

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210277280.1A CN102890818B (en) 2012-08-06 2012-08-06 Method and device for reassembling joint photographic experts group (JPG) picture fragments based on thumbnail

Publications (2)

Publication Number Publication Date
CN102890818A CN102890818A (en) 2013-01-23
CN102890818B true CN102890818B (en) 2015-06-17

Family

ID=47534312

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210277280.1A Active CN102890818B (en) 2012-08-06 2012-08-06 Method and device for reassembling joint photographic experts group (JPG) picture fragments based on thumbnail

Country Status (1)

Country Link
CN (1) CN102890818B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3093851B1 (en) * 2015-05-11 2017-11-08 Micro Systemation AB Method and device for use when reassembling a fragmented jpeg image
CN105068885B (en) * 2015-07-27 2018-02-27 四川效率源信息安全技术股份有限公司 A kind of JPG fragments file access pattern and the method for restructuring
CN107132959A (en) * 2016-02-29 2017-09-05 四川效率源信息安全技术股份有限公司 A kind of wrong method of quick amendment fragment picture restructuring result
CN109584163B (en) * 2018-12-17 2020-12-08 深圳市华星光电半导体显示技术有限公司 Method for restoring original file of paper scrap
CN111223154B (en) * 2019-11-20 2022-12-06 厦门市美亚柏科信息股份有限公司 JPG picture fragment recombination method, terminal equipment and storage medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1617568A (en) * 1999-12-20 2005-05-18 宾杰·威布股份株式会社 Compressing and restoring method of image data

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1617568A (en) * 1999-12-20 2005-05-18 宾杰·威布股份株式会社 Compressing and restoring method of image data

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
Automated Reassembly of File Fragmented Images Using Greedy Algorithms;Nasir Memon;《IEEE TRANSACTIONS ON IMAGE PROCESSING》;20060228;第15卷(第2期);385-393 *
File Fragment Classification—The Case for Specialized Approaches;Vassil Roussev;《2009 Fourth IEEE International Workshop on Systematic Approaches to Digital Forensic Engineering》;20090531;3-14 *
基于差异度的JPEG碎片重组方法;肖 腾;《计算机工程》;20110531;第37卷(第10期);263-265 *

Also Published As

Publication number Publication date
CN102890818A (en) 2013-01-23

Similar Documents

Publication Publication Date Title
CN102890818B (en) Method and device for reassembling joint photographic experts group (JPG) picture fragments based on thumbnail
CN102236693B (en) Method and device for determining similarity between documents
US10346517B2 (en) Application above-the-fold rendering measurements
KR101456757B1 (en) Method and Apparatus for recovering deleted data for SQLite database
JP5394598B2 (en) Medical image compression apparatus, medical image compression method, and prediction knowledge database creation apparatus
CN109412755B (en) Multimedia data processing method, device and storage medium
US8156414B2 (en) String reconstruction using multiple strings
CN101842811B (en) System and method for predicting the file size of an image transformed by scaling and changing quality control parameters
CN103795418B (en) A kind of lossless compression method of road network track
CN106231356A (en) The treating method and apparatus of video
JP6229067B2 (en) Data access method and apparatus
WO2021068891A1 (en) Method, system, electronic device, and storage medium for storing and collecting temperature data
CN105447808A (en) Reversible data hiding method and recovering method
CN102509257B (en) Human visual characteristic compressive sensing-based grayscale image tampering and detection method
US20080001946A1 (en) Apparatus for and method of displaying image
CN113158831A (en) Method and device for detecting movement of camera equipment, computer equipment and storage medium
CN105163122B (en) A kind of compression of images and decompression method based on image block similarity
CN104718706B (en) The method and system of format identification for segmented image data
Hadi Reviewing and evaluating existing file carving techniques for jpeg files
Cohen Advanced JPEG carving
CN104732508B (en) Based on the image interfusion method that distributed compression is perceived
CN104242947A (en) SAMP reconstructing method based on Haar wavelet tree
CN103440616B (en) High volume reversible watermarking method based on self-adaptive prediction model
US20140214781A1 (en) Data compression device, data compression method, and computer program product
Billard et al. Making sense of unstructured flash-memory dumps

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant