
\begin{comment}
python -m ibeis.scripts.specialdraw draw_graph_id \
    --dpath ~/latex/crall-thesis-2017/ --save "figures5/decisiongraph.jpg" \
    --figsize=12,8 --clipwhite --dpi=300 --diskshow
\end{comment}
\newcommand{\decisiongraph}{
\begin{figure}[t]
\centering
\includegraphics[width=\textwidth]{figures5/decisiongraph.jpg}
\captext[A synthetic decision graph]{\caplbl{decisiongraph}
% ---
This is a consistent synthetic decision graph with positive, negative, and incomparable edges.
The color of each node represents the positive connected component (PCC) it belongs to.
% ---
}
\label{fig:decisiongraph}
\end{figure}
}





\begin{comment}
python -m ibeis.scripts.specialdraw draw_inconsistent_pcc --show
python -m ibeis.scripts.specialdraw draw_inconsistent_pcc \
    --dpath ~/latex/crall-thesis-2017/ --save "figures5/inconpcc.jpg" \
    --figsize=15,10 --clipwhite --dpi=300 --diskshow --saveparts
\end{comment}
\newcommand{\inconpcc}{
\begin{figure}[ht!]
\centering
\begin{subfigure}[h]{0.4\textwidth}\centering\includegraphics[width=\textwidth]{figures5/inconpccA.jpg}\caption{}\label{sub:inconpccA}\end{subfigure}
~~% --
\begin{subfigure}[h]{0.4\textwidth}\centering\includegraphics[width=\textwidth]{figures5/inconpccB.jpg}\caption{}\label{sub:inconpccB}\end{subfigure}
\captext[An inconsistent PCC]{\caplbl{inconpcc}
% ---
Any PCC containing at least one negative edge is inconsistent.
Subfigure \Cref{sub:inconpccA} shows an inconsistent PCC, and
\Cref{sub:inconpccB} shows the same PCC where the edges hypothesized to be
errors are highlighted.
% ---
}
\label{fig:inconpcc}
\end{figure}
}



  


\begin{comment}
python -m ibeis.scripts.specialdraw redun_demo2 --show
python -m ibeis.scripts.specialdraw redun_demo2 \
    --dpath ~/latex/crall-thesis-2017/ --save "figures5/kredun.jpg" \
    --figsize=10,5 --clipwhite --dpi=300 --saveparts --diskshow
\end{comment}
\newcommand{\kredun}{
\begin{figure}[h]
\centering
\begin{subfigure}[h]{0.31\textwidth}\centering\includegraphics[width=\textwidth]{figures5/kredunA.jpg}\caption{}\label{sub:kredunA}\end{subfigure}
~~% --
\begin{subfigure}[h]{0.31\textwidth}\centering\includegraphics[width=\textwidth]{figures5/kredunB.jpg}\caption{}\label{sub:kredunB}\end{subfigure}
~~%--
\begin{subfigure}[h]{0.31\textwidth}\centering\includegraphics[width=\textwidth]{figures5/kredunC.jpg}\caption{}\label{sub:kredunC}\end{subfigure}
~~%--
\begin{subfigure}[h]{0.31\textwidth}\centering\includegraphics[width=\textwidth]{figures5/kredunD.jpg}\caption{}\label{sub:kredunD}\end{subfigure}
~~%--
\begin{subfigure}[h]{0.31\textwidth}\centering\includegraphics[width=\textwidth]{figures5/kredunE.jpg}\caption{}\label{sub:kredunE}\end{subfigure}
~~%--
\begin{subfigure}[h]{0.31\textwidth}\centering\includegraphics[width=\textwidth]{figures5/kredunF.jpg}\caption{}\label{sub:kredunF}\end{subfigure}
\captext[\caplbl{kredun}Examples of $k$-redundant PCCs]{
% --
This shows examples of positive (top) and negative (bottom) redundancy.
The positive edges are colored blue and the negative edges are colored red.
Choosing the level of redundancy is a trade-off between the number of required
  reviews and the confidence that the reviews are correct.
% --
}\label{fig:kredun}
\end{figure}
}



