I am trying to create a complicated pseudocode as shown below:
My attempt:
\documentclass{article}
\usepackage{algorithm}% http://ctan.org/pkg/algorithm
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx
\begin{document}
\begin{algorithm}
\caption{Self-Quotient algorithm}\label{euclid}
\begin{algorithmic}[1]
%-------------- Input & Output -----------------
\State \textbf{Input:} Input image \textbf{I}, Gaussian filter \textbf{G} of size \textit{s}$\times$\textit{s}
\State \textbf{Output:} Self-Quotient image \textbf{Q}
%--------------- for loop -----------------------
\For{\textbf{all} pixel \textbf{I}$(x,y)$}
\State Consider a window \textbf{W} of size s$\times$s around \textbf{I}$(x,y)$
\State Compute the anisotropic filter $\textbf{F}_{\textbf{W}(x,y)}$ at the location $(x,y)$
\State $\textbf{F}_{\textbf{W}(x,y)}$ = \{ \textbf{G}$(x,y)$ if \textbf{W}$(x,y)\geq$ Mean(\textbf{W})
\State $\textbf{Z}(x,y)$ = $\Sigma\Sigma( \textbf{F}_{\textbf{W}(x,y)} \circ \textbf{W}(x,y) )$
\State Compute the weight \textbf{w}
\State \textit{w} = ( \textit{s} $\times$ \textit{s} ) $\times \Sigma\Sigma \textbf{F}_\textbf{W}$
\EndFor
%----------- Remaining text ----------------
\State Compute Self-Quotient image \textbf{Q} and correct singularities
\State \textbf{Q} =
\State Adjust histogram and normalize image \textbf{Q}
\end{algorithmic}
\end{algorithm}
\end{document}
This is the output:
I am not able to do a few things:
-
Remove line numbers on the left
-
curly braces in line 6: statement incomplete
-
size of Sigma in line 7 not like what I want. Also line 9 same problem.
-
creating the 2nd-last line (line 12)
Could someone please fix this? I have tried a lot!!!
Best Answer
The following provides the output that you want:
Regarding your outstanding issues, here are the remedies:
Use
\begin{algorithmic}[0]
;Use
\left\{\begin{array}{cl} ... \end{array}\right.
or thecases
environment supplied byamsmath
;Use
\sum
, not\Sigma
;Use
\frac{<numerator>}{<denominator>}
or\tfrac
(also fromamsmath
).