\@writefile{lof}{\contentsline{figure}{\numberline{1}{\ignorespaces The other 4 pixels are used to find the value of the 5th.\relax}}{1}{figure.caption.1}\protected@file@percent }
\@writefile{lof}{\contentsline{figure}{\numberline{1}{\ignorespaces The other 4 pixels are used to find the value of the 5th.\relax}}{1}{figure.caption.1}\protected@file@percent }
@@ -100,13 +100,17 @@ The resulting files were approximately 34\% smaller than their equivalent PNGs,
...
@@ -100,13 +100,17 @@ The resulting files were approximately 34\% smaller than their equivalent PNGs,
\section{Introduction}
\section{Introduction}
\subsection{Overview}
\subsection{Overview}
The idea is based off of how images are scanned in originally.
The idea is based on how images are scanned in originally.
Like a cathode-ray tube in a television, the algorithm goes line by line, reading/writing each pixel individually in a raster pattern.
Like a cathode-ray tube in a television, the algorithm goes line by line, reading/writing each pixel individually in a raster pattern.
Each pixel, as long as it is not on the top or side boundaries, will have 4 neighbors that have already been read into the machine.
Each pixel, as long as it is not on the top or side boundaries, will have 4 neighbors that have already been read into the machine.
Those points can be analyzed and interpolated to find the next pixel's value.
Those points can be analyzed and interpolated to find the next pixel's value.
The goal is to encode the error between that value and the original value, save that, and use that to compress and decompress the image.
The goal is to encode the error between that value and the original value, save that, and use that to compress and decompress the image.
Even though a possibly larger integer may need to be stored, it's more likely that the guess will be correct, or off by a small margin, making the distribution better for compression.
Even though a possibly larger integer may need to be stored, it is more likely that the guess will be correct or off by a small margin, making the distribution better for compression.
The approach of using the neighboring pixels for compression is not new, as evidenced by its use in ISO/IEC14495-1:1999 \cite{ISO/IEC14495-1} and ``CALIC-a context based adaptive lossless image codec''\cite{544819}, which were both written more than 20 years before the publication of this paper.
%This ``neighbor'' system is not as common as it should be, as it provides a base for simple implementation with high rates of compression.
Our final implementation differs from these methods and others in ways that we found beneficial, and ways others may find to be beneficial as well.
\begin{figure}[h]
\begin{figure}[h]
\centering
\centering
...
@@ -117,8 +121,8 @@ Even though a possibly larger integer may need to be stored, it's more likely th
...
@@ -117,8 +121,8 @@ Even though a possibly larger integer may need to be stored, it's more likely th
The images that were used in the development of this paper were all thermal images, with values ranging from 19,197 to 25,935.
The images that were used in the development of this paper were all thermal images, with values ranging from 19,197 to 25,935.
In the system, total possible values can range from 0 to 32,768.
In the system, total possible values can range from 0 to 32,768.
Most images had ranges of at most 4,096 between the smallest and the largest pixel values.
Most images had ranges of at most 4,096 between the smallest and the largest pixel values.
The camera being used has 16 forwardfacing thermal sensors creating 16 similar thermal images every frame.
The camera being used has 16 forward-facing thermal sensors creating 16 similar thermal images every frame.
Everything detailed here can still apply to standard grayscale or RGB images, but only 16bit thermal images were used in testing.
Everything detailed here can still apply to standard grayscale or RGB images, but only 16-bit thermal images were used in testing.
\section{Related Work}
\section{Related Work}
...
@@ -127,24 +131,24 @@ PNG is a lossless compression algorithm that also operates using a single pass s
...
@@ -127,24 +131,24 @@ PNG is a lossless compression algorithm that also operates using a single pass s
The image is separated into several blocks of arbitrary size, which are then compressed using a combination of LZ77 and Huffman encoding \cite{PNGdetails}.
The image is separated into several blocks of arbitrary size, which are then compressed using a combination of LZ77 and Huffman encoding \cite{PNGdetails}.
LZ77 operates by finding patterns in the data and creating pointers to the original instance of that pattern.
LZ77 operates by finding patterns in the data and creating pointers to the original instance of that pattern.
For example, if there are two identical blocks of just the color blue, the second one only has to make reference to the first.
For example, if there are two identical blocks of just the color blue, the second one only has to make reference to the first.
Instead of saving two full blocks, the second one just contains the location of the first, telling the decoder to use that block.
Instead of saving two full blocks, the second one is saved as a pointer to the first, telling the decoder to use that block.
Huffman encoding is then used to save these numbers, optimizing how the location data is stored.
Huffman encoding is then used to save these numbers, optimizing how the location data is stored.
If one pattern is more frequent, the algorithm should optimize over this, producing an even smaller file\cite{PNGdetails}.
If one pattern is more frequent, the algorithm should optimize over this, producing an even smaller file\cite{PNGdetails}.
The Huffman encoding in conjunction with LZ77 helps form ``deflate'', the algorithm summarized here, and the one used in PNG.
The Huffman encoding in conjunction with LZ77 helps form ``deflate'', the algorithm summarized here, and the one used in PNG.
Our algorithm has a similar use of Huffman encoding, but a completely different algorithm than LZ77.
Our algorithm uses Huffman encoding similarly, but a completely different algorithm than LZ77.
LZ77 seeks patterns between blocks while ours has no block structure and no explicit pattern functionality.
LZ77 seeks patterns between blocks, while ours has no block structure and no explicit pattern functionality.
Ours uses the equivalent block size of 1, and instead of encoding the data it encodes alternate data which is used to compress.
Ours uses the equivalent block size of 1, and instead of encoding the data, it encodes alternate data which is used to compress.
\subsection{LZW}
\subsection{LZW}
LZW operates differently by creating a separate code table that maps every sequence to a code.
LZW operates differently by creating a separate code table that maps every sequence to a code.
Although this is used for an image, the original paper by Welch \cite{LZW} explains it through text examples, which will be done here as well.
Although this is used for an image, the original paper by Welch \cite{LZW} explains it through text examples, which will be done here as well.
Instead of looking at each character individually, it looks at variablelength string chains and compresses those.
Instead of looking at each character individually, it looks at variable-length string chains and compresses those.
Passing through the items to be compressed, if a phrase has already been encountered, it saves the reference to the original phrase along with the next character in sequence.
Passing through the items to be compressed, if a phrase has already been encountered, it saves the reference to the original phrase along with the next character in the sequence.
In this way, the longer repeated phrases are automatically found and can be compressed to be smaller.
In this way, the longer repeated phrases are automatically found and can be compressed to be smaller.
This system also uses blocks like PNG in order to save patterns in the data, but instead by looking at the entire data as it moves along, PNG only operates on a short portion of the text \cite{PNGdetails}.
This system also uses blocks like PNG in order to save patterns in the data, but instead by looking at the whole data set as it moves along, PNG only operates on a short portion of the text \cite{PNGdetails}.
Ours, similarly to PNG, only looks at a short portion of the data, which may have an advantage over LZW for images.
Ours, similarly to PNG, only looks at a short portion of the data, which may have an advantage over LZW for images.
Images generally do not have the same patterns that text does, so it may be advantageous to not use the entire corpus in compressing an image and instead only evaluate it based off of nearby objects.
Images generally do not have the same patterns that text does, so it may be advantageous not to use the entire corpus in compressing an image and instead only evaluate it based on nearby objects.
The blue parts of the sky will be next to other blue parts of the sky, and in the realm of thermal images, temperatures will probably be most similar to nearby ones due to how heat flows.
The blue parts of the sky will be next to other blue parts of the sky, and in the realm of thermal images, temperatures will probably be most similar to nearby ones due to how heat flows.
\subsection{Similar Methods}
\subsection{Similar Methods}
Our prior searches did not find any very similar approaches, especially with 16-bit thermal images.
Our prior searches did not find any very similar approaches, especially with 16-bit thermal images.
...
@@ -153,17 +157,17 @@ One paper that is close is ``Encoding-interleaved hierarchical interpolation for
...
@@ -153,17 +157,17 @@ One paper that is close is ``Encoding-interleaved hierarchical interpolation for
This method seems to operate with a similar end goal, to save the interpolation, but operates using a different system, including how it interpolates.
This method seems to operate with a similar end goal, to save the interpolation, but operates using a different system, including how it interpolates.
Instead of using neighboring pixels in a raster format, it uses vertical and horizontal ribbons, and a different way of interpolating.
Instead of using neighboring pixels in a raster format, it uses vertical and horizontal ribbons, and a different way of interpolating.
The ribbons alternate, going between a row that is directly saved and one that is not saved but is later interpolated.
The ribbons alternate, going between a row that is directly saved and one that is not saved but is later interpolated.
In this way it is filling in the gaps of an already robust image and saving the finer details.
By doing this, it is filling in the gaps of an already robust image and saving the finer details.
This other method could possibly show an increase in speed but not likely in overall compression.
This other method could possibly show an increase in speed but not likely in overall compression.
This will not have the same benefit as ours since ours uses interpolation on almost the entire image, instead of just parts, helping it optimize over a larger amount of data.
This will not have the same benefit as ours since ours uses interpolation on almost the entire image, instead of just parts, helping it optimize over a larger amount of data.
This paper is also similar to ``Iterative polynomial interpolation and data compression'' \cite{Dahlen1993}, where the researchers did a similar approach but with different shapes.
This paper is also similar to ``Iterative polynomial interpolation and data compression'' \cite{Dahlen1993}, where the researchers did a similar approach but with different shapes.
The error numbers were still saved, but they used specifically polynomial interpretation which we did not see fit to use in ours.
The error numbers were still saved, but they specifically used polynomial interpretation which we did not see fit to use in ours.
The closest method is ``Near-lossless image compression by relaxation-labelled prediction'' \cite{AIAZZI20021619} which is similar in the general principles of the interpolation and encoding.
The closest method is ``Near-lossless image compression by relaxation-labelled prediction'' \cite{AIAZZI20021619}, which is similar in the general principles of the interpolation and encoding.
The algorithm detailed in the paper uses a clustering algorithm of the nearby points to create the interpolation, saving the errors to be used later in the reconstruction of the original image.
The algorithm detailed in the paper uses a clustering algorithm of the nearby points to create the interpolation, saving the errors to be used later in the reconstruction of the original image.
This method is much more complex, not using a direct interpolation method but instead using a clustering algorithm to find the next point.
This method is much more complex, not using a direct interpolation method but instead using a clustering algorithm to find the next point.
This could potentially have an advantage over what we did by using more points in the process, but in implementation it may become too complicated and lose value.
This could potentially have an advantage over what we did by using more points in the process, but in proper implementation it may become too complicated and lose value.
The goal for us was to have a simple and efficient encoding operation, and this would have too many errors to process.
The goal for us was to have a simple and efficient encoding operation, and this would have too many errors to process.
It also has a binning system like ours, with theirs based off of the mean square prediction error.
It also has a binning system like ours, with theirs based off of the mean square prediction error.
The problem is that which bin it goes into can shift over the classification process adding to the complexity of the algorithm.
The problem is that which bin it goes into can shift over the classification process adding to the complexity of the algorithm.
...
@@ -174,7 +178,7 @@ To begin, the border values are encoded into the system, starting with the first
...
@@ -174,7 +178,7 @@ To begin, the border values are encoded into the system, starting with the first
The values after that are just modifications from the first value.
The values after that are just modifications from the first value.
There are not many values here and the algorithm needs a place to start.
There are not many values here and the algorithm needs a place to start.
Alternate things could have been done, but they would have raised temporal complexity with marginal gain.
Alternate things could have been done, but they would have raised temporal complexity with marginal gain.
Once the middle points are reached, the pixel to the left, top left, directly above, and top right have already been read in.
Once the middle points are reached, the pixel to the left, top left, directly above, and top right have already been read into the system.
Each of these values is given a point in the x-y plane, with the top left at (-1,1), top pixel at (0,1), top right pixel at (1,1), and the middle left pixel at (-1,0), giving the target the coordinates (0,0).
Each of these values is given a point in the x-y plane, with the top left at (-1,1), top pixel at (0,1), top right pixel at (1,1), and the middle left pixel at (-1,0), giving the target the coordinates (0,0).
Using the formula for a plane in 3D ($ax + by + c = z$) we get the system of equations
Using the formula for a plane in 3D ($ax + by + c = z$) we get the system of equations
$$-a + b + c = z_0$$
$$-a + b + c = z_0$$
...
@@ -231,7 +235,7 @@ $$
...
@@ -231,7 +235,7 @@ $$
The new matrix is full rank and can therefore be solved using \verb|numpy.linalg.solve|\cite{Numpy}.
The new matrix is full rank and can therefore be solved using \verb|numpy.linalg.solve|\cite{Numpy}.
The x that results corresponds to two values followed by the original $c$ from the $ax+by+c=z$ form, which is the predicted pixel value.
The x that results corresponds to two values followed by the original $c$ from the $ax+by+c=z$ form, which is the predicted pixel value.
Huffman encoding performs well on data with varying frequency \cite{Huffman}, which makes it a good candidate for saving the error numbers.
Huffman encoding performs well on data with varying frequency \cite{Huffman}, making it a good candidate for saving the error numbers.
Most pixels will be off the predicted values by low numbers since many objects have close to uniform surface temperature or have an almost uniform temperature gradient.
Most pixels will be off the predicted values by low numbers since many objects have close to uniform surface temperature or have an almost uniform temperature gradient.
\begin{figure}[h]
\begin{figure}[h]
...
@@ -249,20 +253,20 @@ Most pixels will be off the predicted values by low numbers since many objects h
...
@@ -249,20 +253,20 @@ Most pixels will be off the predicted values by low numbers since many objects h
In order to adjust for objects in images that are known to have an unpredictable temperature (fail the cases before), a bin system is used.
In order to adjust for objects in images that are known to have an unpredictable temperature (fail the cases before), a bin system is used.
The residuals from \verb|numpy.linalg.lstsq|\cite{Numpy} are used to determine the difference across the 4 known points, which is then used to place it in a category.
The residuals from \verb|numpy.linalg.lstsq|\cite{Numpy} are used to determine the difference across the 4 known points, which the difference is then used to place it in a category.
This number is the difference between trying to fit a plane between 4 different points.
This number is the difference between trying to fit a plane between 4 different points.
If a plane is able to be drawn that contains all 4 points, it makes sense that the error will be much smaller than if the bestfitted plane was not very close to any of the points.
If a plane is able to be drawn that contains all 4 points, it makes sense that the error will be much smaller than if the best-fitted plane was not very close to any of the points.
Something more certain is more likely to be correctly estimated.
Something more certain is more likely to be correctly estimated.
5 bins were used with splits chosen by evenly distributing the difference numbers into evenly sized bins.
5 bins were used with splits chosen by evenly distributing the difference numbers into evenly sized bins.
Many of the images had several different bin sizes ranging from 11 in the first category to a difference of 30 as the first category.
Many of the images had several different bin sizes ranging from 11 in the first category to a difference of 30 as the size of the first category.
An average number between all of them was chosen, since using the average versus specific bins had an effect on compression of less than half a percent.
An average number between all of them was chosen since using the average for bin sizes versus specific bin sizes had an effect on compression of less than half a percent.
\section{Results}
\section{Results}
We attained an average compression ratio of $0.4057$ on a set of 262 images, with compression ratios on individual images ranging from $0.3685$ to $0.4979$.
We attained an average compression ratio of $0.4057$ on a set of 262 images, with compression ratios on individual images ranging from $0.3685$ to $0.4979$.
Because the system runs off of a saved dictionary, it is better to think of the system as a cross between an individual compression system and a larger archival tool.
Because the system runs off of a saved dictionary, it is better to think of the system as a cross between an individual compression system and a larger archival tool.
This means that there are large changes in compression ratios depending on how many files are compressed at a time, despite the ability to decompress files individually and independently.
This means that there are significant changes in compression ratios depending on how many files are compressed at a time, despite the ability to decompress files individually and independently.
When the size of the saved dictionary was included, the compression ratio on the entire set only changed from $0.4043$ to $0.4057$.
When the size of the saved dictionary was included, the compression ratio on the entire set only changed from $0.4043$ to $0.4057$.
However, when tested on a random image in the set, it went from $0.3981$ to $0.7508$.
However, when tested on a random image in the set, it went from $0.3981$ to $0.7508$.
...
@@ -271,6 +275,7 @@ These are outlined in the discussion section below.
...
@@ -271,6 +275,7 @@ These are outlined in the discussion section below.
This was tested on a set of a least 16 images, so this does not affect us as much.
This was tested on a set of a least 16 images, so this does not affect us as much.
When tested on a random set of 16 images, the ratio only changed from $0.3973$ to $0.4193$.
When tested on a random set of 16 images, the ratio only changed from $0.3973$ to $0.4193$.
@@ -281,7 +286,7 @@ When tested on a random set of 16 images, the ratio only changed from $0.3973$ t
...
@@ -281,7 +286,7 @@ When tested on a random set of 16 images, the ratio only changed from $0.3973$ t
\hline
\hline
\end{tabular}
\end{tabular}
\end{center}
Our method created files that are on average 33.7\% smaller than PNG and 34.5\% smaller than LWZ compression on TIFF.
Our method created files that are on average 33.7\% smaller than PNG and 34.5\% smaller than LWZ compression on TIFF.
...
@@ -294,10 +299,10 @@ The issue with \verb|numpy.linalg.solve| was later addressed to fix the potentia
...
@@ -294,10 +299,10 @@ The issue with \verb|numpy.linalg.solve| was later addressed to fix the potentia
Calculating the inverse beforehand and using that in the system had marginal temporal benefit.
Calculating the inverse beforehand and using that in the system had marginal temporal benefit.
\verb|numpy.linalg.solve| runs in $O(N^3)$ for an $N\times N$ matrix, while the multiplication runs in a similar time. \cite{LAPACKAlgorithms}
\verb|numpy.linalg.solve| runs in $O(N^3)$ for an $N\times N$ matrix, while the multiplication runs in a similar time. \cite{LAPACKAlgorithms}
The least squares method mentioned in this project also has a shortcoming, but this one cannot be solved as easily.
The least squares method mentioned in this project also has a shortcoming, but this one cannot be solved as easily.
The psudoinverse can be calculated beforehand, but the largest problem is that it is solving the system for every pixel individually and calculating the norm.
The pseudoinverse can be calculated beforehand, but the largest problem is that it is solving the system for every pixel individually and calculating the norm.
\verb|numpy.linalg.lstsq| itself runs in $O(N^3)$ for an $N\times N$ matrix \cite{LeastSquaredProblem}, while the psudoinverse when implemented uses more python runtime, adding to temporal complexity.
\verb|numpy.linalg.lstsq| itself runs in $O(N^3)$ for an $N\times N$ matrix \cite{LeastSquaredProblem}, while the pseudoinverse, when implemented, uses more python runtime, adding to temporal complexity.
This compression suffers greatly when it is only used on individual images, which is not a problem for the project it was tested on.
This compression suffers when it is only used on individual images, which is not a problem for the use cases of this project.
The test images came from a camera that has 16 image sensors that work simultaneously.
The test images came from a camera that has 16 image sensors that work simultaneously.
The camera works in multiple image increments and therefore creates large packets that can be saved together, while still having the functionality of decompressing individually.
The camera works in multiple image increments and therefore creates large packets that can be saved together, while still having the functionality of decompressing individually.
This saves greatly on the memory that is required to view an image.
This saves greatly on the memory that is required to view an image.
...
@@ -305,13 +310,12 @@ It was therefore not seen necessary to create a different system to compress ind
...
@@ -305,13 +310,12 @@ It was therefore not seen necessary to create a different system to compress ind
A potential workaround for this problem would be to code extraneous values into the image directly instead of adding them to the full dictionary.
A potential workaround for this problem would be to code extraneous values into the image directly instead of adding them to the full dictionary.
This has the downside of not being able to integrate perfectly with Huffman encoding.
This has the downside of not being able to integrate perfectly with Huffman encoding.
A leaf of the tree could be a trigger to not use Huffman encoding anymore and use an alternate system to read in the bits.
A leaf of the tree could be a trigger to switch from Huffman encoding, and instead use an alternate system to read in the bits.
We did not to do this, but it would be a simple change for someone with a different use case.
We did not do this, but it would be a simple change for someone with a different use case.