Mathcad 11.2A Work Sheet Running on PC
Total Page:16
File Type:pdf, Size:1020Kb
Why this document ? ... Because : Things and life today are very highly technical and scientific. Explanations may be rare or out of reach or too empirical. Words are insufficient to "print thechnical facts in mind" Acquiring knowledge is a maturation (brewing) process. Science is not inductive, rather it is coalescent. "Dans le domaine de la science, le hasard ne favorise que les esprits qui ont été préparés" PASTEUR JPEG/MPEG Forensic knowledge base in the Court Room This document is a JPEG/MPEG "knowledge base primer" demo. It is a Mathcad 11.2a work sheet running on PC. No maths are needed as the demonstration is by images. It is presented in the general context of the admissibility of JPEG/MPEG as circumstantial proof, rather to the inadmissibilty a priori. The Fourier part (DFT, IDFT) is not arguable. The relative reliability of the JPEG/MPEG extracted from mass storage is to be submitted to experts in respect to all the technical parts of the chain. An exhaustive analysis may not be possible because each system is protected by Patent Rights (proprietary information). Therefore, this report is a guideline based on the principles and exposed as such for Judge and Counsel. Two extreme JPEG demos have been chosen for purpose. They both represent geometric forms. Example (1) is reconstructible from educated guesses, Example (2) is also geometric but totally destroyed ... So, nuance means nuance an eternal word that didn't change meaning over time. Please, read attentively... this report is personal for public use and understanding, addressing the Court Room especially. At the end of this document you must read more and navigate http://en.wikipedia.org/wiki/JPEG http://en.wikipedia.org/wiki/Wavelet The word wavelet is due to Morlet and Grossmann in the early 1980s. They used the French word ondelette , meaning "small wave". Soon it was transferred to English by translating "onde" into "wave", giving " wavelet ". The Morlet wavelet is arguably the `original' wavelet. Although the discrete Haar wavelets predate Morlet's, it was only as a consequence of Morlet's work that the mathematical foundations of wavelets as a better formulation of time-frequency methods were laid. Conceptually related to windowed-Fourier analysis, the Morlet wavelet is a locally periodic wavetrain. It is obtained by taking a complex sine wave, and by localizing it with a Gaussian (bell-shaped) envelope ..... _________________________________ Fourier: Born: 21 March 1768 in Auxerre, Bourgogne, France Died: 16 May 1830 in Paris As the natural ideas of equality developed it was possible to conceive the sublime hope of establishing among us a free government exempt from kings and priests, and to free from this double yoke the long-usurped soil of Europe. Joseph Fourier Extrapolate "Fourier natural idea": "concieve/conclude the sublime hope for justice from reasoning supported by science" ? _________________________________ What is Fourier transform ? ( jmG ) It is an approximation method (one among many more). It decomposes a function into its two trigonometric real or complex components (sinus, cosinus). There are two forms: 1. the analytical form which transforms the continuous time domain into the frquency domain 2. the discrete form for vector of values. It transforms discrete values into the spectral compositon (harmonic analysis) ... composition meaning sine/cosine components. The discrete form is universally named DFT (Discrete Fourier Transform). The "Fourier transform is maths" as such it belongs to all fields of Science, Physics, Engineering. The DFT is to advanced science and technologies what alphabet is to a language. Once in hand the DFT of some "original", very many educated manipulations can be applied for purpose, then "reverse engineered" by the IDFT (Inverse Discrete Fourier Transform), thus reconstructing a "modified original". Signal processing and Image processing would not exist without DFT/IDFT The discrete cosine transform is the core algorithm for the JPEG image. Below, L is the bitmap (pixels) image matrix of Lena (the lady). We demonstrate the decomposition into the discrete cosine values, where the components of the highest values populate and we reconstruct the image to a degree of accuracy about equivalent to 12 decimals (so to speak for popular understanding). This is an introduction demo to the JPEG compression Part I: Image structure, compression is an unrecoverable destruction L := L:= submatrix() L, 0 , 255 , 0 , 254 0 1 2 Ldct:= dct2d() L max() Ldct 25202 0 137 136 133 = 1 137 136 133 Lrec:= idct2d() Ldct min() Ldct −3292 The scaled recovered Lena is scale() Lrec , 0 , 255 not shown as it is the exact replicate to ± 12 d L scale() Ldct −, 3300 , 25000 The discrete cosine transform (DCT) is an important and widely used analysis tool in signal and image processing. The DCT is particularly valuable for coding and data compression applications, and it forms the core of the JPEG and MPEG algorithms for image compression. Like the discrete Fourier transform (DFT), the DCT defines an orthogonal transformation which maps a signal from the time domain to the frequency domain. However, the DCT is a real-valued transform, and does not involve complex numbers. The DFT is a complex-valued transform. For a comprehensive discussion of the DCT and applications involving the DCT, refer to the book by K. R. Rao and P. Yip. We can verify the energy-compaction property of the DCT by looking at histograms of the transformed and original images, as follows: The transformed image concentrates most of the energy in the first H:= imhist() Ldct , 256 few bins of the histogram, while the distribution of the original image is spread out. This makes the transformed image a better candidate Horig:= imhist() L, 256 for encoding or transmission, since most of the image information can be relayed with very few frequency components. For this reason k := 0 .. rows() H − 1 the DCT is used for image compression. Comparing spectral histogram 4000 Horig k H k 2000 0 0 50 100 150 200 250 300 k original spectral spread DCT spectral concentration Notes • The sine transform, ST, and cosine transform, CT, of a sequence x of length N are defined as follows j j ST j = sin π⋅i⋅ ⋅xi CT j = cos π⋅i⋅ ⋅xi ∑ N ∑ N i i • The sine transform always has first coordinate 0, so the inverse sine transform cannot recover the first element of the input x. The cosine transform contains enough information to reconstruct the original vector x completely. Much of the information in an image can be stored in a smaller space by cosine transforming, then retaining only the coefficients which store most of the image informaiton. To do this, take a two-dimensional cosine transform by first transforming columns and transposing the result, then repeating the procedure. Example 1 ()n i j p c := ()23 0 .. n 0 .. n 5 12 n, i, j define a 24 x 24 array not yet filled with values (n = odd) ... c, is a center pixel bordered Define the aperture each side square by 'p' pixels, these 'p' "border pixels" are made white by the logical definition Ai, j := (i− c < p )⋅() j− c < p of the A matrix ... Typical Mathcad compaction ! Matix A has levels 1/0 for 3D patch and bar plot 〈〉i 〈〉i T The C1, C2, C3, C4 are the two-dimensional C1 := costr() A C2:= C1 cosine transform by first transforming columns 〈〉i 〈〉i T and transposing the result, then repeating the C3 := costr() C2 C4:= C3 procedure. A -------is a 3D patch plot, C4 a bar plot As ------is the 0,255 picture pixels C4s -----is the 0,255 picture pixels For better view of C4s, it as been magnified. It is not a picture, just a captured image of specifications: ()23 0 .. n 0 .. n 4 12 Note: to reproduce the black/white 1/0 of the Patch plot Bar plot 3D patch plot we scale the picture pixel 0..255 A C4 As:= scale() A , 0 , 255 "A" at left is Quite a different image than Lena ! C4s:= scale() C4 , 0 , 255 Still it is easy to see the concentration of information. At this point, we could reduce in two ways the volume of "bytes" to store/export an image: 1. ignore the lower diagonal As C4s 2. scaling has reduced the magnitude of the numbers thus reduced the "bytes size". How image compression works ? By running a 10 tons truck over Lena ... NO ! We filter the uncentered transform with a mask that is nonzero on the 'p' border of the original transform area. With 'p' = 4 we've thus compressed the image content by a factor of about 3. (Of course this isn't true compression, since we're saving the remaining values to high precision; in a real compression scheme we'd quantize these values somehow.) We'll reconstruct the image from the masked transform by using the inverse cosine transform. p := 4 p = 4 First we define a Boolean OR function: OR( a, b ):= if() a+ b , 1 , 0 Mask i, j := OR() i< p , j< p The mask saves only transform values near the upper and left edges of the uncentered transform. Now we'll apply the mask element by element to the transform using the vectorize operator, and then reconstruct the image from the masked transform and compare it with the original image A. → T 〈〉i 〈〉i C4:= Mask⋅ C4 C5:= C4 C6 := icostr() C5 T 〈〉i 〈〉i C7:= C6 C8 := icostr() C7 The cosine transform is the core algorithm for the JPEG image compression standard. Here images and their subsets are compressed by discarding the higher order coefficients of the cosine transform, and decompressed using the inverse cosine transform, as in the example above.