<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\documentclass{lug}
\newcommand{\splitslide}[4]{
    \noindent
    \begin{minipage}{#1 \textwidth - #2}
        #3
    \end{minipage}%
    \hspace{ \dimexpr #2 * 2 \relax}%
    \begin{minipage}{\textwidth - #1 \textwidth - #2}
        #4
    \end{minipage}
}

\usepackage{listings}
\usepackage{censor}

\title{Linux Graphics Processing}
\author{Joseph Claver\\}

\begin{document}

\begin{frame}{Outline}
    Outline:
    \begin{itemize}
        \item Images
        \item Image Processing
        \item Videos
        \item Video Processing
    \end{itemize}
\end{frame}

\section{Images}

\begin{frame}{What's an image?!}
    \splitslide{0.6}{.7em}{
        An image is a visual representation of something. And on a computer,
        it's stored as a collection of bits, to be rendered as pixels on a
        screen.
    }{
        \begin{center}
            \begin{figure}
                \includegraphics[scale=0.15]{graphics/hamburger.jpg}
                \caption{Image of a burger (important)}
                \label{fig:Burger}
            \end{figure}
        \end{center}
    }
\end{frame}

\begin{frame}{Image Formats}
    \splitslide{0.7}{.7em}{
        There are many ways to store an image on a computer!
        \begin{itemize}[&lt;+-&gt;]
            \item PPM - Width, height, and simple RBG pixels
                % Portable Pixel Map. Contains a magic number, width, height,
                % max color value, and then the pixels! Generally inefficient,
                % but it's how you'd expect to find the image in memory.
            \item PNG - Lossless compression, with transparency
                % Was originally made because the creators of GIF started to
                % demand royalties for their compression. Originally called
                % PING - PNG is not GIF - but now called PNG - Portable Network
                % Graphic. It supports lossless compression, such that no pixel
                % detail is lost during file size compression. Also has good
                % color support with transparency layer. They decided not to
                % make this animated, unlike GIF, but made MNG as the animated
                % alternative - though GIF is much more popular.
            \item JPG/JPEG - Lossy compression, for minimizing file size
                % Made by Joint Photographics Experts Group. Aims to compress
                % in a way that still looks nice to the human eye, and can in
                % practice easily compress 20 to 1 while GIF only does about 10
                % to 1. Plus, can easily accommodate slower connections on the
                % Internet by slowly sending "more detailed" layers so that the
                % image slowly gets better. More on that next slide
            \item WebP - Modern image format with pretty good compression
                % Made by Google in 2010, and stands for Web Picture. Boasts
                % better compression rates than other previously mentioned file
                % formats without too significant detail loss. Tries to predict
                % image blocks from adjacent blocks. Though Google reports that
                % it is just better compression rates for no loss in quality,
                % some users claim that it's not appreciably better than
                % existing formats like jpeg.
        \end{itemize}
    }{
        \begin{center}
            \begin{figure}
                \includegraphics[scale=0.05]{graphics/flower.png}
                \caption{A PNG of a flower}
                \label{fig:Flower}
            \end{figure}
        \end{center}
    }
\end{frame}

\begin{frame}{JPEG is Pretty Interesting}
    JPEG encodes images with sine waves!
    % As shown in the below images, JPEG does a spatial fourier transform of
    % sorts, finding which frequencies resonate most with the pixels of the
    % image. The lower frequencies will tend to encode more prominent details,
    % while higher frequencies, which encode noise, can more readily be
    % discarded without losing detail

    \begin{center}
        \begin{figure}
            \includegraphics[scale=0.25]{graphics/how-jpeg-works.png}
            \includegraphics[scale=0.30]{graphics/jpg.jpg}
            \caption{The power of JPEG compression}
            \label{fig:JPEG}
        \end{figure}
    \end{center}
\end{frame}

\begin{frame}{More Image Formats}
    Some other image formats of note:

    \begin{itemize}
        \item RAW: Raw image components from a camera
            % This includes stuff like brightness, color, etc. before it's been
            % converted to a more useable image format. Some cameras even have
            % hexagonal "pixels" that need to be converted to rectangular
            % pixels in processing!
        \item GIF: Graphics Interchange Format
            % Classic. Good for animated stuff, and fairly good on compression
            % too.
        \item SVG: Scalable Vector Graphics
            % It's vector graphics! While most formats work in pixels, vector
            % graphics works in shapes and lines, which scales very well when
            % you zoom in.
        \item Can also use Singular Value Decomposition for compression!
            % Throwback to linear algebra
    \end{itemize}

    \begin{center}
        \begin{figure}
            \includegraphics[scale=0.12]{graphics/svd-compression.png}
            \caption{SVD Compression}
            \label{fig:SVD}
        \end{figure}
    \end{center}
\end{frame}

\section{Image Processing}

\begin{frame}{Tools for Image Editing}
    \splitslide{0.7}{.7em}{
        Many good tools for image editing on Linux!

        \begin{itemize}[&lt;+-&gt;]
            \item GIMP (GNU Image Manipulation Program)
            \item Krita (Swedish word for crayon)
            \item Pinta (It's Paint.NET for Linux)
        \end{itemize}

        But, we won't be talking much about them.
    }{
        \begin{center}
            \begin{figure}
                \includegraphics[scale=0.10]{graphics/gimp-icon.png}
                \caption{GIMP Icon}
                \label{fig:GIMP}
            \end{figure}
        \end{center}
    }
\end{frame}

\begin{frame}{Command-Line Image Processing}
    \splitslide{0.7}{.7em}{
        Instead, we'll be talking about processing images with ImageMagick!

        While most image editors are more for drawing images, ImageMagick can
        be used to edit images on the command-line.
    }{
        \begin{center}
            \begin{figure}
                \includegraphics[scale=0.25]{graphics/imagemagick.png}
                \caption{ImageMagick}
                \label{fig:ImageMagickLogo}
            \end{figure}
        \end{center}
    }
\end{frame}

\begin{frame}{Using ImageMagick}
    \splitslide{0.6}{.6em}{
        Let's demonstrate ImageMagick!

        Here's a png of Tux, the Linux mascot.
    }{
        \begin{center}
            \begin{figure}
                \includegraphics[scale=0.4]{graphics/tux/tux.png}
                \caption{Tux (normal)}
                \label{fig:TuxNormal}
            \end{figure}
        \end{center}
    }
\end{frame}

\begin{frame}{Using ImageMagick}
    \begin{block}{Command}
        \texttt{convert tux.png tux.jpg}
    \end{block}

    \splitslide{0.5}{.7em}{
        \begin{center}
            \includegraphics[scale=0.4]{graphics/tux/tux.png}

            (before)
        \end{center}
    }{
        \begin{center}
            \includegraphics[scale=0.4]{graphics/tux/tux.jpg}

            (after)
        \end{center}
    }

    Now this Tux is a JPEG! JPEG doesn't have transparency; default black
    background.
\end{frame}

\begin{frame}{Using ImageMagick}
    \begin{block}{Command}
        \texttt{convert tux.jpg -quality 3 tux-lq.jpg}
    \end{block}

    \splitslide{0.5}{.7em}{
        \begin{center}
            \includegraphics[scale=0.4]{graphics/tux/tux.jpg}

            (before)
        \end{center}
    }{
        \begin{center}
            \includegraphics[scale=0.4]{graphics/tux/tux-lq.jpg}

            (after)
        \end{center}
    }
\end{frame}

\begin{frame}{JPEG Comparison}
    \begin{center}
        Qualities: 50, 10, 5, 1

        \includegraphics[scale=0.32]{graphics/tux/tux-q50.jpg}
        \includegraphics[scale=0.32]{graphics/tux/tux-q10.jpg}
        \includegraphics[scale=0.32]{graphics/tux/tux-q5.jpg}
        \includegraphics[scale=0.32]{graphics/tux/tux-q1.jpg}
    \end{center}
\end{frame}

\begin{frame}{Using ImageMagick}
    \begin{block}{Command}
        \texttt{convert tux.png -crop '60x100+80+20' tux-crop.png}
    \end{block}

    \splitslide{0.5}{.7em}{
        \begin{center}
            \includegraphics[scale=0.4]{graphics/tux/tux.png}

            (before)
        \end{center}
    }{
        \begin{center}
            \includegraphics[scale=0.4]{graphics/tux/tux-crop.png}

            (after)
        \end{center}
    }
\end{frame}

\begin{frame}{Using ImageMagick}
    \begin{block}{Command}
        \texttt{convert tux.png -blur 100x4 tux-blurry.png}
    \end{block}

    \splitslide{0.5}{.7em}{
        \begin{center}
            \includegraphics[scale=0.4]{graphics/tux/tux.png}

            (before)
        \end{center}
    }{
        \begin{center}
            \includegraphics[scale=0.4]{graphics/tux/tux-blurry.png}

            (after)
        \end{center}
    }

    Note: blur argument is [radius]x[sigma] for Gaussian distribution
\end{frame}

\begin{frame}{Using ImageMagick}
    \begin{block}{Command}
        \texttt{convert tux.png -region '80x120+70+10' \textbackslash \\ -blur 100x10 tux-censor.png}
    \end{block}

    \splitslide{0.5}{.7em}{
        \begin{center}
            \includegraphics[scale=0.4]{graphics/tux/tux.png}

            (before)
        \end{center}
    }{
        \begin{center}
            \includegraphics[scale=0.4]{graphics/tux/tux-censor.png}

            (after)
        \end{center}
    }
\end{frame}

\begin{frame}{Using ImageMagick}
    \begin{block}{Command}
        \texttt{convert tux.png -noise 5 -contrast -contrast \textbackslash \\ -sharpen 10x5 -posterize 2 -swirl -100 \textbackslash \\ -sharpen 10x5 tux-wackiest.png}
    \end{block}

    \splitslide{0.5}{.7em}{
        \begin{center}
            \includegraphics[scale=0.4]{graphics/tux/tux.png}

            (before)
        \end{center}
    }{
        \begin{center}
            \includegraphics[scale=0.4]{graphics/tux/tux-wackiest.png}

            (after)
        \end{center}
    }

    This is Tux after being told that \censor{they saved another A-Press} and
    that \censor{there are only 13 left}.
    % No kidding, this happened just hours ago. I've been waiting, like, my
    % whole life to see them save the JRB chest star A-Press.
\end{frame}

\begin{frame}{Using ImageMagick}
    The point is, you can do a lot of cool stuff with ImageMagick!

    And, since it has a nice CLI, you can even write it into scripts! \\ \\

    \pause

    Looking around on the Internet, I found a Deep-Frying script:

    \tiny
    https://gist.github.com/44100hertz/ec0af5c47b4620966b732e72adad33dc
    \large
\end{frame}

\section{Videos}

\begin{frame}{What's a video?!}
    A video is a series of images displayed in order. Your brain is tricked
    into thinking it's actual motion!

    \begin{center}
        \begin{figure}
            \includegraphics[scale=1.0]{graphics/fiji-gif/fiji-10.png}
            \includegraphics[scale=1.0]{graphics/fiji-gif/fiji-13.png}
            \includegraphics[scale=1.0]{graphics/fiji-gif/fiji-16.png}
            \includegraphics[scale=1.0]{graphics/fiji-gif/fiji-19.png}
            \includegraphics[scale=1.0]{graphics/fiji-gif/fiji-22.png}
            \includegraphics[scale=1.0]{graphics/fiji-gif/fiji-25.png}
            \caption{Bouncy Fiji Frames}
            \label{fig:BouncyFiji}
        \end{figure}
    \end{center}

    These videos are often also accompanied by audio.
\end{frame}

\begin{frame}{Video Encoding}
    Several ways of encoding videos:
    \begin{itemize}[&lt;+-&gt;]
        \item MP4: Good balance of quality and file size, lossy
        \item MOV: Better quality but larger files, lossy
        \item AVI: Very high quality and large files, potentially lossless
    \end{itemize}
    
    Some of the previously mentioned image formats like GIF and WebM can also
    hold videos!
\end{frame}

\begin{frame}{Video Compression}
    Although a video is a series of images, it's often not practical to store
    it that way.

    As an example, MP4 splits the video frames into smaller blocks of pixels,
    and does the following:
    \begin{itemize}[&lt;+-&gt;]
        \item If a block isn't changed, it can just be marked as unchanged
        \item If a block has just moved, it can be marked as such
        \item If a block is all (nearly) one color, can be "smoothed" to that
            one color
    \end{itemize}
\end{frame}

\section{Video Processing}

\begin{frame}{Video Editing}
    Like with images, there are several good* softwares for editing videos on
    Linux:
    \begin{itemize}
        \item OpenShot: Simpler editor, but good for beginners
        \item Flowblade: Built in Python, made to be lightweight
        \item Lightworks: More professional tool, but not entirely free
        \item Blender: Popular choice for 3D rendering and videos
    \end{itemize}

    But, like with image editing, we're not too concerned with these.

    \tiny *I haven't used any of these. Take what I say with a grain of salt! \large
\end{frame}

\begin{frame}{FFmpeg}
    \splitslide{0.6}{.7em}{
        Instead we'll be talking about the \\ FFmpeg CLI!

        FFmpeg is a tool for viewing, modifying, and otherwise using different
        media formats, and it is compatible with a very wide range of
        filetypes.
    }{
        \begin{center}
            \begin{figure}
                \includegraphics[scale=0.1]{graphics/ffmpeg-icon.png}
                \caption{FFmpeg Logo}
                \label{fig:FFmpegLogo}
            \end{figure}
        \end{center}
    }
\end{frame}

\begin{frame}{Using FFmpeg}
    The basic structure of a command using \texttt{ffmpeg}:

    \begin{block}{Command}
        \texttt{ffmpeg -i [inputfile] [flags] [outputfile]}
    \end{block}

    \begin{itemize}
        \item inputfile: The file(s) as input. Can be video or audio files
        \item flags: The flags that modify/use the input file
        \item outputfile: The file(s) as output. Can be video or audio files
    \end{itemize}
\end{frame}

\begin{frame}{Using FFmpeg}
    View info on a file:

    \begin{block}{Command}
        \texttt{ffmpeg -i ball.mp4}
    \end{block}
\end{frame}

\begin{frame}{Using FFmpeg}
    Convert between filetypes:

    \begin{block}{Command}
        \texttt{ffmpeg -i ball.mp4 ball.mov}
    \end{block}
\end{frame}

\begin{frame}{Using FFmpeg}
    Crop the video starting at 00:05, for 3 seconds:

    \begin{block}{Command}
        \texttt{ffmpeg -i ball.mp4 -ss 00:05 -t 3 ball-cut.mp4}
    \end{block}
\end{frame}

\begin{frame}{Using FFmpeg}
    Put an audio file over a video:

    \begin{block}{Command}
        \texttt{ffmpeg -i ball.mp4 -i rain.mp3 -shortest \textbackslash \\ -c:v copy -c:a copy rain-ball.mp4}
    \end{block}
\end{frame}

\begin{frame}{Using FFmpeg}
    Make the audio twice as loud!!!

    \begin{block}{Command}
        \texttt{ffmpeg -i rain.mp3 -af 'volume=2.0' loud-rain.mp3}
    \end{block}
\end{frame}

\begin{frame}{Using FFmpeg}
    Give that video a different aspect ratio:

    \begin{block}{Command}
        \texttt{ffmpeg -i ball.mp4 -aspect 16:9 wide-ball.mp4}
    \end{block}
\end{frame}

\begin{frame}{Using FFmpeg}
    Make the video brighter:

    \begin{block}{Command}
        \texttt{ffmpeg -i ball.mp4 -vf 'eq=brightness=0.3' ball-bright.mp4}
    \end{block}
\end{frame}

\begin{frame}{Using FFmpeg}
    Make the video... creepy:

    \begin{block}{Command}
        \texttt{ffmpeg -i ball.mp4 -vf \textbackslash \\ 'eq=brightness=0.2:saturation=2.0:contrast=2.0, \textbackslash \\ noise=alls=80:allf=t+u' ball-creepy.mp4}
    \end{block}
\end{frame}

\begin{frame}{Using FFmpeg}
    To learn more about using FFmpeg, I recommend looking at the documentation and looking up examples to get a feel for how it inputs, modifies, and outputs data. \\ \\

    \pause
    Either way, it's a good tool for quickly modifying different files without having to pull them into a larger video editing software suite.
\end{frame}

\begin{frame}{Resources}
    \begin{itemize}
        \item ImageMagick CLI guide: \\ \tiny https://imagemagick.org/script/command-line-processing.php \\ \large
        \item FFmpeg CLI documentation: \\ \tiny https://ffmpeg.org/ffmpeg.html \\ \large
        \item FFmpeg common commands: \\ \tiny https://ostechnix.com/20-ffmpeg-commands-beginners \\ \large
    \end{itemize}
\end{frame}

\begin{frame}{References}
    \tiny
    \begin{itemize}
        \item https://www.instructables.com/How-to-Create-Programs-on-Your-Calculator/
        \item https://blog.hubspot.com/insiders/different-types-of-image-files
        \item https://www.britannica.com/technology/JPEG
        \item https://www.youtube.com/watch?v=49\_BX4HeIw4
        \item https://en.wikipedia.org/wiki/Raw\_image\_format
        \item https://mse.redwoods.edu/darnold/math45/laproj/fall2006/iancraig/SVD\_paper.pdf
        \item https://www.computer.org/publications/tech-news/trends/8-best-video-file-formats-for-2020/
        \item https://www.computerscience.gcse.guru/theory/mp4-video-compression
        \item https://en.wikipedia.org/wiki/YUV
    \end{itemize}
    \large
\end{frame}

% actual full list of references that wouldn't fit in the presentation:
% https://video.stackexchange.com/questions/4563/how-can-i-crop-a-video-with-ffmpeg
% https://superuser.com/questions/556029/how-do-i-convert-a-video-to-gif-using-ffmpeg-with-reasonable-quality
% https://superuser.com/questions/1009969/how-to-extract-a-frame-out-of-a-video-using-ffmpeg
% https://imagemagick.org/
% https://www.merriam-webster.com/dictionary/image
% https://blog.hubspot.com/insiders/different-types-of-image-files
% https://en.wikipedia.org/wiki/BMP_file_format
% https://netpbm.sourceforge.net/doc/ppm.html
% https://www.britannica.com/technology/JPEG
% https://developers.google.com/speed/webp
% https://en.wikipedia.org/wiki/WebP
% https://www.youtube.com/watch?v=49_BX4HeIw4
% https://en.wikipedia.org/wiki/Raw_image_format
% https://mse.redwoods.edu/darnold/math45/laproj/fall2006/iancraig/SVD_paper.pdf
% https://en.wikipedia.org/wiki/Singular_value_decomposition#Reduced_SVDs
% https://www.tecmint.com/best-image-photo-editors-for-linux/
% https://en.wikipedia.org/wiki/Krita
% https://en.wikipedia.org/wiki/Pinta_(software)
% https://www.computer.org/publications/tech-news/trends/8-best-video-file-formats-for-2020/
% https://www.computerscience.gcse.guru/theory/mp4-video-compression
% https://en.wikipedia.org/wiki/YUV

\end{document}
</pre></body></html>