[Tex/LaTex] Drawing flow diagram in LaTeX using TikZ

diagramstikz-pgf

I need to draw the following diagram using TikZ package in LaTeX

enter image description here

I wrote the following code so far:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
    \begin{tikzpicture}[auto, node distance=2cm,>=latex']
        \tikzstyle{block} = [draw, rectangle];
        \tikzstyle{rblock}=[draw, shape=rectangle,rounded corners=0.5em];
        \node [rblock] (start) {Start};
        \node [block, right of=start] (acquire) {Acquire Image};
        \node [block, right of=acquire] (rgb2gray) {RGB to Gray};
        \node [block, right of=rgb2gray] (otsu) {Localized OTSU Thresholding};
        \node [block, below of=otsu] (gchannel) {Subtract the Green Channel};
        \node [block, left of=gchannel] (closing) {Morphological Closing};
    \end{tikzpicture}
\end{document}

But the result I get is really bad and all the boxes are on top of each other. Please note, in my code "Subtract the Green Channel" node is below "Localized Otsu Thresholding" but that is also fine, flow diagram can flow either way but preferably the one shown in image.

Could someone please tell me what I'm missing? How can I fix the length of box and let text within them span multiple lines? If possible an someone provide me LaTeX code that could draw flow diagram as shown in image? Any help would be appreciated.

Thanks everyone who answered. I've got this far:

Progress so far

The code I used is below:

\begin{tikzpicture}[>=latex']
    ikzset{block/.style= {draw, rectangle, align=center,minimum width=2cm,minimum height=1cm},
    rblock/.style={draw, shape=rectangle,rounded corners=1em,align=left,minimum width=1.5cm,minimum height=0.75cm},
    input/.style={ % requires library shapes.geometric                                                                                                                                                                                         
      draw,
      trapezium,
      trapezium left angle=60,
      trapezium right angle=120,
      minimum width=2.0em,
      align=center,
      minimum height=1.5em
    },
  }


\node [rblock] (start) {Start};  
\node [block, right =1.75em of start] (acquire) {Acquire Image};

\node [block, right =1.75em of acquire] (rgb2gray) {RGB to Gray};
\node [block, below =1.75em of rgb2gray.south] (otsu) {Localized OTSU \\ Thresholding};
\node [block, left =1.75em  of otsu] (gchannel) {Subtract the Green \ Channel};
\node [block, below left =1.75em of gchannel] (closing) {Morphological \\ Closing};
\node [block, right =1.75em of closing] (NN) {Sign Detection \\ Using NN};
\node [input, right  =1.75em of NN] (limit) {Speed \\ Limit};
\node [coordinate, right =1em of otsu.east] (otsu_right) {};  %% Coordinate on right and middle                                                                                                                                              

  %% paths                                                                                                                                                                                                                                     
  \path[draw,->] (start) edge (acquire)
  (acquire) edge (rgb2gray)
  (rgb2gray.east) -| (otsu_right) -- (otsu.east)
  (otsu) edge  (gchannel)
%  (gchannel) edge (closing)                                                                                                                                                                                                                   
%  (closing) edge (NN)                                                                                                                                                                                                                         
%  (NN) edge (limit)                                                                                                                                                                                                                           
  ;
\end{tikzpicture}

I'm using two column paper style therefore you fit things in, I've putting less number of boxes each line. I want that RGB to Gray node should be right aligned with Localized OTSU node and Morphological opening node left aligned with Subtract Green Channel node. I Please help. Thanks!

Best Answer

You can use positioning library and a useful reading will be this question. Further, tikzstyle is deprecated, use tikzset instead.

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,shapes.geometric}
\begin{document}
    \begin{tikzpicture}[>=latex']
        \tikzset{block/.style= {draw, rectangle, align=center,minimum width=2cm,minimum height=1cm},
        rblock/.style={draw, shape=rectangle,rounded corners=1.5em,align=center,minimum width=2cm,minimum height=1cm},
        input/.style={ % requires library shapes.geometric
        draw,
        trapezium,
        trapezium left angle=60,
        trapezium right angle=120,
        minimum width=2cm,
        align=center,
        minimum height=1cm
    },
        }
        \node [rblock]  (start) {Start};
        \node [block, right =2cm of start] (acquire) {Acquire Image};
        \node [block, right =2cm of acquire] (rgb2gray) {RGB to Gray};
        \node [block, right =2cm of rgb2gray] (otsu) {Localized OTSU \\ Thresholding};
        \node [block, below right =2cm and -0.5cm of start] (gchannel) {Subtract the \\ Green Channel};
        \node [block, right =2cm of gchannel] (closing) {Morphological \\ Closing};
        \node [block, right =2cm of closing] (NN) {Sign Detection \\ Using NN};
        \node [input, right =2cm of NN] (limit) {Speed \\ Limit};
        \node [coordinate, below right =1cm and 1cm of otsu] (right) {};  %% Coordinate on right and middle
        \node [coordinate,above left =1cm and 1cm of gchannel] (left) {};  %% Coordinate on left and middle

%% paths
        \path[draw,->] (start) edge (acquire)
                    (acquire) edge (rgb2gray)
                    (rgb2gray) edge (otsu)
                    (otsu.east) -| (right) -- (left) |- (gchannel)
                    (gchannel) edge (closing)
                    (closing) edge (NN)
                    (NN) edge (limit)
                    ;
    \end{tikzpicture}
\end{document}

enter image description here