\begin{comment}
python -m ibeis.algo.graph.mixin_loops prob_any_remain --num_pccs=40 --size=2 --patience=20 --window=20 --dpi=300 --figsize=7.4375,3.0 '--dpath=~/latex/crall-thesis-2017' --save=figures5/poisson.png --diskshow
\end{comment}
\newcommand{\poisson}{
\begin{figure}[h]
    %
    \centering 
    \includegraphics[width=\textwidth]{figures5/poisson.png} 
    \captext[\caplbl{poisson}The convergence criteria on a synthetic dataset]{
    %--
    The convergence criteria is applied to a synthetic dataset with $40$ names and $2$ annotations per name.
    The red line indicates the fraction of label-changing reviews that remain undiscovered.
    The blue line is the probability that at least one of the next $20$ reviews will be label-changing.
    Notice that the blue line dips when the red line flattens.
    The process terminates once this probability drops below a threshold, which is denoted by the green dotted
      line.
    %--
} \label{fig:poisson}
\end{figure}
}

% -----------
% Experiments
% -----------


\begin{comment}
python -m ibeis Chap5.draw error_tables PZ_Master1
python -m ibeis Chap5.draw error_tables GZ_Master1

python -m ibeis Chap5.draw dbstats PZ_Master1,GZ_Master1

