SlideShare a Scribd company logo
1 of 23
Enhanced Image Manipulation Library for UNIX
By: Matthew Weingarten (8189-1861)
CIS 4914 Senior Project
Advisor: Mark Schmalz
Advisor’s email: mssz@cise.ufl.edu
Date of talk: 12/8/15
Weingarten 1
Table of Contents
1. Abstract………………………………………………………………………………2
2. Introduction…………………………………………………………………………..3
3. Problem Domain……………………………………………………………………...5
4. Literature Search……………………………………………………………………...6
5. Solution……………………………………………………………………………….7
6. Results………………………………………………………………………………...9
7. Conclusions…………………………………………………………………………...11
8. Acknowledgements…………………………………………………………………...12
9. References…………………………………………………………………………….13
10. Appendices……………………………………………………………………………14
11. Biography……………………………………………………………………………..22
Weingarten 2
Abstract
The increase in technology during the last decade has brought an increased need for
methods and tools to analyze, compare, and manipulate images. UNIX-Based Image Analyst
(UIA), a command-line image manipulation library developed by University of Florida students,
provides a framework for doing this. Existing functionality in the library can be improved while
new operations can be added. The author’s work has added new operations, most notably the
Walsh-Hadamard transform, and made past ones more efficient. The author has learned about the
statistical and mathematical techniques involved in the image manipulation process.
Weingarten 3
Introduction
Problem Statement
Image analysis has become an increasing field of research in the past several decades as a
result of the growth of processor technology for working with large file sizes. With technology’s
current reliance on data, it has become more important than ever to be able to manipulate and
analyze images.
Most image analysis is performed with GUI frameworks that are expensive and difficult
to work with. Developers favor simplicity whenever possible, so it seems natural to be able to
perform image analysis on the command line.
Background
UNIX-Based Image Analyst (UIA) is a UNIX library dedicated to performing image
analysis on the command line and is the result of past Senior Projects at the University of Florida.
Dmitriy Bernsteyn, Suzanne Curry, Craig Holmquist, and Robert Pollock have all contributed to
UIA in the past. Their work has provided a foundation on which to implement additional
operations while enhancing past functionality.
Working with UIA is rather simple. The user specifies an operation and the arguments
necessary to run that operation, and then the system performs that corresponding manipulation
and displays its output. Operations that can be performed include:
 Arithmetic conversion routines (adding/subtracting/multiplying/dividing two
images, taking the sine/logarithm of an image, and more) that produce a new
image
 Statistical operations such as the root-mean-square error (RMSE) that are either
performed on a whole image or a part of the image
Not all of the library’s functionality is native. ImageMagick is a tool that is pre-installed
on many Ubuntu systems and allows a developer to convert images to Portable Graymap Format
(PGM) as well as display images in a convenient manner. UIA is written in C and kept under
ANSI-C standards so that it is portable to as many UNIX systems as possible.
Solution
UIA has a lot of operations available, but it is not complete. Additional functionality,
such as the Walsh-Hadamard transform, can be added to the system. Previously developed
Weingarten 4
operations can be enhanced to work with larger image sizes and can be documented in a more
practicable manner so that it is more understandable to a first-time reader. Since it is only
worked on every few years or so, UIA was brought up to existing standards with the newest
UNIX and ImageMagick releases.
Contribution
The author’s contribution to UIA would not be possible if it were not for the past work of
Bernsteyn, Curry, Holmquist, and Pollock. Existing utilities in UNIX assist the author in
converting between image formats and displaying the images in a proper manner.
Weingarten 5
Problem Domain
Image manipulation is a component of the computer graphics field of computer science.
Most of its work is heavily rooted in statistical theorems and operations. Image manipulation has
a wide variety of applications, including but not limited to journalism, medicine, meteorology,
and video conferencing.
Weingarten 6
Literature Search
Since UIA depends on outside libraries to perform some of its basic tasks, the
documentation of those resources was vital. This is especially the case in this project as a result
of some of the code becoming deprecated over the time that has elapsed between the author’s
work and UIA’s previous versions. ImageMagick’s convert utility [4] was used to convert
images to PGM format. The utility was also used to convert images back to their original format,
which was very useful for transporting the images between different operating systems.
convert also was used for any image resizing that needed to be done. ImageMagick’s
display utility [4] was used to display images that UIA produced, while its compose utility
[4] was used to add and subtract images. ImageMagick’s documentation of these commands was
essential in its proper use in the context of the project.
Wikipedia’s article on the Walsh-Hadamard transform (WHT) [3] was essential in setting
up the calculations for the Hadamard matrix. The examples it provided were useful in getting
that portion of the code up and running.
MathWorks’ documentation on the hadamard function as well as the fwht (fast
WHT) function [2] were essential in having the author’s implementation of the WHT run like the
one that currently exists in MATLAB. There are a few minor differences between the WHT that
exists in common literature, such as Wikipedia [3], and the one that exists in MATLAB. As it
was the author’s original intent to have his C code perform like MATLAB’s existing functions,
MathWorks’ documentation was very useful in making the necessary changes to achieve that
purpose.
The remaining references [1, 5, 6, 7, and 8] were imperative to get a basic understanding
of the WHT and how it relates to image processing. Examples were provided by these sources to
visually represent how the WHT manipulates an image. Without these examples, the author
would never have been able to know whether his implementation was performing correctly or
not.
Weingarten 7
Solution
The main addition that the author made to UIA was the WHT, which is a generalized
form of a Fourier transform. It performs a series of size-2 discrete Fourier transforms (DFTs) on
an image. The algorithm uses a divide-and-conquer approach that runs in 𝑂(𝑛𝑙𝑜𝑔(𝑛)) time.
Before the transform is run on an image, preliminary steps need to be performed. First,
the number of columns in the image have to be padded to the next power of two. This is a
requirement for the WHT to run properly. This can be done as follows:
𝑁𝑃2( 𝑑𝑎𝑡𝑎) = 2^(⌈log2( 𝑑𝑎𝑡𝑎)⌉)
This formula computes the log base 2 of the number of columns, takes the ceiling of that
to convert it to the next largest integer, and then raises 2 to that exponent in order to either keep
the same number of columns (if it’s already a power of 2), or increase it to the next largest power
of 2 (if it’s not a power of 2).
Since this might add pixels to the image that were not there before, those pixels have to
be zeroed so that they will be compatible with the algorithm. After this step has been performed,
the WHT is run on each row of the image matrix. This is possible because the WHT, just like
most DFTs, exhibits the principle of separability, meaning that running multiple transformations
across one dimension will have the net effect of running the transformation over all image
dimensions.
For any given row, the WHT begins by generating the corresponding Hadamard matrix
for that row. The Hadamard matrix is used for scaling an image. The way it runs is as follows:
INPUT: n, which represents log2(𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑐𝑜𝑙𝑢𝑚𝑛𝑠)
OUTPUT: hadamardMatrix
IF n := 1
hadamardMatrix := (
. 5 . 5
. 5 −.5
)
ELSE
hadamardMatrix :=
1
2
(
ℎ𝑎𝑑𝑎𝑚𝑎𝑟𝑑(𝑛 − 1) ℎ𝑎𝑑𝑎𝑚𝑎𝑟𝑑(𝑛 − 1)
ℎ𝑎𝑑𝑎𝑚𝑎𝑟𝑑(𝑛 − 1) −ℎ𝑎𝑑𝑎𝑚𝑎𝑟𝑑(𝑛 − 1)
)
While common literature, such as Wikipedia, has slight changes in the numbers and
scaling factor used in the algorithm, this specific implementation is consistent with how
Weingarten 8
MATLAB runs its fwht function. After the Hadamard matrix is generated, the row vector is
multiplied by this matrix to scale it into a new image. When all of the rows are transformed, the
image is normalized to grayscale and ImageMagick’s display utility is used to display the
image, similar to how it was used with UIA’s fft routine.
In addition to the basic WHT algorithm, error analysis was performed to compare the
performance of the author’s WHT implementation with that of MATLAB. In order to do this, the
computed image first has to be converted from a double array to a nearest integer array due to the
PGM format and its unsigned char representation for array elements, which trims off any
numbers beyond the decimal point. An error image was then calculated as the difference between
the author’s output and that of MATLAB. After this is calculated, the following two measures
are generated:
 Mean of the error values (𝑚𝑒𝑎𝑛 =
∑ 𝑒𝑖
𝑛
𝑖=1
𝑛
, where 𝑒𝑖 represents the error value at
pixel i)
 RMSE of the error values (𝑅𝑀𝑆𝐸 = √
1
𝑛
∑ (𝑒𝑖 − 𝑚𝑒𝑎𝑛)2𝑛
𝑖=1 )
The RMSE was used to assist the author in modifying his WHT implementation until its
error was at most equal to the error naturally inherent in an image, which is defined as
(
1
2
) 𝑏𝑖𝑡𝑠 𝑝𝑒𝑟 𝑝𝑖𝑥𝑒𝑙
. The author extended this error analysis by performing it on segments of the
image in order to better identify any sources of error. The segment size was calculated based on
the number of segments that the user specified. This code is provided in Appendix A.
Additionally, the author wrote a Markdown file that would better explain to a first-time
reader the purpose of UIA and how each operation in the library works. Comments dealing with
UIA’s code before the author’s work were added and enhanced to make the code more
understandable and readable to those not affiliated with UIA. More error checking was added as
well. Furthermore, UIA’s deprecated code was updated to work with the most current releases of
UNIX and ImageMagick.
Weingarten 9
Results
The results presented in this section will be based on the following test image:
Figure 1: The test image used for WHT analysis.
UIA is executed on this image using the wht opcode and the image “surfing10a.gif.”
The output of the transformation is the following image:
Figure 2: The output image generated by UIA’s new wht routine.
Compare this with MATLAB’s output image from its fwht routine:
Figure 3: The output image generated by MATLAB’s fwht routine.
These images are the same, which can be verified by running whtrmse with the
original image and MATLAB’s output image. The mean and RMSE for the difference image are
reported as 0.000 and 0.000, respectively. The same result applies to each segment (the author
used 4 segments here) of the image. As these errors are less than the threshold value for eight-bit
Weingarten 10
pixel values encoding (
1
256
), the author’s WHT implementation performs as intended. Additional
test results on different images are provided in Appendix B.
There are some intricacies involved in achieving zero error. First, the MATLAB script
that runs fhwt has to run on a PGM of the input image, which can be done with an online
image converter. Then, the MATLAB output image has to be saved in PGM format, which is an
option with MATLAB’s imwrite operation. Converting between different image formats
within UIA actually introduces error into the difference image, but as long as the image is saved
as a PGM and the MATLAB script is run on a PGM image, then the mean and RMSE of the
error values will be zero.
Before the project began, there was no outside documentation for a first-time reader to
become acquainted with UIA. Compare that to the Markdown file generated by the author, an
excerpt of which is presented below:
Figure 4: An excerpt from UIA’s new Markdown file.
This makes the library’s functionality more understandable to readers who are not as
familiar with the various image manipulation techniques. By lowering the amount of time
required for someone to become familiar with the system, future participants will be able to get
started with UIA in a shorter amount of time.
Weingarten 11
Conclusions
The author added the WHT to UIA as its major enhancement, as well as documentation
for first-time readers, error-checking, and the repairing of deprecated code. Throughout the
course of this implementation, the author learned a great amount about image manipulation,
working with the command-line, proper documentation, and working with large datasets.
There were a few intricacies with the author’s implementation. For one, using the PGM
format requires rounding the image’s double array into a nearest integer array because of its
unsigned char element representation. Additionally, the MATLAB output image has to be saved
in PGM format in order for the mean and RMSE of the difference image to be 0.
The addition of the WHT to UIA provides new opportunities for image analysis. In future
projects, even more operations, building on the WHT as well as being separate, can be added to
UIA to make the library even more extensive. After the library is more complete, it can hopefully
be open-sourced so that the masses can use this tool for image analysis as well as add image
manipulations of their own.
There are a few existing bugs in UIA that were never documented before this project.
Due to a lack of expertise in the subject area, the author was not able to fix those bugs. A bug log
has been added for future projects so that future students who choose to work on UIA can
identify existing issues in an effort to make it error-free.
Weingarten 12
Acknowledgements
Even though this project was an individual undertaking, there are a lot of people the
author needs to thank for getting this far. First, the author would like to thank Dr. Mark Schmalz,
his advisor for this project as well as a friend he can gladly say he got to know over the past few
months. The author would also like to thank Dmitriy Bernsteyn, Suzanne Curry, Craig
Holmquist, and Robert Pollock for their contributions to UIA and the documentation they
provided so that it was understandable when he first began the project. The author would also
like to thank his friends, at the University of Florida and elsewhere, for teaching him new things
along his life’s journey so far. Life would be incomplete without them.
Lastly, but most importantly, the author would like to thank his family. His parents, his
sister, his grandparents, and all his relatives have been extremely supportive, from his childhood
all the way to this current day. And now, his life is really starting, but he could not have written
this paper without their support. He wishes to thank them for everything they’ve done. Words
cannot express how much he is thankful for.
Weingarten 13
References
[1] "ANSI-C." Wikipedia. Wikimedia Foundation. Web. 7 Sept. 2015.
<https://en.wikipedia.org/wiki/ANSI_C>.
[2] "Fast Walsh-Hadamard Transform." MathWorks. MathWorks. Web. 15 Oct. 2015.
<http://www.mathworks.com/help/signal/ref/fwht.html>.
[3] "Hadamard Transform." Wikipedia. Wikimedia Foundation. Web. 7 Sept. 2015.
[4] "Home." ImageMagick: Convert, Edit, Or Compose Bitmap Images. ImageMagick Studio
LLC. Web. 24 Sept. 2015. <http://imagemagick.org/script/index.php>.
[5] Johnson, Jeremy. "Lecture 4: Walsh-Hadamard Transform Algorithms." Jeremy Johnson.
Jeremy Johnson, 5 Feb. 2004. Web. 7 Sept. 2015.
<https://www.cs.drexel.edu/~jjohnson/wi04/cs680/lectures/wht.html>.
[6] "Walsh-Hadamard Transform." MathWorks. MathWorks. Web. 15 Oct. 2015.
[7] "The Hadamard Transform." Neuron. Web. 8 Oct. 2015. <http://neuron-
ai.tuke.sk/hudecm/science/7/7.html>.
[8] "What Is the Walsh-Hadamard Transform and What Is It Good For?" Stack Exchange. 12
Mar. 2012. Web. 7 Sept. 2015. <http://dsp.stackexchange.com/questions/1693/what-is-the-
walsh-hadamard-transform-and-what-is-it-good-for>.
Weingarten 14
Appendices
Appendix A
This appendix is used to document, in full detail, the author’s WHT implementation.
int outCols; //columns after padding
double* img2;
double** hadamard (int n)
{
//uses a divide and conquer approach to compute the Hadamard matrix
based on the number of iterations the user needs for their vector
if(n == 1) //base case, default Hadamard matrix is [.5 .5 .5 -.5]
{
double** result = malloc(2 * sizeof(double*)); //allocate space
int i;
for(i = 0; i < 2; i++)
{
result[i] = malloc(2 * sizeof(double)); //allocate space
}
result[0][0] = .5;
result[0][1] = .5;
result[1][0] = .5;
result[1][1] = -.5;
return result;
}
else //recursive case
{
double** result = malloc((1<<n) * sizeof(double *)); //allocate
space
int i;
for(i = 0; i < (1<<n); i++)
{
result[i] = malloc((1<<n) * sizeof(double)); //allocate
space
Weingarten 15
}
double** result2 = malloc((1<<(n-1)) * sizeof(double*));
//allocate space for previous computation
for(i = 0; i < 1<<(n-1); i++)
{
result2[i] = malloc((1<<(n-1)) * sizeof(double));
//allocate space for previous computation
}
result2 = hadamard(n - 1); //recursion
int j;
for(i = 0; i < (1<<(n-1)); i++) //top left corner
{
for(j = 0; j < (1<<(n-1)); j++)
{
result[i][j] = result2[i][j] * .5;
}
}
for(i = (1<<(n-1)); i < (1<<n); i++) //top right corner
{
for(j = 0; j < (1<<(n-1)); j++)
{
result[i][j] = result2[i - (1<<(n-1))][j] * .5;
}
}
for(i = 0; i < (1<<(n-1)); i++) //bottom left corner
{
for(j = (1<<(n-1)); j < (1<<n); j++)
{
result[i][j] = result2[i][j - (1<<(n-1))] * .5;
}
}
for(i = (1<<(n-1)); i < (1<<n); i++) //bottom right corner, need
to invert entries
{
Weingarten 16
for(j = (1<<(n-1)); j < (1<<n); j++)
{
result[i][j] = result2[i - (1<<(n-1))][j - (1<<(n-1))]
* -.5; //invert
}
}
return result;
}
}
void hadamardTransform(double* data, int n)
{
//gets Hadamard matrix, multiplies it by data vector, and then sets
data vector to that result
//uses the MATLAB definition of fwht for doing the transform
//note that their definition is different than the definition used in
common literature
double** hadamard1 = malloc(n * sizeof(double*)); //allocate space for
Hadamard matrix
int i;
for(i = 0; i < n; i++)
{
hadamard1[i] = malloc(n * sizeof(double)); //allocate space for
Hadamard matrix
}
double* result = malloc(n * sizeof(double));
hadamard1 = hadamard(LN2(n)); //get result
result = multiply(data, hadamard1, n); //multiply matrices
for(i = 0; i < n; i++)
{
data[i] = result[i];
}
}
void img_wht(int rows, int cols, double *img)
{
outCols = NEXT_P2(cols); //computes next power of 2
Weingarten 17
int size = rows * outCols * sizeof(double);
double* imgA = malloc(size);
int i;
for(i = 0; i < rows; i++)
{
realToDouble2(img + (cols * i), cols, imgA + (i * outCols), outCols);
//zeros padded entries of array for each row
}
for(i = 0; i < rows; i++) //apply Hadamard transform to each row
{
hadamardTransform(imgA + (i * outCols), outCols);
}
displayWHTImage(imgA, rows, outCols); //display result
img2 = malloc((rows*outCols) * sizeof(double));
for(i = 0; i < rows*outCols; i++) //copies values over for img_wht_rmse
{
img2[i] = imgA[i];
}
}
void rmseCalculations(double* error, int rows, int cols)
{
//calculate mean and RMSE of error values for a given error matrix
int i;
double sum = 0.0;
for(i = 0; i < rows * cols; i++) //computes sums of error values
{
sum += error[i];
}
double mean = sum / (rows * cols); //takes the average of all the error
values
printf("Mean of error values: %.3fn", mean);
double variance = 0.0;
for(i = 0; i < rows * cols; i++)
{
Weingarten 18
variance += pow((error[i] - mean), 2.0); //calculates the
variance of the error values
}
double rmse = sqrt(variance) / sqrt(rows * cols); //calculates the RMSE
of the error values
printf("RMSE of error values: %.3fn", rmse);
}
void img_wht_rmse(int rows, int cols, double *img, double *img1, int blocks)
{
//performs simple error analysis on the difference between the output
of the
//Walsh-Hadamard transformation and MATLAB's fwht implementation
//performs this error analysis on the whole image and each segment to
better identify any error
int i;
img_wht(rows, cols, img); //perform WHT on input image
for(i = 0; i < rows*outCols; i++)
{
img2[i] = round(img2[i]); //round to nearest integer to work with
PGM
}
double* error = malloc((rows * outCols) * sizeof(double));
for(i = 0; i < rows * outCols; i++) //takes the difference between each
point in image arrays
{
error[i] = img2[i] - img1[i];
}
printf("For the whole image: n");
rmseCalculations(error, rows, outCols); //calculate mean and RMSE of
error values along whole image
double rowSize = (double)(rows) / blocks;
int rowSize2 = ceil(rowSize); //take the ceiling to achieve a whole
number
double* error2 = malloc((rowSize2 * blocks * outCols) * sizeof(double));
for(i = 0; i < rowSize2 * blocks * outCols; i++)
Weingarten 19
{
if(i >= rows * outCols)
{
error2[i] = 0.0; //zero-padding
}
else
{
error2[i] = error[i];
}
}
int j;
for(i = 0; i < blocks; i++)
{
double* error3 = malloc((rowSize2 * outCols) * sizeof(double));
for(j = 0; j < rowSize2 * outCols; j++)
{
error3[j] = error2[i*rowSize2*outCols + j]; //copy over
necessary part
}
printf("For segment %d:n", (i + 1));
rmseCalculations(error3, rowSize2, outCols); //calculate error
over corresponding segment
}
free(error);
free(error2);
}
Appendix B
Figure 5: Test image 2 for WHT analysis.
Weingarten 20
Figure 6: UIA’s result’s with the new wht utility.
Figure 7: MATLAB’s result with the wht utility.
Figure 8: Test image 3 for WHT analysis
Figure 9: UIA’s result’s with the new wht utility.
Weingarten 21
Figure 10: MATLAB’s result with the wht utility.
For both sets of images, the mean and RMSE of the error values were 0.000 on the whole
image as well as on each segment (used 4 segments for the first one and 3 for the second) of the
image.
Weingarten 22
Biography
Matthew (Matt) Weingarten graduated from the University of Florida in December 2015
with a Bachelor of Science in Computer Science and minors in Mathematics and Statistics. In
July 2016, he will join the Emerging Technologist Program at Nielsen in Oldsmar, Florida. Until
then, he plans to travel the country and relax. In his free time, Matt loves to play Bridge, a card
game he has been playing since he was 14, watching and playing sports, playing video games,
and browsing the Internet.
Figure 11: Weingarten at a Rolling Stones concert in 2015.

