示例#1
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            OpenFileDialog dlgSourcePicture = new OpenFileDialog();
            dlgSourcePicture.Filter = "Image Files(*.BMP;*.JPG;*.GIF;*.PNG)|*.BMP;*.JPG;*.GIF;*.PNG|All files (*.*)|*.*";
            dlgSourcePicture.Multiselect = false;
            if (dlgSourcePicture.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                Application.Exit();

            m_imgSource = new Image<Bgr, Byte>((Bitmap) Image.FromFile(dlgSourcePicture.FileName)).Convert<Hsv, Byte>();
            m_imgThreshold = new Image<Gray, Byte>(m_imgSource.Size);

            m_frmSourceImage = new ImageViewer(m_imgSource, "Original Image");
            m_frmSourceImage.ShowIcon = false;
            m_frmSourceImage.MaximizeBox = false;
            m_frmSourceImage.Show();
            m_frmSourceImage.SetDesktopLocation(100, 0);
            m_frmSourceImage.SizeChanged += m_frmSourceImage_SizeChanged;

            m_frmThresholdImage = new ImageViewer(m_imgThreshold, "Threshold Image");
            m_frmThresholdImage.ShowIcon = false;
            m_frmThresholdImage.MaximizeBox = false;
            m_frmThresholdImage.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            m_frmThresholdImage.Show();
            m_frmThresholdImage.SetDesktopLocation(m_frmSourceImage.DesktopLocation.X + m_frmSourceImage.Size.Width + 100, m_frmSourceImage.DesktopLocation.Y);

            ProduceThresholdImage();
        }