[Tex/LaTex] Aligning figures using subfigure Error: Not in outer par mode

floatshorizontal alignmentsubfloats

I am soooo lost! have no idea why I keep getting this error. I have tried almost every combination of subfigure, float, centering but I keep getting "Not in outer par mode" error

\begin{figure}[htp]
 %   \centering
 \noindent\makebox[\textwidth]{
    \begin{subfigure}[b]{0.3\textwidth}
            \centering
            \includegraphics[width=\textwidth]{img/preproc_1.png}
            \caption{Raw Image}
            \label{fig:preproc_1}
    \end{subfigure}%
    ~ %add desired spacing between images, e. g. ~, \quad, \qquad etc. 
      %(or a blank line to force the subfigure onto a new line)
    \begin{subfigure}[b]{0.3\textwidth}
            \centering
            \includegraphics[width=\textwidth]{img/preproc_2.png}
            \caption{Gaussian Smoothing}
            \label{fig:preproc_2}
    \end{subfigure}
    ~ %add desired spacing between images, e. g. ~, \quad, \qquad etc. 
      %(or a blank line to force the subfigure onto a new line)
    \begin{subfigure}[b]{0.3\textwidth}
            \centering
            \includegraphics[width=\textwidth]{img/preproc_3.png}
            \caption{Eigenvalues}
            \label{fig:preproc_3}
    \end{subfigure}
    \caption{Visualization of the preprocessing procedure} \label{fig:preprocessing}
\end{figure}

Best Answer

Your code nearly works, but there's no need for the following line

% \noindent\makebox[\textwidth]{

I've put it together as a complete MWE below- remove the demo option from graphicx when you want the images back in.

\documentclass{article}

\usepackage[demo]{graphicx}
\usepackage{subcaption}


\begin{document}

\begin{figure}[htp]
% \noindent\makebox[\textwidth]{
    \begin{subfigure}[b]{0.3\textwidth}
            \centering
            \includegraphics[width=\textwidth]{img/preproc_1.png}
            \caption{Raw Image}
            \label{fig:preproc_1}
    \end{subfigure}%
    \hfill
    \begin{subfigure}[b]{0.3\textwidth}
            \centering
            \includegraphics[width=\textwidth]{img/preproc_2.png}
            \caption{Gaussian Smoothing}
            \label{fig:preproc_2}
    \end{subfigure}%
    \hfill
    \begin{subfigure}[b]{0.3\textwidth}
            \centering
            \includegraphics[width=\textwidth]{img/preproc_3.png}
            \caption{Eigenvalues}
            \label{fig:preproc_3}
    \end{subfigure}
    \caption{Visualization of the preprocessing procedure} \label{fig:preprocessing}
\end{figure}

\end{document}