More Related Content

What's hot

METHOD FOR A SIMPLE ENCRYPTION OF IMAGES BASED ON THE CHAOTIC MAP OF BERNOULLI
METHOD FOR A SIMPLE ENCRYPTION OF IMAGES BASED ON THE CHAOTIC MAP OF BERNOULLIMETHOD FOR A SIMPLE ENCRYPTION OF IMAGES BASED ON THE CHAOTIC MAP OF BERNOULLI
METHOD FOR A SIMPLE ENCRYPTION OF IMAGES BASED ON THE CHAOTIC MAP OF BERNOULLIijcsit
 
GPUFish_technical_report
GPUFish_technical_reportGPUFish_technical_report
GPUFish_technical_reportCharles Hubbard
 
FPGA Implementation of 2-D DCT & DWT Engines for Vision Based Tracking of Dyn...
FPGA Implementation of 2-D DCT & DWT Engines for Vision Based Tracking of Dyn...FPGA Implementation of 2-D DCT & DWT Engines for Vision Based Tracking of Dyn...
FPGA Implementation of 2-D DCT & DWT Engines for Vision Based Tracking of Dyn...IJERA Editor
 
The method of comparing two image files
 The method of comparing two image files The method of comparing two image files
The method of comparing two image filesMinh Anh Nguyen
 
