# What is the correct code this algorithm in latex

\documentclass{article}
\usepackage{amsmath}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}

\makeatletter
\def\BState{\State\hskip-\ALG@thistlm}
\makeatother

\begin{document}
\begin{algorithm}
\caption{ROI}\label{euclid}
\begin{algorithmic}[1]
\Procedure{MyProcedure Region of interest (ROI_1)}{}
\State $\textit{Image_1} \gets \text{camera }\textit{image}$
\State $i \textit{ROI_1} \gets \text{trimmed}\textit{scale image}$
\BState \emph{image_1}
\State $i \textit{ROi_2} \gets \text{trimmed image}\textit{from ROI_1}$
\State $i \textit{image_2} \gets \text{ROI_2}$
\EndProcedure
\end{algorithmic}
\end{algorithm}
\end{document}


I wrote this referring to this Write pseudo code in latex. I included the below listed packages:

Could anyone help me correct this.

• please merge showed code fragments to one complete but small document, which we can compile as it is. to lines which you not know, for what they serves, indicate with some comments. – Zarko May 8 at 15:29

do you like obtain the following result?

the mwe (minimal working example) for above result is:

\documentclass{article}
\usepackage{amsmath}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}

\begin{document}
\begin{algorithm}
\caption{ROI}\label{euclid}
\begin{algorithmic}
\Procedure{MyProcedure Region of interest (ROI$_1$)}{}
\State Image$_1$ $\gets$ Camera Image
\State ROI$_1$   $\gets$ Trimmed Scale Image
\If {ROI$_1$ is Found}
\State {Draw Rectangle around Image$_1$}
\EndIf
\State ROI$_2$ $\gets$ Trimmed Image from ROI$_1$
\State Image$_2$ $\gets$ ROI$_2$
\EndProcedure
\end{algorithmic}
\end{algorithm}
\end{document}


basic information about algorithm and algorithmic you can find in WIKIBOOKS

• Thanks for your help!! it worked – sreeramp96 May 8 at 16:20