Fix Array out of bounds when detecting in 2D images.

Signed-off-by: Jean-Yves Tinevez <jean-yves.tinevez@pasteur.fr>
Change the name of nested class to avoid confusion.

Signed-off-by: Jean-Yves Tinevez <jean-yves.tinevez@pasteur.fr>