(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.2' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 5615, 184]*) (*NotebookOutlinePosition[ 6381, 210]*) (* CellTagsIndexPosition[ 6337, 206]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Huffman Codes", "Title"], Cell["\<\ Wavelet Workshop June 6-9, 2007 University of St. Thomas\ \>", "Subtitle"], Cell["Objectives", "Subsubtitle"], Cell["\<\ The purpose of this notebook is to give allow you to become familiar with the \ qualitative/quantitative measures cumulative energy, peak \ signal-to-noise-ratio, and entropy. We will also write our first module in \ this notebook\ \>", "Text"], Cell[CellGroupData[{ Cell["DiscreteWavelets", "Subsubtitle"], Cell[TextData[{ StyleBox["You should run this cell each time you open this notebook!!", FontColor->RGBColor[1, 0, 0]], " It loads the ", StyleBox["Mathematica", FontSlant->"Italic"], " package ", StyleBox["WaveletFunctions", FontFamily->"Courier"], " for use in subsequent computations." }], "Text"], Cell[BoxData[ \(<< DiscreteWavelets`DiscreteWavelets`\)], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["Help on DiscreteWavelets", "Subsubtitle"], Cell[TextData[{ "If you ever need help with ", StyleBox["DiscreteWavelets", FontFamily->"Courier"], ", go to ", StyleBox["Help", FontSlant->"Italic"], ", then ", StyleBox["Help Browser", FontSlant->"Italic"], ", and click on ", StyleBox["AddOns & Links", FontSlant->"Italic"], ". If you scroll down you will find ", StyleBox["DiscreteWavelets", FontFamily->"Courier"], ". " }], "Text"], Cell[CellGroupData[{ Cell["Computing Huffman Codes", "Section"], Cell[TextData[{ StyleBox["DiscreteWavelets", FontFamily->"Courier"], " has a routine called ", StyleBox["MakeHuffmanCodes", FontWeight->"Bold"], " that takes as input a vector of positive integers, a matrix of positive \ integers, or a string, and returns the Huffman codes for the input. \ Actually, the routine returns the codes, the original bitstream length, and \ the new bitstream length. Let's look at an example call.\n" }], "Text"], Cell[BoxData[{ \(\(str = "\";\)\), "\[IndentingNewLine]", \({codes, oldlen, \ newlen} = MakeHuffmanCodes[str]\)}], "Input"], Cell["\<\ Notice that the codes list consists of triples. The first element of each \ triple is the character (or integer) encoded, the second element is the \ relative frequency for the string or integer, and the third element is the \ Huffman code.\ \>", "Text"], Cell[BoxData[{ \(v = Table[Random[Integer, {0, 20}], {10}]\), "\[IndentingNewLine]", \({codes, oldlen, \ newlen} = MakeHuffmanCodes[str]\)}], "Input"], Cell[BoxData[{ \(\(gray = ImageNames[ImageType \[Rule] GrayScale, ListThumbnails \[Rule] True];\)\), "\[IndentingNewLine]", \(\(A = ImageRead[gray[\([3]\)]];\)\), "\[IndentingNewLine]", \(\({codes, oldlen, newlen} = MakeHuffmanCodes[A];\)\), "\[IndentingNewLine]", \(\(Print["\", oldlen, "\< and the new bitstream length is \>", newlen, "\<.\>"];\)\)}], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["Huffman Trees", "Section"], Cell[TextData[{ "There is a function in ", StyleBox["DiscreteWavelets", FontFamily->"Courier"], " that allows you to display the Huffman tree for Huffman codes. The \ routine is called HuffmanTree. The command is called ", StyleBox["Entropy", FontWeight->"Bold"], " and it takes as input either a vector or a matrix. Here are some example \ calls." }], "Text"], Cell[BoxData[{ \(<< DiscreteWavelets`DiscreteWavelets`\), "\[IndentingNewLine]", \(str = "\"\), "\[IndentingNewLine]", \(\({codes, oldlen, newlen} = MakeHuffmanCodes["\"];\)\), "\[IndentingNewLine]", \(HuffmanTree[codes]\)}], "Input"], Cell["This routine is not intended for use with large data sets!!", "Text"] }, Open ]] }, Open ]] }, Open ]] }, FrontEndVersion->"5.2 for Microsoft Windows", ScreenRectangle->{{0, 1024}, {0, 692}}, AutoGeneratedPackage->None, ScreenStyleEnvironment->"Presentation", WindowSize->{1016, 651}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, ShowSelection->True, StyleDefinitions -> "Report.nb" ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1776, 53, 30, 0, 117, "Title"], Cell[1809, 55, 84, 4, 143, "Subtitle"], Cell[1896, 61, 33, 0, 67, "Subsubtitle"], Cell[1932, 63, 255, 5, 62, "Text"], Cell[CellGroupData[{ Cell[2212, 72, 39, 0, 67, "Subsubtitle"], Cell[2254, 74, 323, 10, 63, "Text"], Cell[2580, 86, 70, 1, 51, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[2687, 92, 47, 0, 67, "Subsubtitle"], Cell[2737, 94, 429, 17, 64, "Text"], Cell[CellGroupData[{ Cell[3191, 115, 42, 0, 96, "Section"], Cell[3236, 117, 458, 10, 107, "Text"], Cell[3697, 129, 146, 2, 77, "Input"], Cell[3846, 133, 265, 5, 62, "Text"], Cell[4114, 140, 159, 2, 77, "Input"], Cell[4276, 144, 470, 9, 155, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[4783, 158, 32, 0, 96, "Section"], Cell[4818, 160, 381, 10, 85, "Text"], Cell[5202, 172, 295, 5, 129, "Input"], Cell[5500, 179, 75, 0, 40, "Text"] }, Open ]] }, Open ]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)