Recognition of Handwritten Mathematical Equations
Recognition of  Handwritten Mathematical EquationsRecognition of  Handwritten Mathematical Equations
Recognition of Handwritten Mathematical EquationsIRJET Journal
 
3d tracking : chapter2-1 mathematical tools
3d tracking : chapter2-1 mathematical tools3d tracking : chapter2-1 mathematical tools
3d tracking : chapter2-1 mathematical toolsWoonhyuk Baek
 
MapReduce: Ordering and Large-Scale Indexing on Large Clusters
MapReduce: Ordering and  Large-Scale Indexing on Large ClustersMapReduce: Ordering and  Large-Scale Indexing on Large Clusters
MapReduce: Ordering and Large-Scale Indexing on Large ClustersIRJET Journal
 
Hand gesture recognition using discrete wavelet transform and hidden Markov m...
Hand gesture recognition using discrete wavelet transform and hidden Markov m...Hand gesture recognition using discrete wavelet transform and hidden Markov m...
Hand gesture recognition using discrete wavelet transform and hidden Markov m...TELKOMNIKA JOURNAL
 
IMPLEMENTATION OF UNSIGNED MULTIPLIER USING MODIFIED CSLA
IMPLEMENTATION OF UNSIGNED MULTIPLIER USING MODIFIED CSLAIMPLEMENTATION OF UNSIGNED MULTIPLIER USING MODIFIED CSLA
IMPLEMENTATION OF UNSIGNED MULTIPLIER USING MODIFIED CSLAeeiej_journal
 
Implementation of an arithmetic logic using area efficient carry lookahead adder
Implementation of an arithmetic logic using area efficient carry lookahead adderImplementation of an arithmetic logic using area efficient carry lookahead adder
Implementation of an arithmetic logic using area efficient carry lookahead adderVLSICS Design
 
Design and Implementation of a Programmable Truncated Multiplier
Design and Implementation of a Programmable Truncated MultiplierDesign and Implementation of a Programmable Truncated Multiplier
Design and Implementation of a Programmable Truncated Multiplierijsrd.com
 

What's hot (17)

METHOD FOR A SIMPLE ENCRYPTION OF IMAGES BASED ON THE CHAOTIC MAP OF BERNOULLI
METHOD FOR A SIMPLE ENCRYPTION OF IMAGES BASED ON THE CHAOTIC MAP OF BERNOULLIMETHOD FOR A SIMPLE ENCRYPTION OF IMAGES BASED ON THE CHAOTIC MAP OF BERNOULLI
METHOD FOR A SIMPLE ENCRYPTION OF IMAGES BASED ON THE CHAOTIC MAP OF BERNOULLI
 
GPUFish_technical_report
GPUFish_technical_reportGPUFish_technical_report
GPUFish_technical_report
 
FPGA Implementation of 2-D DCT & DWT Engines for Vision Based Tracking of Dyn...
FPGA Implementation of 2-D DCT & DWT Engines for Vision Based Tracking of Dyn...FPGA Implementation of 2-D DCT & DWT Engines for Vision Based Tracking of Dyn...
FPGA Implementation of 2-D DCT & DWT Engines for Vision Based Tracking of Dyn...
 
The method of comparing two image files
 The method of comparing two image files The method of comparing two image files
The method of comparing two image files
 
Recognition of Handwritten Mathematical Equations
Recognition of  Handwritten Mathematical EquationsRecognition of  Handwritten Mathematical Equations
Recognition of Handwritten Mathematical Equations
 
3d tracking : chapter2-1 mathematical tools
3d tracking : chapter2-1 mathematical tools3d tracking : chapter2-1 mathematical tools
3d tracking : chapter2-1 mathematical tools
 
Ay33292297
Ay33292297Ay33292297
Ay33292297
 
MapReduce: Ordering and Large-Scale Indexing on Large Clusters
MapReduce: Ordering and  Large-Scale Indexing on Large ClustersMapReduce: Ordering and  Large-Scale Indexing on Large Clusters
MapReduce: Ordering and Large-Scale Indexing on Large Clusters
 
master_seminar
master_seminarmaster_seminar
master_seminar
 
Hand gesture recognition using discrete wavelet transform and hidden Markov m...
Hand gesture recognition using discrete wavelet transform and hidden Markov m...Hand gesture recognition using discrete wavelet transform and hidden Markov m...
Hand gesture recognition using discrete wavelet transform and hidden Markov m...
 
IMPLEMENTATION OF UNSIGNED MULTIPLIER USING MODIFIED CSLA
IMPLEMENTATION OF UNSIGNED MULTIPLIER USING MODIFIED CSLAIMPLEMENTATION OF UNSIGNED MULTIPLIER USING MODIFIED CSLA
IMPLEMENTATION OF UNSIGNED MULTIPLIER USING MODIFIED CSLA
 
dominguez_cecilia_image-processing-manual
dominguez_cecilia_image-processing-manualdominguez_cecilia_image-processing-manual
dominguez_cecilia_image-processing-manual
 
Project vague
Project   vagueProject   vague
Project vague
 
Modeling and Real-Time Simulation of Induction Motor Using RT-LAB
Modeling and Real-Time Simulation of Induction Motor Using RT-LABModeling and Real-Time Simulation of Induction Motor Using RT-LAB
Modeling and Real-Time Simulation of Induction Motor Using RT-LAB
 
Implementation of an arithmetic logic using area efficient carry lookahead adder
Implementation of an arithmetic logic using area efficient carry lookahead adderImplementation of an arithmetic logic using area efficient carry lookahead adder
Implementation of an arithmetic logic using area efficient carry lookahead adder
 
Design and Implementation of a Programmable Truncated Multiplier
Design and Implementation of a Programmable Truncated MultiplierDesign and Implementation of a Programmable Truncated Multiplier
Design and Implementation of a Programmable Truncated Multiplier
 
Parallel Processor for Graphics Acceleration
Parallel Processor for Graphics AccelerationParallel Processor for Graphics Acceleration
Parallel Processor for Graphics Acceleration
 

Similar to Final Report

