Add report for Assignment1

This commit is contained in:
Citlali del Rey 2024-04-30 13:56:02 -07:00
parent 923dd2e2a5
commit 79550d0612
Signed by: nullobsi
GPG Key ID: 933A1F44222C2634
4 changed files with 116 additions and 0 deletions

BIN
Assignment1/lenna.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

116
Assignment1/report1.tex Normal file
View File

@ -0,0 +1,116 @@
%! TeX program = lualatex
\RequirePackage[l2tabu,orthodox]{nag}
\DocumentMetadata{lang=en-US}
\documentclass[a4paper]{scrarticle}
\usepackage{geometry}
%\usepackage{tikz}
%\usepackage{tikz-uml}
\usepackage{hyperref}
\usepackage{caption}
\usepackage{bookmark}
\usepackage{fontspec}
\usepackage{microtype}
\usepackage{graphicx}
% Math packages
%\usepackage{amsmath}
%\usepackage{mathtools}
%\usepackage{amsthm}
%\usepackage{thmtools}
%\usepackage{lualatex-math}
% Unicode Math
\usepackage[warnings-off={mathtools-colon,mathtools-overbracket},math-style=ISO]{unicode-math}
\usepackage{newcomputermodern}
\newcommand*{\figref}[2][]{%
\hyperref[{fig:#2}]{%
Figure~\ref*{fig:#2}%
\ifx\\#1\\%
\else
\,#1%
\fi
}%
}
%\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
%\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}
%\declaretheorem[within=chapter]{definition}
%\declaretheorem[sibling=definition]{theorem}
%\declaretheorem[sibling=definition]{corollary}
%\declaretheorem[sibling=definition]{principle}
\usepackage{polyglossia}
\usepackage[backend=biber]{biblatex}
\setdefaultlanguage[variant=american,ordinalmonthday=true]{english}
\day=7
\month=2
\year=2024
\title{Assignment 1 Report}
\subtitle{Imperative Programming in C}
\author{Juan Pablo Zendejas}
\date{\today}
\begin{document}
\maketitle
%\tableofcontents
In this assignment, I was tasked with performing image manipulation
using an imperative programming style in C. Using the provided PGM file,
I wrote a program to do a threshold and rotation transformation by
reading the image into a 2D matrix and writing the resulting 2D matrices
to separate files.
\begin{figure}[h]
\centering
\begin{minipage}{0.3\textwidth}
\centering
\includegraphics[width=0.7\linewidth]{lenna.png}
\captionof{figure}{Input file}
\label{fig:lenna}
\end{minipage}%
\begin{minipage}{0.3\textwidth}
\centering
\includegraphics[width=0.7\linewidth]{rotate.png}
\captionof{figure}{Transposed}
\label{fig:transpose}
\end{minipage}%
\begin{minipage}{0.3\textwidth}
\centering
\includegraphics[width=0.7\linewidth]{threshold.png}
\captionof{figure}{Threshold}
\label{fig:thresh}
\end{minipage}%
\end{figure}
In \figref{lenna}, we see the provided input file. \figref{transpose}
represents a transposed or rotated version of the image. Finally,
\figref{thresh} is the image with a threshold value of 80 applied.
Values above 80 in the 0-255 range become white while values below 80
become black.
The assignment did not take too long to complete. While I was creating
the transformation code, I ran into a segmentation fault issue when
attempting to duplicate the matrix with the \texttt{memcpy} function.
Eventually, I discovered that I forgot to use \texttt{malloc} on the
rows to create the 2nd level of the 2D matrix. Once I solved that issue,
the math was fairly simple.
Due to the way the rotation operation was performed using a transpose,
rotating twice would result in the original image. Mathematically, this
is because the transformation is the inverse of itself. Swapping $x$ and
$y$ coordinates twice will result in the coordinates ending in the same
order. Rotating twice would not cause the image to be upside down
because it is not a 90° rotation, but rather a mirroring along the
diagonal of the image.
I did not collaborate during this assignment. I used the UNIX
\texttt{man} pages for documentation on the standard library and did not
use any external library.
\end{document}

BIN
Assignment1/rotate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 KiB

BIN
Assignment1/threshold.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB