cap_segmen.tex 17.9 KB
\chapter{Segmentation}

To select a certain type of tissue from an image it's used the segmentation feature at InVesalius.

\section{Threshold}

Limiar é uma técnica de segmentação de imagens que permite selecionar da imagem somente os \textit{pixels} cuja intensidade está dentro de um limiar definido pelo usuário.  O limiar é definido por dois números, limiares inicial e final, também conhecidos como \textit{thresholds} mínimo e máximo. Como referência para a definição, é utilizada a escala de Hounsfield (tabela \ref{tab:escala_hounsfield}).

In thresholding segmentation technique only the \textit{pixels} whose intensity is inside threshold range defined by the user. Threshold is defined by two number, the initial and final threshold, also known as minimum and maximum threshold. ...

Thresholding segmentation is located at the InVesalius left-panel, item \textbf{2. Select region of interest} (figure~\ref{fig:region_selection}).

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.6]{segmentation_threshold_window_left_pt.png}
\caption{Select region of interest}
\label{fig:region_selection}
\end{figure}

Before starting segment it's necessary to configure a mask. A mask is a image overlayed to exam image where the selected regions are colored. See figure~\ref{fig:region_selection_masc}

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.4]{segmentation_threshold_axial_pt.png}
\caption{Mask - selected region in yellow.}
\label{fig:region_selection_masc}
\end{figure}

To change the threshold you may use the control that represents the image grayscale (figure~\ref{fig:region_selection_bar}). Move the \textit{left} sliding control to change the initial threshold. Move the \textit{right} sliding control to change the final threshold. It's also possible to to digit the desired threshold values in the text boxes in the left and right side of the thresholding control. Changing the thresholding values, automatically the mask will be updated, showing with a color the \textit{pixel} that are inside the thresholding range.


\begin{figure}[!htb]
\centering
\includegraphics[scale=0.75]{segmentation_threshold_bar.png}
\caption{Selecting the \textit{pixels} with intensity between $226$ and $3021$ (Bone)}
\label{fig:region_selection_bar}
\end{figure}

It's also possible to select some predefined thresholding values based on some type of tissues, like displayed in the figure~\ref{fig:limiar_presets}. Just select the desired tissue and the mask automatically updated.

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.65]{segmentation_threshold_presets_pt.png}
\caption{Selection list with some predefined thresholding values.}
\label{fig:limiar_presets}
\end{figure}

The table~\ref{tab:limiar} show thresholding values according to some tissues or materials.

\begin{table}[h]
\centering
\caption{Predefined thresholding values to some materials}
\begin{tabular}{lcc}\\
\hline % este comando coloca uma linha na tabela
Material & Initial threshold & Final Threshold\\
\hline
\hline
Bone & 226 & 3021\\
Compact Bone (Adult) & 662 & 1988\\
Compact Bone (Child) & 586 & 2198\\
Custom & User Def. & User Def.\\
Enamel (Adult) & 1553 & 2850\\
Enamel (Child) & 2042 & 3021\\
Fat Tissue (Adult) & -205 & -51\\
Fat Tissue (Child) & -212 & -72\\
Muscle Tissue (Adult) & -5 & 135\\
Muscle Tissue (Child) & -25 & 139\\
Skin Tissue (Adult) & -718 & -177\\
Skin Tissue (Child) & -766 & -202\\
Soft Tissue & -700 & 225\\
Spongial Bone (Adult) & 148 & 661\\
Spongial Bone (Child) & 156 & 585\\
\hline
\end{tabular}
\label{tab:limiar}
\end{table} 
\newpage

The table~\ref{tab:limiar} is indicated to images obtained from medical tomographs. The range of gray values from images obtained from odontological tomographs are greater and non-regular. Thus, it's necessary to use sliding control (figure~\ref{fig:region_selection_bar}) to adjust the thresholding values.

If you want to create a new mask click on the button \textbf{Create new mask} inside the item  \textbf{2. Select region of interest}. See the figure~\ref{fig:shortcut_new_mask}.

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.2]{object_add_original}
\caption{Button to create a new mask.}
\label{fig:shortcut_new_mask}
\end{figure}

Clicando-se nesse atalho, uma nova janela será apresentada (figure \ref{fig:create_new_mask}).  Selecione a faixa de limiar desejada e clique em \textbf{OK}.

