void RenderImage(Graphics graf)
        {
            if (_ImgCol == null ||
                listBoxImg.SelectedIndex < 0 ||
                listBoxImg.SelectedIndex >= _ImgCol.ImgList.Count
                )
            {
                _fImgDirty           =
                    _fDetectionDirty = false;

                return;
            }

            LabeledImg labeledImg = _ImgCol.ImgList[listBoxImg.SelectedIndex];

            // render the image
            if (_fImgDirty)
            {
                labelImgName.Text = labeledImg.FileName;

                Rectangle rect = labelImageBorder.Bounds;
                rect.Width  = labelHeader.Left - 1 - labelImageBorder.Bounds.Left;
                rect.Height = labelStatus.Top - 1 - labelImageBorder.Bounds.Top;

                graf.FillRectangle(new SolidBrush(BackColor), rect);

                labeledImg.Render(graf, labelImageBorder.Bounds);

                if (checkBoxLabel.Checked)
                {
                    labeledImg.RenderAnnotations(graf, labelImageBorder.Bounds);
                }

                _fImgDirty = false;
            }

            if (_fDetectionDirty)
            {
                if (checkBoxDetect.Checked)
                {
                    DetectionResult detRes = DetectFaces(labeledImg);

                    if (detRes != null)
                    {
                        float eThreshold = trackBarThreshold.Value * _eStepSize;

                        if (radioButtonRawRectangles.Checked)
                        {
                            detRes.RenderRawRect(eThreshold, graf, labelImageBorder.Bounds);
                        }

                        if (radioButtonMergedRect.Checked)
                        {
                            detRes.RenderMergedRect(eThreshold, graf, labelImageBorder.Bounds);
                        }
                    }

                    if (listBoxDetectedRect.Items.Count > 0)
                    {
                        ScoredRect scoredRect = (ScoredRect)listBoxDetectedRect.SelectedItem;

                        if (scoredRect != null)
                        {
                            labelRectInfo.Text = "Rect #" + listBoxDetectedRect.SelectedIndex + "\r\n" +
                                                 scoredRect.ToString() + "\r\n" +
                                                 "Score: " + scoredRect.Score;

                            scoredRect.Render(graf, labelImageBorder.Bounds, true);

                            labeledImg.Render(graf, scoredRect.Bounds, labelFaceBorder.Bounds);
                            labeledImg.Render(graf, scoredRect.Bounds, labelFaceBorderBig.Bounds);
                        }
                    }
                }

                _fDetectionDirty = false;
            }
        }