Esempio n. 1
0
 public void SetCaptureImage(Image <Bgr, byte> frame)
 {
     if (backgroundImage == null || bgImg == null)
     {
         LoadResourceImage();
     }
     originalImage = frame.Clone();
     SetChromakeyColor(getRedValue_Low(), getRedValue_High(), getGreenValue_Low(), getGreenValue_High(), getBlueValue_Low(), getBlueValue_High());
     applyChromakey(bgImg, originalImage);
     img_capture.Source = imageConverter.BitmapToImageSource(dst.Bitmap);
 }
Esempio n. 2
0
        protected void displayImage()
        {
            //var uri = new Uri(inputfilename);
            //var bitmap = new BitmapImage(uri);
            //imageMain.Source = bitmap;
            this.imageMain.Source            = ImageConverter.BitmapToImageSource(CurrentImage);
            this.imageCanvas.Width           = CurrentImage.Width;
            this.imageCanvas.Height          = CurrentImage.Height;
            this.statusLabelDimValue.Content = string.Format("{0} × {1}px  {2}bpp", CurrentImage.Width, CurrentImage.Height, System.Drawing.Bitmap.GetPixelFormatSize(CurrentImage.PixelFormat).ToString());

            if (this.isFitImageSelected)
            {
                System.Drawing.Size fitSize = fitImagetoContainer((int)this.imageCanvas.Width, (int)this.imageCanvas.Height, (int)this.scrollViewer.ActualWidth, (int)this.scrollViewer.ActualHeight);
                this.imageCanvas.Width  = fitSize.Width;
                this.imageCanvas.Height = fitSize.Height;
                setScale();
            }
            else if (this.scaleX != 1f)
            {
                this.imageCanvas.Width  = Convert.ToInt32(CurrentImage.Width / scaleX);
                this.imageCanvas.Height = Convert.ToInt32(CurrentImage.Height / scaleY);
            }
            //curScrollPos = Point.Empty;
            this.centerPicturebox();

            this.imageCanvas.Deselect();
            this.imageCanvas.SegmentedRegions = null;
            setSegmentedRegions();
        }
Esempio n. 3
0
        protected override void contrastToolStripMenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (imageList == null)
            {
                MessageBox.Show(this, Properties.Resources.LoadImage, strProgName);
                return;
            }
            SliderDialog dialog = new SliderDialog();

            dialog.LabelText = Properties.Resources.Contrast;
            dialog.SetForContrast();
            dialog.ValueUpdated += new SliderDialog.HandleValueChange(UpdatedContrast);

            originalImage = imageList[imageIndex];
            stack.Push(originalImage);

            Nullable <bool> dialogResult = dialog.ShowDialog();

            if (dialogResult.HasValue && !dialogResult.Value)
            {
                // restore original image
                imageList[imageIndex] = originalImage;
                this.imageMain.Source = ImageConverter.BitmapToImageSource(originalImage);
            }
        }
        private void backgroundWorkerLoadThumbnail_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            // Load thumbnails & associated labels into panel
            System.Drawing.Image thumbnail = (System.Drawing.Image)e.UserState;
            RadioButton          rb        = new RadioButton();

            rb.Width  = thumbnail.Width;
            rb.Height = thumbnail.Height;
            rb.Style  = toggleButtonStyle;
            BitmapImage bmimage = ImageConverter.BitmapToImageSource(thumbnail);

            System.Windows.Controls.Image image = new System.Windows.Controls.Image();
            image.Source           = bmimage;
            rb.Content             = image;
            rb.HorizontalAlignment = HorizontalAlignment.Center;
            rb.Tag    = e.ProgressPercentage;
            rb.Click += new RoutedEventHandler(this.radioButton_Click);
            this.panelThumbnail.Children.Add(rb);
            Label label = new Label();

            label.Content             = e.ProgressPercentage + 1;
            label.HorizontalAlignment = HorizontalAlignment.Center;
            label.Margin = new Thickness(0, -5, 0, 0);
            this.panelThumbnail.Children.Add(label);
        }
Esempio n. 5
0
 protected override void buttonRotateCW_Click(object sender, RoutedEventArgs e)
 {
     this.centerPicturebox();
     this.imageCanvas.Deselect();
     imageList[imageIndex].RotateFlip(RotateFlipType.Rotate90FlipNone);
     this.imageMain.Source = ImageConverter.BitmapToImageSource(imageList[imageIndex]);
     adjustPictureBoxAfterFlip();
     clearStack();
 }
Esempio n. 6
0
 private void UpdatedThreshold(object sender, SliderDialog.ValueChangedEventArgs e)
 {
     System.Drawing.Image image = ImageHelper.AdjustThreshold(originalImage, (float)e.NewValue * 0.01f);
     if (image != null)
     {
         imageList[imageIndex] = image;
         this.imageMain.Source = ImageConverter.BitmapToImageSource(image);
     }
 }
Esempio n. 7
0
 protected override void smoothToolStripMenuItem_Click(object sender, RoutedEventArgs e)
 {
     if (imageList == null)
     {
         MessageBox.Show(this, Properties.Resources.LoadImage, strProgName);
         return;
     }
     originalImage = imageList[imageIndex];
     stack.Push(originalImage);
     imageList[imageIndex] = ImageHelper.GaussianBlur((Bitmap)originalImage);
     this.imageMain.Source = ImageConverter.BitmapToImageSource(imageList[imageIndex]);
 }
Esempio n. 8
0
        public Result OnStartup(UIControlledApplication a)
        {
            RibbonPanel ribbonPanel = this.GetRibbonPanel(a);

            string thisAssemblyPath = Assembly.GetExecutingAssembly().Location;

            PushButton button = ribbonPanel.AddItem(new PushButtonData("RoomsArea", "Rooms Area", thisAssemblyPath, "Tools.AreaCalculatorCommand")) as PushButton;

            button.ToolTip    = "Calculate rooms area";
            button.LargeImage = ImageConverter.BitmapToImageSource(Images.RoomArea);

            return(Result.Succeeded);
        }
Esempio n. 9
0
        protected override void despeckle3x3ToolStripMenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (imageList == null)
            {
                MessageBox.Show(this, Properties.Resources.LoadImage, strProgName);
                return;
            }

            try
            {
                originalImage         = imageList[imageIndex];
                imageList[imageIndex] = ImageHelper.RemoveSpeckles((Bitmap)originalImage, Tesseract.Pix.SEL_STR3, 3);
                this.imageMain.Source = ImageConverter.BitmapToImageSource(imageList[imageIndex]);
                stack.Push(originalImage);
            }
            catch
            {
                MessageBox.Show(this, Properties.Resources.Require_grayscale, strProgName, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 10
0
        protected override void deskewToolStripMenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (imageList == null)
            {
                MessageBox.Show(this, Properties.Resources.LoadImage, strProgName);
                return;
            }
            this.imageCanvas.Deselect();
            this.Cursor = Cursors.Wait;

            gmseDeskew deskew         = new gmseDeskew((Bitmap)imageList[imageIndex]);
            double     imageSkewAngle = deskew.GetSkewAngle();

            if ((imageSkewAngle > MINIMUM_DESKEW_THRESHOLD || imageSkewAngle < -(MINIMUM_DESKEW_THRESHOLD)))
            {
                originalImage = imageList[imageIndex];
                stack.Push(originalImage);
                imageList[imageIndex] = ImageHelper.Rotate((Bitmap)originalImage, -imageSkewAngle);
                this.imageMain.Source = ImageConverter.BitmapToImageSource(imageList[imageIndex]);
            }
            this.Cursor = null;
        }