After clicking on this button a dialog will be shown (figure~\ref{fig:create_new_mask}). Select the desired threshold and click on \textbf{Ok}.

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.55]{segmentation_threshold_window_dialog_pt.png}
\caption{Creating a new mask.}
\label{fig:create_new_mask}
\end{figure}

\newpage

After the segmentation it's possible to generate a corresponding 3D surface. The surface is formed by triangles. The following chapter will give more details about surfaces.

Click on the \textbf{Create surface} button (figure~\ref{fig:generate_surface}) to create a new surface. If there is a surface created previously you may overwrite it with the new one. To do this select the option \textbf{Overwrite last surface} before creating the new surface.

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.55]{segmentation_generate_surface_pt.png}
\caption{Create surface button.}
\label{fig:generate_surface}
\end{figure}

After a few moments the surface will be displayed at the 3D visualization window of InVesalius (figure~\ref{fig:surface}).

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.5]{surface_from_threshold.png}
\caption{3D surface.}
\label{fig:surface}
\end{figure}



\section{Manual segmentation (Image edition)}

Thresholding segmentation may not be efficient in some case since it's applied to the whole image. Manual segmentation may be used o segment only an isolated image region. Manual segmentation turns possible to add or remove some image regions to the segmentation. Manual segmentation requires more knowledge of  human anatomy. To use it click on \textbf{Manual edition} (figure~\ref{fig:advanced_edition}) to open the manual segmentation panel.

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.75]{segmentation_manual_label_pt.png}
\caption{Icon to open the Manual segmentation panel.}
\label{fig:advanced_edition}
\end{figure}

Figure~\ref{fig:edition_slices_ref} show the Manual segmentation panel.

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.6]{segmentation_manual_window_pt.png}
\caption{Manual segmentation panel.}
\label{fig:edition_slices_ref}
\end{figure}

There are two brushes used to segmentation: a circle and a square. Click on triangle icon (see figure~\ref{fig:brush_type}) to and click on the desired brush.

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.9]{segmentation_manual_pencil_type.png}
\caption{Brush types.}
\label{fig:brush_type}
\end{figure}

\newpage

It's also possible to adjust the brush size, like shown in the figure~\ref{fig:select_diameter}.

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.8]{segmentation_manual_diameter.png}
\caption{Adjusting the brush size.}
\label{fig:select_diameter}
\end{figure}

É necessário selecionar o tipo de operação que será realizada pelo pincel. As opções são as
seguintes:\\
\\
\textbf{Desenhar}, para pintar uma região que não foi selecionada;\\
\textbf{Apagar}, para remover uma região que foi selecionada;\\
\textbf{Limiar}, para remover uma região que está fora do limiar e foi selecionada, ou pintar
uma região que está dentro do limiar e não foi selecionada.\\

It's needed to select the operation to be performed by the brush. These are the options:

\textbf{Draw}: to add a non-selected region to the segmentation;

\textbf{Erase}: to remove a selected region from the segmentation;

\textbf{Threshold}: applies the thresholding locally, adding or removing a
region if in inside or outside of the threshold range.

Figure~\ref{fig:select_brush_operations} shows the operations.

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.7]{segmentation_manual_pencil_type_operation_type_pt.png}
\caption{Brush operations}
\label{fig:select_brush_operations}
\end{figure}

A figure \ref{fig:noise_amalgaman} mostra um caso em que algumas imagens contêm ruídos causados pela presença de prótese dentária de amálgama no paciente. Observe os "raios" saindo da região da arcada dentária. Isso ocorre porque a máscara de segmentação também seleciona parte dos ruídos, pois eles estão na mesma intensidade do limiar para osso.

Figure~\ref{fig:noise_amalgaman} shows a image with noises caused by the presence of dental prosthesis.

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.3]{segmentation_manual_noise_amalgam.jpg}
\caption{Imagem com ruído segmentada com limiar}
\label{fig:noise_amalgaman}
\end{figure}

A figure \ref{fig:surface_amagaman} ilustra como é uma superfície gerada a partir dessa
segmentação.

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.3]{segmentation_manual_noise_amalgam_3d.jpg}
\caption{Superfície gerada a partir de imagem com ruído}
\label{fig:surface_amagaman}
\end{figure}

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.3]{segmentation_manual_noise_amalgam_3d_zoom.jpg}
\caption{Zoom da região com ruído}
\label{fig:surface_amagaman_zoom}
\end{figure}

\newpage

Em casos como este, utilizando o editor, com o pincel na opção \textbf{Apagar}, mantenha o
botão \textbf{esquerdo} do mouse pressionado enquanto o \textbf{arrasta} sobre a região que
deseja remover (na máscara).

