[Tex/LaTex] Can’t label an image in subfigure

cross-referencingsubfloats

I have been trying to label images in subfigures and then reference them in the caption of the main figure environment. But I get error "Label without proper reference" and "reference undefined error" for all the three subfigures. Can anyone find out the problem?

\begin{figure}[t]
\begin{subfigure}{0.3\linewidth}
 \includegraphics[width=\linewidth]{./Figures/img1}
\label{fig:original}
\end{subfigure}
\begin{subfigure}{0.3\linewidth}
\includegraphics[width=\linewidth]{./Figures/img2}
\label{fig:smooth}
\end{subfigure}
\begin{subfigure}{0.3\linewidth}
\includegraphics[width=\linewidth]{./Figures/img3}
\label{fig:binarySkeleton}
\end{subfigure}
\caption{\ref{fig:original}Image 1 \ref{fig:smooth}image 2 \ref{fig:binarySkeleton} Image 3 }
\label{fig:pre-processing}
\end{figure}

Best Answer

If you have images/plots that has labels a, b, c in them, and you don't need captions, then you can use {\phantomsubcaption\label{subfiglabel}}. For example:

enter image description here

\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\includegraphics[width=0.3\linewidth]{example-image-a}\hfill
\includegraphics[width=0.3\linewidth]{example-image-b}\hfill
\includegraphics[width=0.3\linewidth]{example-image-c}
{\phantomsubcaption\label{first subfig}}
{\phantomsubcaption\label{second subfig}}
{\phantomsubcaption\label{third subfig}}
\caption{...}
\label{full fig}
\end{figure}

See fig.~\ref{full fig}, which contains \ref{first subfig}, \ref{second subfig} and \ref{third subfig}.
\end{document}