Image processing using matlab
Image processing using matlabImage processing using matlab
Image processing using matlabdedik dafiyanto
 
sp-trajano-april2010
sp-trajano-april2010sp-trajano-april2010
sp-trajano-april2010Axel Trajano
 
Using A Application For A Desktop Application
Using A Application For A Desktop ApplicationUsing A Application For A Desktop Application
Using A Application For A Desktop ApplicationTracy Huang
 
Technical Documentation_Embedded_Image_DSP_Projects
Technical Documentation_Embedded_Image_DSP_ProjectsTechnical Documentation_Embedded_Image_DSP_Projects
Technical Documentation_Embedded_Image_DSP_ProjectsEmmanuel Chidinma
 
FAST AND EFFICIENT IMAGE COMPRESSION BASED ON PARALLEL COMPUTING USING MATLAB
FAST AND EFFICIENT IMAGE COMPRESSION BASED ON PARALLEL COMPUTING USING MATLABFAST AND EFFICIENT IMAGE COMPRESSION BASED ON PARALLEL COMPUTING USING MATLAB
FAST AND EFFICIENT IMAGE COMPRESSION BASED ON PARALLEL COMPUTING USING MATLABJournal For Research
 
HANDWRITTEN DIGIT RECOGNITION SYSTEM BASED ON CNN AND SVM
HANDWRITTEN DIGIT RECOGNITION SYSTEM BASED ON CNN AND SVMHANDWRITTEN DIGIT RECOGNITION SYSTEM BASED ON CNN AND SVM
HANDWRITTEN DIGIT RECOGNITION SYSTEM BASED ON CNN AND SVMsipij
 
Handwritten Digit Recognition System based on CNN and SVM
Handwritten Digit Recognition System based on CNN and SVMHandwritten Digit Recognition System based on CNN and SVM
Handwritten Digit Recognition System based on CNN and SVMsipij
 
IRJET - Single Image Super Resolution using Machine Learning
IRJET - Single Image Super Resolution using Machine LearningIRJET - Single Image Super Resolution using Machine Learning
IRJET - Single Image Super Resolution using Machine LearningIRJET Journal
 
Orthogonal Matching Pursuit in 2D for Java with GPGPU Prospectives
Orthogonal Matching Pursuit in 2D for Java with GPGPU ProspectivesOrthogonal Matching Pursuit in 2D for Java with GPGPU Prospectives
Orthogonal Matching Pursuit in 2D for Java with GPGPU ProspectivesMatt Simons
 
International Journal of Computational Engineering Research(IJCER)
 International Journal of Computational Engineering Research(IJCER)  International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER) ijceronline
 
Detection of medical instruments project- PART 1
Detection of medical instruments project- PART 1Detection of medical instruments project- PART 1
Detection of medical instruments project- PART 1Sairam Adithya
 
Mapreduce2008 cacm
Mapreduce2008 cacmMapreduce2008 cacm
Mapreduce2008 cacmlmphuong06
 
School of Computing, Science & EngineeringAssessment Briefin.docx
School of Computing, Science & EngineeringAssessment Briefin.docxSchool of Computing, Science & EngineeringAssessment Briefin.docx
School of Computing, Science & EngineeringAssessment Briefin.docxanhlodge
 
Matlab for Electrical Engineers
Matlab for Electrical EngineersMatlab for Electrical Engineers
Matlab for Electrical EngineersManish Joshi
 
High Performance Computing for Satellite Image Processing and Analyzing – A ...
High Performance Computing for Satellite Image  Processing and Analyzing – A ...High Performance Computing for Satellite Image  Processing and Analyzing – A ...
High Performance Computing for Satellite Image Processing and Analyzing – A ...Editor IJCATR
 
Monitor and Quality Control for Automatic Production Line System
Monitor and Quality Control for Automatic Production Line SystemMonitor and Quality Control for Automatic Production Line System
Monitor and Quality Control for Automatic Production Line SystemIRJET Journal
 

Similar to Final Report (20)

Log polar coordinates
Log polar coordinatesLog polar coordinates
Log polar coordinates
 
Image processing using matlab
Image processing using matlabImage processing using matlab
Image processing using matlab
 
sp-trajano-april2010
sp-trajano-april2010sp-trajano-april2010
sp-trajano-april2010
 
Using A Application For A Desktop Application
Using A Application For A Desktop ApplicationUsing A Application For A Desktop Application
Using A Application For A Desktop Application
 
[LinkedIn]_Thesis Sum in English_New
[LinkedIn]_Thesis Sum in English_New[LinkedIn]_Thesis Sum in English_New
[LinkedIn]_Thesis Sum in English_New
 
Presentation 3
Presentation 3Presentation 3
Presentation 3
 
Technical Documentation_Embedded_Image_DSP_Projects
Technical Documentation_Embedded_Image_DSP_ProjectsTechnical Documentation_Embedded_Image_DSP_Projects
Technical Documentation_Embedded_Image_DSP_Projects
 
FAST AND EFFICIENT IMAGE COMPRESSION BASED ON PARALLEL COMPUTING USING MATLAB
FAST AND EFFICIENT IMAGE COMPRESSION BASED ON PARALLEL COMPUTING USING MATLABFAST AND EFFICIENT IMAGE COMPRESSION BASED ON PARALLEL COMPUTING USING MATLAB
FAST AND EFFICIENT IMAGE COMPRESSION BASED ON PARALLEL COMPUTING USING MATLAB
 
HANDWRITTEN DIGIT RECOGNITION SYSTEM BASED ON CNN AND SVM
HANDWRITTEN DIGIT RECOGNITION SYSTEM BASED ON CNN AND SVMHANDWRITTEN DIGIT RECOGNITION SYSTEM BASED ON CNN AND SVM
HANDWRITTEN DIGIT RECOGNITION SYSTEM BASED ON CNN AND SVM
 
Handwritten Digit Recognition System based on CNN and SVM
Handwritten Digit Recognition System based on CNN and SVMHandwritten Digit Recognition System based on CNN and SVM
Handwritten Digit Recognition System based on CNN and SVM
 
IRJET - Single Image Super Resolution using Machine Learning
IRJET - Single Image Super Resolution using Machine LearningIRJET - Single Image Super Resolution using Machine Learning
IRJET - Single Image Super Resolution using Machine Learning
 
Autonomous robot
Autonomous robotAutonomous robot
Autonomous robot
 
Orthogonal Matching Pursuit in 2D for Java with GPGPU Prospectives
Orthogonal Matching Pursuit in 2D for Java with GPGPU ProspectivesOrthogonal Matching Pursuit in 2D for Java with GPGPU Prospectives
Orthogonal Matching Pursuit in 2D for Java with GPGPU Prospectives
 
International Journal of Computational Engineering Research(IJCER)
 International Journal of Computational Engineering Research(IJCER)  International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)
 
Detection of medical instruments project- PART 1
Detection of medical instruments project- PART 1Detection of medical instruments project- PART 1
Detection of medical instruments project- PART 1
 
Mapreduce2008 cacm
Mapreduce2008 cacmMapreduce2008 cacm
Mapreduce2008 cacm
 
School of Computing, Science & EngineeringAssessment Briefin.docx
School of Computing, Science & EngineeringAssessment Briefin.docxSchool of Computing, Science & EngineeringAssessment Briefin.docx
School of Computing, Science & EngineeringAssessment Briefin.docx
 
Matlab for Electrical Engineers
Matlab for Electrical EngineersMatlab for Electrical Engineers
Matlab for Electrical Engineers
 
High Performance Computing for Satellite Image Processing and Analyzing – A ...
High Performance Computing for Satellite Image  Processing and Analyzing – A ...High Performance Computing for Satellite Image  Processing and Analyzing – A ...
High Performance Computing for Satellite Image Processing and Analyzing – A ...
 
Monitor and Quality Control for Automatic Production Line System
Monitor and Quality Control for Automatic Production Line SystemMonitor and Quality Control for Automatic Production Line System
Monitor and Quality Control for Automatic Production Line System
 

Final Report

  • 1. Enhanced Image Manipulation Library for UNIX By: Matthew Weingarten (8189-1861) CIS 4914 Senior Project Advisor: Mark Schmalz Advisor’s email: mssz@cise.ufl.edu Date of talk: 12/8/15
  • 2. Weingarten 1 Table of Contents 1. Abstract………………………………………………………………………………2 2. Introduction…………………………………………………………………………..3 3. Problem Domain……………………………………………………………………...5 4. Literature Search……………………………………………………………………...6 5. Solution……………………………………………………………………………….7 6. Results………………………………………………………………………………...9 7. Conclusions…………………………………………………………………………...11 8. Acknowledgements…………………………………………………………………...12 9. References…………………………………………………………………………….13 10. Appendices……………………………………………………………………………14 11. Biography……………………………………………………………………………..22
  • 3. Weingarten 2 Abstract The increase in technology during the last decade has brought an increased need for methods and tools to analyze, compare, and manipulate images. UNIX-Based Image Analyst (UIA), a command-line image manipulation library developed by University of Florida students, provides a framework for doing this. Existing functionality in the library can be improved while new operations can be added. The author’s work has added new operations, most notably the Walsh-Hadamard transform, and made past ones more efficient. The author has learned about the statistical and mathematical techniques involved in the image manipulation process.
  • 4. Weingarten 3 Introduction Problem Statement Image analysis has become an increasing field of research in the past several decades as a result of the growth of processor technology for working with large file sizes. With technology’s current reliance on data, it has become more important than ever to be able to manipulate and analyze images. Most image analysis is performed with GUI frameworks that are expensive and difficult to work with. Developers favor simplicity whenever possible, so it seems natural to be able to perform image analysis on the command line. Background UNIX-Based Image Analyst (UIA) is a UNIX library dedicated to performing image analysis on the command line and is the result of past Senior Projects at the University of Florida. Dmitriy Bernsteyn, Suzanne Curry, Craig Holmquist, and Robert Pollock have all contributed to UIA in the past. Their work has provided a foundation on which to implement additional operations while enhancing past functionality. Working with UIA is rather simple. The user specifies an operation and the arguments necessary to run that operation, and then the system performs that corresponding manipulation and displays its output. Operations that can be performed include:  Arithmetic conversion routines (adding/subtracting/multiplying/dividing two images, taking the sine/logarithm of an image, and more) that produce a new image  Statistical operations such as the root-mean-square error (RMSE) that are either performed on a whole image or a part of the image Not all of the library’s functionality is native. ImageMagick is a tool that is pre-installed on many Ubuntu systems and allows a developer to convert images to Portable Graymap Format (PGM) as well as display images in a convenient manner. UIA is written in C and kept under ANSI-C standards so that it is portable to as many UNIX systems as possible. Solution UIA has a lot of operations available, but it is not complete. Additional functionality, such as the Walsh-Hadamard transform, can be added to the system. Previously developed
  • 5. Weingarten 4 operations can be enhanced to work with larger image sizes and can be documented in a more practicable manner so that it is more understandable to a first-time reader. Since it is only worked on every few years or so, UIA was brought up to existing standards with the newest UNIX and ImageMagick releases. Contribution The author’s contribution to UIA would not be possible if it were not for the past work of Bernsteyn, Curry, Holmquist, and Pollock. Existing utilities in UNIX assist the author in converting between image formats and displaying the images in a proper manner.
  • 6. Weingarten 5 Problem Domain Image manipulation is a component of the computer graphics field of computer science. Most of its work is heavily rooted in statistical theorems and operations. Image manipulation has a wide variety of applications, including but not limited to journalism, medicine, meteorology, and video conferencing.
  • 7. Weingarten 6 Literature Search Since UIA depends on outside libraries to perform some of its basic tasks, the documentation of those resources was vital. This is especially the case in this project as a result of some of the code becoming deprecated over the time that has elapsed between the author’s work and UIA’s previous versions. ImageMagick’s convert utility [4] was used to convert images to PGM format. The utility was also used to convert images back to their original format, which was very useful for transporting the images between different operating systems. convert also was used for any image resizing that needed to be done. ImageMagick’s display utility [4] was used to display images that UIA produced, while its compose utility [4] was used to add and subtract images. ImageMagick’s documentation of these commands was essential in its proper use in the context of the project. Wikipedia’s article on the Walsh-Hadamard transform (WHT) [3] was essential in setting up the calculations for the Hadamard matrix. The examples it provided were useful in getting that portion of the code up and running. MathWorks’ documentation on the hadamard function as well as the fwht (fast WHT) function [2] were essential in having the author’s implementation of the WHT run like the one that currently exists in MATLAB. There are a few minor differences between the WHT that exists in common literature, such as Wikipedia [3], and the one that exists in MATLAB. As it was the author’s original intent to have his C code perform like MATLAB’s existing functions, MathWorks’ documentation was very useful in making the necessary changes to achieve that purpose. The remaining references [1, 5, 6, 7, and 8] were imperative to get a basic understanding of the WHT and how it relates to image processing. Examples were provided by these sources to visually represent how the WHT manipulates an image. Without these examples, the author would never have been able to know whether his implementation was performing correctly or not.
  • 8. Weingarten 7 Solution The main addition that the author made to UIA was the WHT, which is a generalized form of a Fourier transform. It performs a series of size-2 discrete Fourier transforms (DFTs) on an image. The algorithm uses a divide-and-conquer approach that runs in 𝑂(𝑛𝑙𝑜𝑔(𝑛)) time. Before the transform is run on an image, preliminary steps need to be performed. First, the number of columns in the image have to be padded to the next power of two. This is a requirement for the WHT to run properly. This can be done as follows: 𝑁𝑃2( 𝑑𝑎𝑡𝑎) = 2^(⌈log2( 𝑑𝑎𝑡𝑎)⌉) This formula computes the log base 2 of the number of columns, takes the ceiling of that to convert it to the next largest integer, and then raises 2 to that exponent in order to either keep the same number of columns (if it’s already a power of 2), or increase it to the next largest power of 2 (if it’s not a power of 2). Since this might add pixels to the image that were not there before, those pixels have to be zeroed so that they will be compatible with the algorithm. After this step has been performed, the WHT is run on each row of the image matrix. This is possible because the WHT, just like most DFTs, exhibits the principle of separability, meaning that running multiple transformations across one dimension will have the net effect of running the transformation over all image dimensions. For any given row, the WHT begins by generating the corresponding Hadamard matrix for that row. The Hadamard matrix is used for scaling an image. The way it runs is as follows: INPUT: n, which represents log2(𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑐𝑜𝑙𝑢𝑚𝑛𝑠) OUTPUT: hadamardMatrix IF n := 1 hadamardMatrix := ( . 5 . 5 . 5 −.5 ) ELSE hadamardMatrix := 1 2 ( ℎ𝑎𝑑𝑎𝑚𝑎𝑟𝑑(𝑛 − 1) ℎ𝑎𝑑𝑎𝑚𝑎𝑟𝑑(𝑛 − 1) ℎ𝑎𝑑𝑎𝑚𝑎𝑟𝑑(𝑛 − 1) −ℎ𝑎𝑑𝑎𝑚𝑎𝑟𝑑(𝑛 − 1) ) While common literature, such as Wikipedia, has slight changes in the numbers and scaling factor used in the algorithm, this specific implementation is consistent with how
  • 9. Weingarten 8 MATLAB runs its fwht function. After the Hadamard matrix is generated, the row vector is multiplied by this matrix to scale it into a new image. When all of the rows are transformed, the image is normalized to grayscale and ImageMagick’s display utility is used to display the image, similar to how it was used with UIA’s fft routine. In addition to the basic WHT algorithm, error analysis was performed to compare the performance of the author’s WHT implementation with that of MATLAB. In order to do this, the computed image first has to be converted from a double array to a nearest integer array due to the PGM format and its unsigned char representation for array elements, which trims off any numbers beyond the decimal point. An error image was then calculated as the difference between the author’s output and that of MATLAB. After this is calculated, the following two measures are generated:  Mean of the error values (𝑚𝑒𝑎𝑛 = ∑ 𝑒𝑖 𝑛 𝑖=1 𝑛 , where 𝑒𝑖 represents the error value at pixel i)  RMSE of the error values (𝑅𝑀𝑆𝐸 = √ 1 𝑛 ∑ (𝑒𝑖 − 𝑚𝑒𝑎𝑛)2𝑛 𝑖=1 ) The RMSE was used to assist the author in modifying his WHT implementation until its error was at most equal to the error naturally inherent in an image, which is defined as ( 1 2 ) 𝑏𝑖𝑡𝑠 𝑝𝑒𝑟 𝑝𝑖𝑥𝑒𝑙 . The author extended this error analysis by performing it on segments of the image in order to better identify any sources of error. The segment size was calculated based on the number of segments that the user specified. This code is provided in Appendix A. Additionally, the author wrote a Markdown file that would better explain to a first-time reader the purpose of UIA and how each operation in the library works. Comments dealing with UIA’s code before the author’s work were added and enhanced to make the code more understandable and readable to those not affiliated with UIA. More error checking was added as well. Furthermore, UIA’s deprecated code was updated to work with the most current releases of UNIX and ImageMagick.
  • 10. Weingarten 9 Results The results presented in this section will be based on the following test image: Figure 1: The test image used for WHT analysis. UIA is executed on this image using the wht opcode and the image “surfing10a.gif.” The output of the transformation is the following image: Figure 2: The output image generated by UIA’s new wht routine. Compare this with MATLAB’s output image from its fwht routine: Figure 3: The output image generated by MATLAB’s fwht routine. These images are the same, which can be verified by running whtrmse with the original image and MATLAB’s output image. The mean and RMSE for the difference image are reported as 0.000 and 0.000, respectively. The same result applies to each segment (the author used 4 segments here) of the image. As these errors are less than the threshold value for eight-bit
  • 11. Weingarten 10 pixel values encoding ( 1 256 ), the author’s WHT implementation performs as intended. Additional test results on different images are provided in Appendix B. There are some intricacies involved in achieving zero error. First, the MATLAB script that runs fhwt has to run on a PGM of the input image, which can be done with an online image converter. Then, the MATLAB output image has to be saved in PGM format, which is an option with MATLAB’s imwrite operation. Converting between different image formats within UIA actually introduces error into the difference image, but as long as the image is saved as a PGM and the MATLAB script is run on a PGM image, then the mean and RMSE of the error values will be zero. Before the project began, there was no outside documentation for a first-time reader to become acquainted with UIA. Compare that to the Markdown file generated by the author, an excerpt of which is presented below: Figure 4: An excerpt from UIA’s new Markdown file. This makes the library’s functionality more understandable to readers who are not as familiar with the various image manipulation techniques. By lowering the amount of time required for someone to become familiar with the system, future participants will be able to get started with UIA in a shorter amount of time.
  • 12. Weingarten 11 Conclusions The author added the WHT to UIA as its major enhancement, as well as documentation for first-time readers, error-checking, and the repairing of deprecated code. Throughout the course of this implementation, the author learned a great amount about image manipulation, working with the command-line, proper documentation, and working with large datasets. There were a few intricacies with the author’s implementation. For one, using the PGM format requires rounding the image’s double array into a nearest integer array because of its unsigned char element representation. Additionally, the MATLAB output image has to be saved in PGM format in order for the mean and RMSE of the difference image to be 0. The addition of the WHT to UIA provides new opportunities for image analysis. In future projects, even more operations, building on the WHT as well as being separate, can be added to UIA to make the library even more extensive. After the library is more complete, it can hopefully be open-sourced so that the masses can use this tool for image analysis as well as add image manipulations of their own. There are a few existing bugs in UIA that were never documented before this project. Due to a lack of expertise in the subject area, the author was not able to fix those bugs. A bug log has been added for future projects so that future students who choose to work on UIA can identify existing issues in an effort to make it error-free.
  • 13. Weingarten 12 Acknowledgements Even though this project was an individual undertaking, there are a lot of people the author needs to thank for getting this far. First, the author would like to thank Dr. Mark Schmalz, his advisor for this project as well as a friend he can gladly say he got to know over the past few months. The author would also like to thank Dmitriy Bernsteyn, Suzanne Curry, Craig Holmquist, and Robert Pollock for their contributions to UIA and the documentation they provided so that it was understandable when he first began the project. The author would also like to thank his friends, at the University of Florida and elsewhere, for teaching him new things along his life’s journey so far. Life would be incomplete without them. Lastly, but most importantly, the author would like to thank his family. His parents, his sister, his grandparents, and all his relatives have been extremely supportive, from his childhood all the way to this current day. And now, his life is really starting, but he could not have written this paper without their support. He wishes to thank them for everything they’ve done. Words cannot express how much he is thankful for.
  • 14. Weingarten 13 References [1] "ANSI-C." Wikipedia. Wikimedia Foundation. Web. 7 Sept. 2015. <https://en.wikipedia.org/wiki/ANSI_C>. [2] "Fast Walsh-Hadamard Transform." MathWorks. MathWorks. Web. 15 Oct. 2015. <http://www.mathworks.com/help/signal/ref/fwht.html>. [3] "Hadamard Transform." Wikipedia. Wikimedia Foundation. Web. 7 Sept. 2015. [4] "Home." ImageMagick: Convert, Edit, Or Compose Bitmap Images. ImageMagick Studio LLC. Web. 24 Sept. 2015. <http://imagemagick.org/script/index.php>. [5] Johnson, Jeremy. "Lecture 4: Walsh-Hadamard Transform Algorithms." Jeremy Johnson. Jeremy Johnson, 5 Feb. 2004. Web. 7 Sept. 2015. <https://www.cs.drexel.edu/~jjohnson/wi04/cs680/lectures/wht.html>. [6] "Walsh-Hadamard Transform." MathWorks. MathWorks. Web. 15 Oct. 2015. [7] "The Hadamard Transform." Neuron. Web. 8 Oct. 2015. <http://neuron- ai.tuke.sk/hudecm/science/7/7.html>. [8] "What Is the Walsh-Hadamard Transform and What Is It Good For?" Stack Exchange. 12 Mar. 2012. Web. 7 Sept. 2015. <http://dsp.stackexchange.com/questions/1693/what-is-the- walsh-hadamard-transform-and-what-is-it-good-for>.
  • 15. Weingarten 14 Appendices Appendix A This appendix is used to document, in full detail, the author’s WHT implementation. int outCols; //columns after padding double* img2; double** hadamard (int n) { //uses a divide and conquer approach to compute the Hadamard matrix based on the number of iterations the user needs for their vector if(n == 1) //base case, default Hadamard matrix is [.5 .5 .5 -.5] { double** result = malloc(2 * sizeof(double*)); //allocate space int i; for(i = 0; i < 2; i++) { result[i] = malloc(2 * sizeof(double)); //allocate space } result[0][0] = .5; result[0][1] = .5; result[1][0] = .5; result[1][1] = -.5; return result; } else //recursive case { double** result = malloc((1<<n) * sizeof(double *)); //allocate space int i; for(i = 0; i < (1<<n); i++) { result[i] = malloc((1<<n) * sizeof(double)); //allocate space
  • 16. Weingarten 15 } double** result2 = malloc((1<<(n-1)) * sizeof(double*)); //allocate space for previous computation for(i = 0; i < 1<<(n-1); i++) { result2[i] = malloc((1<<(n-1)) * sizeof(double)); //allocate space for previous computation } result2 = hadamard(n - 1); //recursion int j; for(i = 0; i < (1<<(n-1)); i++) //top left corner { for(j = 0; j < (1<<(n-1)); j++) { result[i][j] = result2[i][j] * .5; } } for(i = (1<<(n-1)); i < (1<<n); i++) //top right corner { for(j = 0; j < (1<<(n-1)); j++) { result[i][j] = result2[i - (1<<(n-1))][j] * .5; } } for(i = 0; i < (1<<(n-1)); i++) //bottom left corner { for(j = (1<<(n-1)); j < (1<<n); j++) { result[i][j] = result2[i][j - (1<<(n-1))] * .5; } } for(i = (1<<(n-1)); i < (1<<n); i++) //bottom right corner, need to invert entries {
  • 17. Weingarten 16 for(j = (1<<(n-1)); j < (1<<n); j++) { result[i][j] = result2[i - (1<<(n-1))][j - (1<<(n-1))] * -.5; //invert } } return result; } } void hadamardTransform(double* data, int n) { //gets Hadamard matrix, multiplies it by data vector, and then sets data vector to that result //uses the MATLAB definition of fwht for doing the transform //note that their definition is different than the definition used in common literature double** hadamard1 = malloc(n * sizeof(double*)); //allocate space for Hadamard matrix int i; for(i = 0; i < n; i++) { hadamard1[i] = malloc(n * sizeof(double)); //allocate space for Hadamard matrix } double* result = malloc(n * sizeof(double)); hadamard1 = hadamard(LN2(n)); //get result result = multiply(data, hadamard1, n); //multiply matrices for(i = 0; i < n; i++) { data[i] = result[i]; } } void img_wht(int rows, int cols, double *img) { outCols = NEXT_P2(cols); //computes next power of 2
  • 18. Weingarten 17 int size = rows * outCols * sizeof(double); double* imgA = malloc(size); int i; for(i = 0; i < rows; i++) { realToDouble2(img + (cols * i), cols, imgA + (i * outCols), outCols); //zeros padded entries of array for each row } for(i = 0; i < rows; i++) //apply Hadamard transform to each row { hadamardTransform(imgA + (i * outCols), outCols); } displayWHTImage(imgA, rows, outCols); //display result img2 = malloc((rows*outCols) * sizeof(double)); for(i = 0; i < rows*outCols; i++) //copies values over for img_wht_rmse { img2[i] = imgA[i]; } } void rmseCalculations(double* error, int rows, int cols) { //calculate mean and RMSE of error values for a given error matrix int i; double sum = 0.0; for(i = 0; i < rows * cols; i++) //computes sums of error values { sum += error[i]; } double mean = sum / (rows * cols); //takes the average of all the error values printf("Mean of error values: %.3fn", mean); double variance = 0.0; for(i = 0; i < rows * cols; i++) {
  • 19. Weingarten 18 variance += pow((error[i] - mean), 2.0); //calculates the variance of the error values } double rmse = sqrt(variance) / sqrt(rows * cols); //calculates the RMSE of the error values printf("RMSE of error values: %.3fn", rmse); } void img_wht_rmse(int rows, int cols, double *img, double *img1, int blocks) { //performs simple error analysis on the difference between the output of the //Walsh-Hadamard transformation and MATLAB's fwht implementation //performs this error analysis on the whole image and each segment to better identify any error int i; img_wht(rows, cols, img); //perform WHT on input image for(i = 0; i < rows*outCols; i++) { img2[i] = round(img2[i]); //round to nearest integer to work with PGM } double* error = malloc((rows * outCols) * sizeof(double)); for(i = 0; i < rows * outCols; i++) //takes the difference between each point in image arrays { error[i] = img2[i] - img1[i]; } printf("For the whole image: n"); rmseCalculations(error, rows, outCols); //calculate mean and RMSE of error values along whole image double rowSize = (double)(rows) / blocks; int rowSize2 = ceil(rowSize); //take the ceiling to achieve a whole number double* error2 = malloc((rowSize2 * blocks * outCols) * sizeof(double)); for(i = 0; i < rowSize2 * blocks * outCols; i++)
  • 20. Weingarten 19 { if(i >= rows * outCols) { error2[i] = 0.0; //zero-padding } else { error2[i] = error[i]; } } int j; for(i = 0; i < blocks; i++) { double* error3 = malloc((rowSize2 * outCols) * sizeof(double)); for(j = 0; j < rowSize2 * outCols; j++) { error3[j] = error2[i*rowSize2*outCols + j]; //copy over necessary part } printf("For segment %d:n", (i + 1)); rmseCalculations(error3, rowSize2, outCols); //calculate error over corresponding segment } free(error); free(error2); } Appendix B Figure 5: Test image 2 for WHT analysis.
  • 21. Weingarten 20 Figure 6: UIA’s result’s with the new wht utility. Figure 7: MATLAB’s result with the wht utility. Figure 8: Test image 3 for WHT analysis Figure 9: UIA’s result’s with the new wht utility.
  • 22. Weingarten 21 Figure 10: MATLAB’s result with the wht utility. For both sets of images, the mean and RMSE of the error values were 0.000 on the whole image as well as on each segment (used 4 segments for the first one and 3 for the second) of the image.
  • 23. Weingarten 22 Biography Matthew (Matt) Weingarten graduated from the University of Florida in December 2015 with a Bachelor of Science in Computer Science and minors in Mathematics and Statistics. In July 2016, he will join the Emerging Technologist Program at Nielsen in Oldsmar, Florida. Until then, he plans to travel the country and relax. In his free time, Matt loves to play Bridge, a card game he has been playing since he was 14, watching and playing sports, playing video games, and browsing the Internet. Figure 11: Weingarten at a Rolling Stones concert in 2015.