A figure \ref{fig:editor_amalgaman} mostra a imagem da figure \ref{fig:noise_amalgaman} após
edição.

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.3]{segmentation_manual_noise_amalgam_removed.jpg}
\caption{Imagem com ruído removido}
\label{fig:editor_amalgaman}
\end{figure}

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.3]{segmentation_manual_noise_amalgam_removed_3d_zoom.jpg}
\caption{Superfície criada a partir da imagem com ruído removido}
\label{fig:surface_edited_amalgaman}
\end{figure}

\newpage
Realizada a edição, basta gerar a superfície a partir da imagem editada (figure
\ref{fig:surface_edited_amalgaman}). Como houve edição, ao clicar em \textbf{Criar superfície}, será
requerido se deseja gerar a superfície a partir do método \textbf{binário} ou utilizando o método de suavização
\textbf{Suavização sensível ao contexto} (figure \ref{fig:new_surface_edited}) para minimizar os "degraus" na superfície.
Demais detalhes serão discutidos no capítulo \ref{cap_surface}.
%\ref{fig:generate_surface}).

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.5]{surface_generation_dialog_pt.png}
\caption{Método de criação de superfície}
\label{fig:new_surface_edited}
\end{figure}


\section{Watershed}

A segmentação por watershed, necessita que o usuário indique através de marcadores o que é objeto e o que é fundo. Esse método de segmentação interpreta a imagem como uma bacia hidrográfica, sendo que os valores dos níveis de cinza são as altitudes, formando vales e montanhas, os marcadores de fundo e objeto são as fontes de água. Essas fontes de água, começam "encher" essa bacia hidrográfica até se encontrarem, assim segmentando a imagem em fundo e objeto. Para utilizá-la, é necessário clicar na opção \textbf{Watershed} para abrir o painel de edição (figure~\ref{fig:watershed_painel}).

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.75]{segmentation_watershed_panel_pt.png}
\caption{Painel de segmentação por Watershed}
\label{fig:watershed_painel}
\end{figure}

Antes de iniciar a segmentação por Watershed, é recomendável limpar toda a máscara utilizando a ferramenta de limpeza de máscara, conforme é mostrado na seção~\ref{cap:limpeza_mascara}.

Para inserir marcadores de fundo e objeto, é utilizada uma ferramenta em forma de pincel, a exemplo da segmentação manual, existe a opção de selecionar pincel retangular ou circular, também é possível alterar o tamanho deles. 

É necessário também selecionar o tipo de operação que será realizada pelo pincel. As opções são as
seguintes:
\begin{itemize}
\item \textbf{Objeto}, para inserir marcadores de objeto;
\item \textbf{Fundo}, para inserir marcadores de fundo (não é objeto);
\item \textbf{Apagar}, para apagar marcadores de objeto ou fundo.
\end{itemize}

A opção "\textbf{Sobrescrever máscara}" é utilizada quando deseja-se que a máscara selecionada seja substituída pelo resultado da segmentação. Já a opção "\textbf{Considerar brilho e contraste}" é utilizada para o algoritmo levar em consideração a imagem que está sendo visualizada, assim é possível alterar o brilho e contraste e obter resultados melhores de segmentação.

É possível configurar o método de \textit{Watershed} através do botão ao lado esquerdo do painel (figure~\ref{fig:watershed_conf}). Ao abrir essa opção é mostrada a janela~\ref{fig:watershed_janela_conf}. A opção método permite alterar o algoritmo que é utilizado na segmentação, existe o Wartershed convencional e o Watershed baseado no método de IFT (\textit{Image Forest Transform}), em alguns casos, como segmentação de cérebro ele apresenta melhor resultado.

A conectividade dos pixels que serão levados em consideração, pode ser alterados, no caso 2D, é possível selecionar conectividade $4$ e $8$, já no caso 3D pode-se selecionar $6$,$18$ ou $26$. O valor "\textbf{Sigma da gaussiana}" é alterado para o método suavizar mais ou menos a imagem ao aplicar a segmentação, valores altos tendem a deixar a imagem mais suavizada e consequentemente o algoritmo seleciona menos detalhes e ruídos.

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.5]{configuration.png}
\caption{Botão para abrir a configuração do método de Watershed}
\label{fig:watershed_conf}
\end{figure}

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.55]{segmentation_watershed_conf_pt.png}
\caption{Opções de configuração do método de Watershed}
\label{fig:watershed_janela_conf}
\end{figure}