\end{comment}
\newcommand{\TestTrainDBStats}{
\begin{table}[h]
    \centering
    \captext[\caplbl{TestTrainDBStats}Database statistics for graph identification experiments]{
    % ---
    Each database is split into a training and a testing set.
    We report the number of names, the number of annotations, and the average number (as the mean and standard
      deviation) of annotations per name for each set.
    Additionally, we report how many edges (pairs of annotations) were used to train the classifiers.
    % ---
    }
    \label{tbl:TestTrainDBStats}
    \begin{subfigure}[h]{\textwidth}\centering\input{figures5/PZ_Master1/dbstats.tex}\caption{Plains zebras}\end{subfigure}
    \begin{subfigure}[h]{\textwidth}\centering\input{figures5/GZ_Master1/dbstats.tex}\caption{Grévy's zebras}\end{subfigure}
\end{table}
}


\begin{comment}
python -m ibeis Chap5.measure_simulation --db GZ_Master1 --show
python -m ibeis Chap5.measure_simulation --db PZ_Master1 --show

python -m ibeis Chap5.draw_simulation --db PZ_Master1 --diskshow
python -m ibeis Chap5.draw_simulation --db GZ_Master1 --diskshow
\end{comment}
\newcommand{\Simulation}{
\begin{figure}[t]
\centering
\begin{subfigure}[h]{\textwidth}\centering\includegraphics[width=\textwidth]{figures5/PZ_Master1/simulation.png}\caption{Plains zebras}\end{subfigure}
~
\begin{subfigure}[h]{\textwidth}\centering\includegraphics[width=\textwidth]{figures5/GZ_Master1/simulation.png}\caption{Grévy's zebras}\end{subfigure}
\captext[\caplbl{Simulation}Simulation experiment]{
% ---
The user simulation experiment compares the three identification algorithms defined in this \thesis{}.
The plot on the left indicates the identification accuracy using the number of remaining merges and the plot on
  the right counts the number of errors made (lower is better in both cases).
The best results are clearly achieved by \pvar{graph}.
% ---
}
\label{fig:Simulation}
\end{figure}
}


\begin{comment}
python -m ibeis Chap5.draw_refresh --db GZ_Master1 --diskshow
python -m ibeis Chap5.draw_refresh --db PZ_Master1 --diskshow
\end{comment}
\newcommand{\Refresh}{
\begin{figure}[ht]
\centering
\begin{subfigure}[h]{\textwidth}\centering\includegraphics[width=\textwidth]{figures5/PZ_Master1/refresh.png}\caption{Plains zebras}\end{subfigure}
~
\begin{subfigure}[h]{\textwidth}\centering\includegraphics[width=\textwidth]{figures5/GZ_Master1/refresh.png}\caption{Grévy's zebras}\end{subfigure}
\captext[\caplbl{Refresh}Measured refresh and termination probabilities]{
% ---
The probability that the next reviews will be label-changing ($\Pr{C\teq1}$) is high while new merges are
  discovered.
Once the probability falls under the threshold, positive redundancy is enforced (the flat areas) on existing
  PCCs, and then candidate edges are recomputed.
After an iteration with no label-changing reviews, the process terminates.
%Identification converges in $4$ iterations for plains zebras and $3$ for Grévy's.
% ---
}
\label{fig:Refresh}
\end{figure}
}




\begin{comment}
python -m ibeis Chap5.draw error_tables PZ_Master1
python -m ibeis Chap5.draw error_tables GZ_Master1
\end{comment}

\newcommand{\ErrorSizeDetails}{
\begin{table}[h]
    \centering
    \captext[\caplbl{ErrorSizeDetails}Simulation error sizes]{
    % ---
    This table analyzes the simulation errors.
    We compare statistics of the predicted PCCs with statistics of the real ground truth PCCs.
    In each category ``Pred PCCs'' is the number of predicted PCCs and ``Pred PCC size'' is the average number of
      annotations in those PCCs (measured as mean and standard deviation).
    The ``Real PCCs'' and ``Real PCC size'' columns are similarly defined.
    % ---
    }
    \label{tbl:ErrorSizeDetails}
    \begin{subfigure}[h]{\textwidth}\centering\input{figures5/PZ_Master1/error_size_details.tex}\caption{Plains zebras}\end{subfigure}
    \begin{subfigure}[h]{\textwidth}\centering\input{figures5/GZ_Master1/error_size_details.tex}\caption{Grévy's zebras}\end{subfigure}
\end{table}
}


\newcommand{\ErrorGroupDetails}{
\begin{table}[h]
    \centering
    \captext[\caplbl{ErrorGroupDetails}Simulation error group sizes]{
    % ---
    This table analyzes the error groups in the graph algorithm.
    A merge error group is a set of predicted PCCs that are incorrectly disconnected,  % 
    and a split error group is a set of real PCCs that are incorrectly connected.
    For each case we report the number of error groups, the average number of PCCs in each group, and the average
      size of the smallest and largest PCC in each group.
    % ---
    }
    \label{tbl:ErrorGroupDetails}
    \begin{subfigure}[h]{\textwidth}\centering\input{figures5/PZ_Master1/error_group_details.tex}\caption{Plains zebras}\end{subfigure}
    \begin{subfigure}[h]{\textwidth}\centering\input{figures5/GZ_Master1/error_group_details.tex}\caption{Grévy's zebras}\end{subfigure}
\end{table}
}


%-------------
% Error cases
%-------------

\newcommand{\SplitErrorsPZ}{
    \begin{figure}[h]
    \centering
    \includegraphics[width=\textwidth]{figures5/PZ_Master1/errors/split_14,22_hdupvjwn_edge2134,2492.png}
    \captext[\caplbl{SplitErrorsPZ}Plains split case due to ground truth error]{
    % ---
    This was incorrectly reported as a split case.
    The automatic verification algorithm correctly predicted that this pair is positive.
    % ---
    }
    \label{fig:SplitErrorsPZ}
    \end{figure}
}



\newcommand{\SplitErrorsGZ}{
    \begin{figure}[h]
    \centering
    \includegraphics[width=\textwidth]{figures5/GZ_Master1/errors/split_4,19_cymmmggo_edge1582,2371.png}
    \captext[\caplbl{SplitErrorsGZ}Grévy's split case due to ground truth error]{
    % ---
    This was incorrectly reported as a split case.
    The automatic verification algorithm correctly predicted that these annotations should be in the same PCC.
    % ---
    }
    \label{fig:SplitErrorsGZ}
    \end{figure}
}


\newcommand{\MergeErrorPZA}{

    \begin{figure}[h]
    \centering
    \includegraphics[width=\textwidth]{figures5/PZ_Master1/errors/merge_4,19_ybwvbppc_edge3420,3628.png}
    \captext[\caplbl{MergeErrorPZA}Plains merge case due to low probability]{
    % ---
    In this case the ranking algorithm generated an edge that could have connected the PCCs.
    Because the of the low positive probability due to viewpoint and occlusion, the termination criteria stopped
      the algorithm before this edge was reviewed.
    % ---
    }
    \label{fig:MergeErrorPZA}
    \end{figure}
}

\newcommand{\MergeErrorPZB}{
    \begin{figure}[h]
    \centering
    \includegraphics[width=\textwidth]{figures5/PZ_Master1/errors/merge_5,5,11_myqqzsxq_edge16523,17208.png}
    \captext[\caplbl{MergeErrorPZB}Plains merge case due to ranking failure]{
    % ---
    In this case there are three PCCs that should have been merged into one.
    Occlusion and pose variation prevented the ranking algorithm from generating candidate edges.
    However, the positive probability of the selected pair is $0.77$, which means that the pair would have likely
      been reviewed if the ranking algorithm had found it.
    % ---
    }
    \label{fig:MergeErrorPZB}
    \end{figure}
}



\newcommand{\MergeErrorGZA}{
    \begin{figure}[h]
    \centering
    \includegraphics[width=\textwidth]{figures5/GZ_Master1/errors/merge_4,11_zzdqqwzs_edge930,1045.png}
    \captext[\caplbl{MergeErrorGZA}Grévy's merge case due to ranking failure]{
    % ---
    The ranking algorithm did not generate any candidate edge that could have merged these PCCs due to viewpoint
      variations.
    Even, if the ranking algorithm had selected this edge, the positive probability on the edge would not have
      given it a high enough priority to be reviewed.
    % ---
    }
    \label{fig:MergeErrorGZA}
    \end{figure}
}

\newcommand{\MergeErrorGZB}{
    \begin{figure}[h]
    \centering
    \includegraphics[width=\textwidth]{figures5/GZ_Master1/errors/merge_4,29_vwajntbm_edge2146,2601.png}
    \captext[\caplbl{MergeErrorGZB}Grévy's merge case due to low probability]{
    % ---
    The ranking algorithm selected this edge a candidate, but due to occlusion from scenery and other animals the
      predicted positive probability is low.
    Therefore, the termination criteria stopped the algorithm before this edge was reviewed.
    % ---
    }
    \label{fig:MergeErrorGZB}
    \end{figure}
}

% MERGE GZ
%file:///home/joncrall/latex/crall-thesis-2017/figures5/PZ_Master1/errors/merge_4,14_ggywrmal_edge1913,2487.png
%file:///home/joncrall/latex/crall-thesis-2017/figures5/PZ_Master1/errors/merge_4,19_ybwvbppc_edge3420,3628.png
%file:///home/joncrall/latex/crall-thesis-2017/figures5/PZ_Master1/errors/merge_5,5,11_myqqzsxq_edge16523,17208.png
%file:///home/joncrall/latex/crall-thesis-2017/figures5/PZ_Master1/errors/merge_5,5,23_xwnmudnl_edge17126,17345.png
%file:///home/joncrall/latex/crall-thesis-2017/figures5/PZ_Master1/errors/merge_5,34_ymcmfzhc_edge9962,16092.png

%file:///home/joncrall/latex/crall-thesis-2017/figures5/GZ_Master1/errors/merge_4,11_zzdqqwzs_edge930,1045.png
%file:///home/joncrall/latex/crall-thesis-2017/figures5/GZ_Master1/errors/merge_4,19_xwsktmfx_edge2881,2927.png
%file:///home/joncrall/latex/crall-thesis-2017/figures5/GZ_Master1/errors/merge_4,29_vwajntbm_edge2146,2601.png
