1 % /solutions/conference-talks/conference-ornate-20min.fr.tex, 22/02/2006 De Sousa
3 %\documentclass[red]{beamer}
4 \usepackage{pgf,pgfarrows,pgfnodes,pgfautomata,pgfheaps,pgfshade}
5 \usepackage{amsfonts,amsmath,amssymb,stmaryrd}
6 \usepackage[latin1]{inputenc}
7 \usepackage[T1]{fontenc}
8 %\usepackage[frenchb]{babel}
11 \usepackage{amsmath,amssymb}
16 %\usepackage{figlatex}
21 %\usepackage[vlined,longend,algoruled,titlenumbered,french]{algorithm2e}
22 \usepackage[vlined,french,algoruled]{algorithm2e}
23 \usepackage[gen]{eurosym}
26 % ___| |_ _ _| | ___ ___| |_ ___ ___ _ _| | ___ _ _ _ __ ___
27 % / __| __| | | | |/ _ \ / _ \ __| / __/ _ \| | | | |/ _ \ | | | '__/ __|
28 % \__ \ |_| |_| | | __/ | __/ |_ | (_| (_) | |_| | | __/ |_| | | \__ \
29 % |___/\__|\__, |_|\___| \___|\__| \___\___/ \__,_|_|\___|\__,_|_| |___/
33 \setbeamercovered{transparent}
35 % enlever [red] dans le \documentclass si utilisation de la suite :
36 \usecolortheme[RGB={202,31,39}]{structure} % rouge
38 %\setbeamertemplate{background}{\includegraphics[height=96mm,width=128mm]{fond.png}}
40 % definition de la couleur du fond des blocks
41 \definecolor{ArrierePlanBodyW}{rgb}{0.5,0.5,0.5} % si ecriture blanche
42 \definecolor{ArrierePlanBodyB}{rgb}{0.85,0.85,0.85} % si ecriture noire
43 % definition de la couleur des slides
44 \definecolor{ArrierePlan}{rgb}{0.9,0.9,0.9}
46 % selection de la couleur du fond des slides
47 \setbeamercolor{background canvas}{bg=ArrierePlan}
48 % selection de la couleur du fond des block avec ecriture noire
49 %\setbeamercolor{block body}{use=structure,fg=black,bg=ArrierePlanBodyB}
50 % selection de la couleur du fond des block avec ecriture blanche
51 \setbeamercolor{block body}{use=structure,fg=white,bg=ArrierePlanBodyW}
54 \DeclareGraphicsExtensions{pdf,eps,jpg,png}
55 \graphicspath{{.}{./fig/}{img/}}
57 \defbeamertemplate*{footline}{section in head/foot}
60 \hbox{\begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex,leftskip=.3cm plus1fill,rightskip=.3cm]{author in head/foot}%
61 \usebeamerfont{author in head/foot}\insertshortauthor
63 \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex,leftskip=.3cm,rightskip=.3cm plus1fil]{title in head/foot}%
64 \usebeamerfont{title in head/foot}\insertshorttitle \hfill \insertframenumber{} / \inserttotalframenumber\hspace*{2ex}%
65 \end{beamercolorbox}}%
70 \setbeamercovered{dynamic}
71 %\logo{\includegraphics[height=1cm]{./img/logo_petit-tr.png}}
72 % \defbeamertemplate*{headline}{split theme}
74 % \begin{beamercolorbox}{section in head/foot}
75 % \insertsectionnavigationhorizontal{2cm}{\includegraphics[height=2cm]{./img/logo_petit-tr.png}}{}
76 % \end{beamercolorbox}%
79 \defbeamertemplate*{headline}{page title}{
81 \begin{beamercolorbox}[wd=.08\paperwidth,ht=1.45cm]{section in head/foot}%
82 \vbox to 1.45cm{\vfill\hspace*{-0.1mm}\includegraphics[height=1.45cm]{./img/logo_fresnel.pdf}\vfill}%
84 \begin{beamercolorbox}[wd=.655\paperwidth,ht=1.45cm]{section in head/foot}%
85 \vbox to 1.45cm{\vfill\hspace*{-0.1mm}\includegraphics[height=1.45cm]{./img/UPC.jpg}\vfill}%
87 \begin{beamercolorbox}[wd=.1\paperwidth,ht=1.45cm]{section in head/foot}%
88 \vbox to 1.45cm{\vfill\hspace*{1mm}\includegraphics[height=1.25cm]{./img/lifc.pdf}\vfill}%
90 \begin{beamercolorbox}[wd=.17\paperwidth,ht=1.45cm]{section in head/foot}%
91 \vbox to 1.45cm{\vfill\hspace*{-0.1mm}\includegraphics[height=1.45cm]{./img/ufc2.pdf}\vfill}%
95 \defbeamertemplate*{headline}{section in head/foot}
98 \begin{beamercolorbox}[wd=.1\paperwidth,ht=1.45cm]{section in head/foot}%
99 \vbox to 1.45cm{\vfill\hspace*{-0.1mm}\includegraphics[height=1.25cm]{./img/lifc.pdf}\vfill}%
100 \end{beamercolorbox}%
101 \begin{beamercolorbox}[wd=.39\paperwidth,ht=1.45cm]{section in head/foot}%
102 \vbox to 1.45cm{\vfil\insertsectionnavigation{.4\paperwidth}\vfil}%
103 \end{beamercolorbox}%
104 \begin{beamercolorbox}[wd=.43\paperwidth,ht=1.45cm]{subsection in head/foot}%
105 \vbox to 1.45cm{\vfil\insertsubsectionnavigation{.4\paperwidth}\vfil}%
106 \end{beamercolorbox}%
107 %\begin{beamercolorbox}[wd=.17\paperwidth,ht=1.45cm]{section in head/foot}%
108 % \vbox to 1.45cm{\vfill\hspace*{-0.1mm}\includegraphics[height=1.45cm]{./img/ufc2.pdf}\vfill}%
109 %\end{beamercolorbox}%
110 %\begin{beamercolorbox}[wd=.235\paperwidth,ht=1.45cm]{section in head/foot}%
111 % \vbox to 1.45cm{\vfill\hspace*{-0.1mm}\includegraphics[height=1.45cm]{./img/UPC.jpg}\vfill}%
112 %\end{beamercolorbox}%
113 \begin{beamercolorbox}[wd=.1\paperwidth,ht=1.45cm]{section in head/foot}%
114 \vbox to 1.45cm{\vfill\includegraphics[height=1.45cm]{./img/logo_fresnel.pdf}\vfill}%
115 \end{beamercolorbox}%
128 \newcounter{labelExo}
130 \newcommand{\Exos}[1]{\stepcounter{exo}{\vspace{0.5cm}
131 {\textbf{Exercice \arabic{exo}~:\ #1}}}}
133 \newcommand{\Solution}{\vspace{0.5cm}
134 {\textbf{\emph{Solution de l'exercice \arabic{exo}}}}}
141 \newcounter{labelDef}
143 \renewcommand{\Definition}[1]{\stepcounter{def}{%\vspace{0.5cm}
144 {\textbf{Définition \arabic{def}~:\ #1 }}}}
151 \def\Q{I\kern-0.60em Q}
152 \def\C{I\kern-0.60em C}
153 \def\F{I\kern-0.20em F}
154 \def\K{I\kern-0.20em K}
156 % fleche d'affectation pour les algo
157 \def\plv{$ \leftarrow$\hspace{1ex}}
161 %% \parbox{.165\textwidth}{%
162 %% \includegraphics[width=0.165\textwidth]{logo-2lignes-moyen-tr.png}}
164 %%\parbox{.22\textwidth}{%
165 %% \includegraphics[width=0.11\textwidth]{logo_tutelle4.jpg}}
167 %\parbox{.22\textwidth}{
168 % \includegraphics[width=0.11\textwidth]{logo_petit-tr.png}}
170 \parbox{.5\textwidth}{%
171 \includegraphics[width=0.5\textwidth]{CITLogo2.jpg}}
177 \title[Snake GPU] % (facultatif, à utiliser uniquement si le titre de l'article est trop long)
178 {\scshape GPU-accelerated snake}
180 \subtitle {GPU implementation of a region-based segmentation algorithm (snake) for large images}
182 \author[G. Perrot] % (facultatif, à utiliser seulement avec plusieurs auteurs)
183 {Gilles Perrot$¹$, Stéphane Domas$¹$, Raphaël Couturier$¹$, Nicolas Bertaux$²$.}
184 % - Composez les noms dans l'ordre dans lequel ils apparaîtrons dans l'article
185 % - Utilisez la commande \inst{?} uniquement si les auteurs ont des affiliations
188 \institute[] % (facultatif mais généralement nécessaire)
190 $¹$University of Franche-Comté - Distributed Numerical Algorithmics group (AND),\\
191 $²$Fresnel Institute - Physics and Image Computing group (PhyTI)
193 % - Utilisez la commande \inst uniquement s'il y a plusieurs affectations
194 % - Faîtes quelque chose de simple, personne ne s'intéresse à votre adresse.
196 \date[] % (facultatif)
197 {\small 31 august - 1 september}
200 % Inséré uniquement dans la page d'information du fichier PDF. Peut être
205 % Si vous avez un fichier nommé "université-logo-nomfichier.xxx", où xxx
206 % est un format graphique accepté par latex ou pdflatex (comme par exemple .png),
207 % alors vous pouvez insérer votre logo ainsi :
209 %\pgfdeclareimage[height=1cm]{logo-lifc}{img/logo-lifc.jpg}
210 %\logo{\pgfuseimage{logo-lifc}}
214 % À supprimer si vous ne voulez pas que la table des matières apparaisse
215 % au début de chaque sous-section :
217 % \AtBeginSubsection[] {
218 % \begin{frame}<beamer>{Lignes directrices}
219 % \tableofcontents[currentsection,currentsubsection]
224 % Si vous souhaitez recouvrir vos transparents un à un,
225 % utilisez la commande suivante (pour plus d'info, voir la page 74 du manuel
226 % d'utilisation de Beamer (version 3.06) par Till Tantau) :
228 %\beamerdefaultoverlayspecification{<+->}
229 \colorlet{textvert}{green}
233 \setbeamertemplate{headline}[page title]
234 \setbeamertemplate{footline}[default]
236 \begin{frame}[default]
241 \begin{frame}{Table of contents}
243 % Vous pouvez, si vous le souhaitez ajouter l'option [pausesections]
246 \setbeamertemplate{headline}[section in head/foot]
247 \setbeamertemplate{footline}[section in head/foot]
250 \begin{frame}{Image segmentation}
251 \begin{block}{Definition, goal}
253 \item Dividing an image in two homogeneous regions.
254 \item Reducing the amount of data needed to code information.
255 \item Helping the human perception in certain cases.
260 \begin{frame}{Images of our interest}
261 \begin{block}{Origins}
263 \item Synthetic Aperture RADAR (S.A.R.),
264 \item Ultrasonic (medical imaging),
265 \item Photographic (IR, nightshots).
268 \begin{block}{Characteristics}
270 \item 16 bit-coded gray levels,
271 \item From 10~Mpixels to more than 100~Mpixels,
277 \section{Snake algorithm}
279 % \begin{frame}{Active contour hypothesis}
281 % \item A background region $B$ and a target region $T$, containing $n_T$ and $n_B$ pixels, compose a $L x H$ pixel image.
282 % \item Probability density functions (PDF) $p^B$ and $p^T$ are of the same family (Gaussian in this example).
283 % % inutile ds les hypotheses, on ne dit pas qu'on ls connait
284 % %\item Vectors of parameters $\Theta^B$ and $\Theta^T$ of the PDFs $p^B$ and $p^T$ are unknown.
285 % \item The contour $\varGamma$ which surrounds $T$ is chosen polygonal.
286 % \item [\ding{253}] Implementation of a region-based algorithm.
290 \begin{frame}{Algorithm basics : criterion}
292 \begin{column}[l]{5cm}
293 \resizebox{5cm}{5cm}{\input{img/fig_target.pdf_t}}
295 \begin{column}[l]{7.5cm}
297 \item The goal is to find the most likely contour $\varGamma$ (number and positions of nodes).
298 \item The criterion used is a \emph{Generalized Likelihood} one .\\In the Gaussian case, it is given by
299 $$GL = \dfrac{1}{2}\left[ n_B.log\left({\widehat{\sigma_B}}^2\right) + n_T.log\left({\widehat{\sigma_T}}^2\right)\right]$$
300 where $\widehat{\sigma_\Omega}$ is the estimation of the deviation $\sigma$ for the region $\Omega$.
307 % \begin{frame}{Algorithm basics : parameters estimation}
309 % \item In the Gaussian case, $p_{\Omega}$ has two parameters, average and deviation, which are estimated by maximum likelihood.\\
310 % If $z$ is the gray level of the pixel of coordinates $(i,j)$:
314 % \widehat{\mu_{\Omega}} = \frac{1}{n_{\Omega}} \displaystyle\sum_{(i,j)\in \Omega} z(i,j) \\
315 % \widehat{\sigma^2_{\Omega}} = \frac{1}{n_{\Omega}} \displaystyle\sum_{(i,j)\in \Omega} \left(z(i,j) - \widehat{\mu_{\Omega}}\right)^2 \\
319 % \item These estimations have to be computed for each test state of the contour $\varGamma$: time-consuming.
323 \begin{frame}{Algorithm basics : parameters estimation}
325 %peut-être illustrer ici
326 \item Based on the Green-Ostogradsky theorem, Chesnaud has shown how to replace those 2-dimensions sums inside the contour
327 by 1-dimension sums along the contour.
328 \item This optimization implies:
330 \item the precomputation of a few matrices (called cumulated images) containing the potential \emph{contributions} of each pixel of the image,
331 \item the use of constant lookup tables of weighting coefficients to determine the \emph{contributions} of each segment of pixels.
336 % \begin{frame}{CPU sequential implementation : outlines}
338 % \item Precomputation of the cumulated images.
339 % \item Choice of the initial contour $\varGamma_0$: rectangle near the borders.
340 % \item Changes made to the contour in order to find the most likely one:
341 % \begin{enumerate}[i]
342 % \item Move every node as long as it gives a better criterion.
343 % \item Add nodes in the middle of each big enough segment.
348 \begin{frame}{Snake algorithm in action}
350 \begin{column}[T]{7cm}
352 \onslide<1> \includegraphics[width=7cm]{./img/sequences/cochon_it0.png}
353 \onslide<2> \includegraphics[width=7cm]{./img/sequences/cochon_it1.png}
354 \onslide<3> \includegraphics[width=7cm]{./img/sequences/cochon_it21.png}
355 \onslide<4> \includegraphics[width=7cm]{./img/sequences/cochon_it22.png}
356 \onslide<5> \includegraphics[width=7cm]{./img/sequences/cochon_it4.png}
359 \begin{column}[T]{5cm}
362 \item 15~Mpixels image\\(SSE implementation limit).
363 \item Initial contour: 4 nodes.
368 \item End of first iteration: no more move can be of interest.
373 \item Nodes added in the middle of segments.
378 \item End of second iteration.
383 \item End of fifth iteration\\(36 nodes).
391 \section{GPU Implementation}
392 \begin{frame}{GPU implementation: prior knowledge}
394 \item The parallelism of a modern GPU lays on a SIMT paradigm (Single Instruction Multiple Threads): the same instruction
395 is processed by a great number of threads at a time (up to $2^{16}$).
396 \item Threads are compounded in independants blocks with no possible synchronization between blocks.
397 \item Threads in a block share a small amount of shared memory (16-48~KBytes).
398 \item There are restrictive conditions to be fullfilled in order to make efficent accesses to global and shared memory.
399 \item Data transfers between CPU and GPU are slow.
403 \begin{frame}{GPU implementation: precomputations}
405 \item One of the cumulated images is not to be computed anymore: values are evaluated on the fly.
406 \item An inclusive parallel prefixsum is performed on each row of the image for each matrix to be processed ($z$,$z^2$).
407 \item[\ding{253}] Speedup is around x7 for images larger than 100~MPixels. Comparison is done with the SSE/CPU implementation of the PhyTI group.
408 \item[\ding{253}] Higher speedups (x15) are obtained with specific versions for constant image sizes.
413 \begin{frame}{GPU implementation: nodes move}
414 To select the possible next position of a node:
416 \item Parameters of the corresponding contour have to be estimated.
417 \item Then the value of the criterion can be obtained and compared with the previous one.
418 \item The parallelization needs reside essentially in the parameters estimation.\\Two possible parallelism levels:
420 \item One contour per thread.
421 \item One pixel per thread.
422 \item[\ding{253}] The \emph{one pixel per thread} rule is far more efficient, due to memory access constraints.
428 \begin{frame}{GPU implementation: parallelization}
430 \begin{column}[T]{6cm}
431 \resizebox{6cm}{6cm}{\input{./img/topologie.pdf_t}}
433 \begin{column}[T]{6.5cm}
435 \item Every 16 segments for every even/odd nodes are processed in parallel.
436 \item Fits GPU specific parallelism: each pixel is processed by a thread.
442 \begin{frame}{GPU implementation: data structure}
443 The main idea is to organize, in a single array, every pixels of every segments to be processed.\\
444 Thus, for a given state of the contour ($N$ nodes), we:
446 \item Find the largest segment to be processed. It gives:
448 \item the block size $bs$ of the computing grid,
449 \item the number of blocks needed for each segment ($N_{TB}$).
451 \item Compute in parallel, the coordinates of every pixels of the $16.N$ segments to be considered,
452 \item Make some parallel reductions to finally obtain parameters estimation.
456 \begin{frame}{GPU implementation: data structure}
459 \onslide<1> \resizebox{8cm}{1.43cm}{\input{img/contribs_segments_seg.pdf_t}}
460 \onslide<2> \resizebox{8cm}{3.78cm}{\input{img/contribs_segments_16seg.pdf_t}}
461 \onslide<3> \resizebox{8cm}{6cm}{\input{img/contribs_segments_even.pdf_t}}
462 \onslide<4> \resizebox{8cm}{6cm}{\input{img/contribs_segments.pdf_t}}
467 \begin{frame}{GPU implementation: first results}
469 \item Global speedup around x7-x8 for image sizes from 15 to 150~Mpixels.
470 \item First iterations have higher speedups:
472 \item several large segments,
473 \item few inactive threads in the grid.
475 \item Last iterations are sometimes slower than on CPU:
477 \item a lot of small segments,
478 \item more inactive threads in the grid.
483 \begin{frame}{GPU implementation: smart init (reasons)}
485 \item The target shape is often far from initial contour,
486 \item It causes the very first iteration to be much more time-consuming than the other ones.
487 \item Horizontal segments contributions are null.
488 \item Vertical segments contributions computations can be fast, through a specific process.
489 \item[\ding{253}] It's fast to find a rectangle near the target.
493 \begin{frame}{GPU implementation: smart init (process)}
495 \begin{column}[l]{7cm}
496 \resizebox{7cm}{6.75cm}{\input{img/smart_init1.pdf_t}}
498 \begin{column}[l]{5.5cm}
500 \item Realize a periodic sampling of a few hundreds of J-coordinates.
501 \item Evaluate in parallel every possible rectangle of diagonal $(0 , j_L)-(H , j_H)$.
502 \item Select the one with the best GL criterion.
503 \item $j_L$ and $j_H$ are now considered as constants.
509 \begin{frame}{GPU implementation: smart init (process)}
511 \begin{column}[l]{7cm}
512 \resizebox{7cm}{6.75cm}{\input{img/smart_init2.pdf_t}}
514 \begin{column}[l]{5.5cm}
516 \item Given $j_L$ and $j_H$.
517 \item Realize a periodic sampling of a few hundreds of I-coordinates.
518 \item Evaluate in parallel every possible rectangle of diagonal $(i_L , j_L)-(i_H , j_H)$.
519 \item Select the one with the best GL criterion.
525 \begin{frame}{GPU implementation: enhancement}
527 \item Global speedup around x10 for image sizes from 15 to 150~Mpixels and a small enough target (as in the example)
528 \item Less than 0.6 second for the 150~Mpixels image of this example.
533 \begin{frame}{Conclusion, future works}
535 \item Interesting speedups
536 \item Original algorithm is not GPU-friendly
539 \item Finding a more suited structure to describe the contour.
540 \item Switching to a statistical model independant from a PDF: the potts model.
541 \item Benefit from recent features of CUDA v4 (overlapping, multiple kernels)
542 \item Extend to a multiple targets algorithm, based on this single target elementary piece of code.
548 %\begin{frame}[allowframebreaks]{References}
549 %\bibliographystyle{plain}
550 %\bibliography{biblio}