public static void DisplayImage(Image img, PictureBox pb, bool stretch, bool invert)
        {
            Bitmap bm;

            if (img is Int32Image)
            {
                Int32Image disp = new Int32Image((Int32Image)img);
                if (invert)
                {
                    VisionLab.Not((Int32Image)disp);
                }
                if (stretch)
                {
                    VisionLab.Multiply((Int32Image)disp, 255);
                }

                bm = VisionLabEx.JLToBitmap(disp);
                disp.Dispose();
            }
            else
            {
                bm = VisionLabEx.JLToBitmap(img);
            }

            if (pb.Image != null)
            {
                pb.Image.Dispose();
            }
            pb.Image = bm;
        }