Existe a opção do método ser executado para todo o volume (expandir para outras fatias), para isso, após ser inserido os marcadores de objeto e de fundo, é necessário clicar no botão \textbf{Expandir watershed para 3D}, localizado no painel. Na figure~\ref{fig:watershed_2d} é exibido o resultado da segmentação do cérebro em uma fatia (2D), já na figure~\ref{fig:watershed_3d} é mostrado a expansão para todo o volume (3D). 

Ainda na figure~\ref{fig:watershed_2d}, podemos visualizar os marcadores de objeto em verde claro, os marcadores de fundo em vermelho e a máscara em verde transparente cobrindo a região selecionada (resultado).

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.2]{segmentation_watershed_axial.png}
\caption{Watershed aplicado em uma fatia de um volume.}
\label{fig:watershed_2d}
\end{figure}

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.4]{segmentation_watershed_multiplanar_3d_pt.png}
\caption{Segmentação do cérebro com o método de Watershed aplicado em todo um volume (expandido em 3D).}
\label{fig:watershed_3d}
\end{figure}

\section{Crescimento de região}

A técnica de segmentação por crescimento de região é ativada no menu \textbf{Ferramentas}, \textbf{Segmentação}, por último \textbf{Crescimento de região} (figure~\ref{fig:menu_segmentation_region_growing}). Inicialmente deve-se selecionar a configuração entre \textbf{2D - Fatia atual} ou \textbf{3D - Todas as fatias}, também é necessário selecionar a conectividade do crescimento entre $4$ ou $8$ para o 2D e $6$, $18$ ou $26$ para 3D. Por último é necessário selecionar o método, entre \textbf{Dinâmico, Limiar ou Confidência} (figure~\ref{fig:segmentation_region_growing_dinamic}).

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.5]{menu_segmentation_region_growing_pt.png}
\caption{Menu para ativar a segmentação por região de crescimento.}
\label{fig:menu_segmentation_region_growing}
\end{figure}

\begin{figure}[!htb]
\centering
\includegraphics[scale=0.7]{segmentation_region_growing_dinamic_pt.png}
\caption{Tela para ajuste de parâmetros de segmentação por crescimento de região.}
\label{fig:segmentation_region_growing_dinamic}
\end{figure}

A técnica parte de um pixel inicial que é indicado clicando com o \textbf{botão direito} do mouse, os pixels vizinhos que satisfazem as condições indicadas anteriormente são selecionados. Cada método leva em consideração diferentes condições, a seguir são apresentadas as diferenças entre cada método:

\begin{itemize}
	\item \textbf{Dinâmico}: Esse método captura o valor do pixel que foi clicado, levando em consideração o desvio para baixo (min) e desvio para cima (max). A opção \textbf{Considerar o brilho e contraste} é ativada por padrão, essa opção permite levar em consideração os valores de níveis de cinza que são exibidos e/ou ajustados na opção brilho e contraste. Ao desativar essa opção será levado em consideração os valores de cinza gravados na imagem (figure~\ref{fig:segmentation_region_growing_dinamic_parameter}). 
	
	\begin{figure}[!htb]
	\centering
	\includegraphics[scale=0.7]{segmentation_region_growing_dinamic_parameter_pt.png}
	\caption{Ajuste de parâmetros para o método dinâmico.}
	\label{fig:segmentation_region_growing_dinamic_parameter}
	\end{figure}
	
	\item \textbf{Limiar}: O método limiar selecionará os pixels cuja a vizinhança estejam dentro do valor mínimo e máximo (figure~\ref{fig:segmentation_region_growing_limiar}).

	\begin{figure}[!htb]
	\centering
	\includegraphics[scale=0.7]{segmentation_region_growing_limiar_pt.png}
	\caption{Ajuste de faixa de valores do método limiar.}
	\label{fig:segmentation_region_growing_limiar}
	\end{figure}	
	
	\item \textbf{Confidência}: O método (figure~\ref{fig:segmentation_region_growing_confidence_parameter})
	
	\begin{figure}[!htb]
	\centering
	\includegraphics[scale=0.7]{segmentation_region_growing_confidence_parameter_pt.png}
	\caption{Ajuste de faixa de valores do método limiar.}
	\label{fig:segmentation_region_growing_confidence_parameter}
	\end{figure}	
	
	
\end{itemize}