OpenCV CLI VC# VS2008 VS2012 画像処理 GUIプログラミング 画像処理の研究を行う事になったので、画像処理について勉強しています。

GUI構成

  • Menustrip, Panel, OpenCvSharp.UserInterface.PictureBoxIpl
  • 設計2

Sobel, Canny, LaplaceはOpenCvSharpにある既存のメソッドを用います

Sobel, Canny, Laplasian

解説

  • エッジ検出処理自体は"Cv.Canny", "Cv.Sobel", "Cv.Laplace" で行います。これらメソッドに必要なパラメータを動的に変更できるようにするため、ソースが長くなっています。
Sobelのコード

  • 画像の確保
IplImage src = pictureBoxIpl1.ImageIpl;
 PictureBoxIplに表示した画像を操作したいため、pictureBoxIplからIplImageを作成しています。
 ここで注意すべきはカラーチャネルで、8ビット濃淡画像を読み込みPictureBoxIplに表示した場合でも、次にPictureBoxIplからIplImageを作成するとカラーチャネルは "IplImage.NChannels = 3" となります。
Cv.Cannyの出力はチャネル数1で固定、Cv.SobelとCv.Laplaceは入力画像のチャネル数と出力画像のチャネル数が一致しなければなりませんので、注意が必要です。

  • InputData_String


自作のフォームです。様々なデータインプット用フォームとして利用しています。

>inputF.label1.Text = "aperture_size";      //Label Name

>String[] A_aperture = { "3", "5", "7"};    //Definition type of Array String

> foreach (String num in A_aperture)
 inputF.comboBox1.Items.Add(num);           //Initialize : Add ALL Items : A_aperture -> comboBox1.Items

>inputF.comboBox1.SelectedIndex = 1;        //Initialize : Decide Number 

>while (inputF.Visible == true)   //Visible Property(bool) : true = forms are displayed; otherwise false.


このデータフォームはOKボタンを押すことでHide()が実行されるため、Visibleプロパティがfalseになります。
Dispose()はフォームを終了するため、再アクセスすることはできません。そのため、再アクセスする可能性があるものは "とりあえず" Hide()にしておくと便利です。

Form form = new Form();
form.Show();
form.Dispose();
form.Show();  //ここでエラー

Form form2 = new Form();
form2.Show();
form2.Hide();
form2.Show(); //OK

  • TrackBarForm


トラックバーを羅列したフォームです(OpenCvSharp.UserInterface.TrackbarWithLabel)
その都度、ラベル名や最大値、最小値、現在値を設定します。
トラックバースクロール時にはラベル名をトラックバーの値に書き換えているため、ラベル番号を参照することで値を取得できます。
this.trackbarWithLabel1.Label.Text = this.trackbarWithLabel1.Trackbar.Value.ToString();

下部にあるTimeLimit(progressBar)は、timerの使い方を学ぶために付けてみただけであって、特に意味はありません。
リミットが来たらトラックバーを終了させるだけです。

public TrackbarForm()
        {
            InitializeComponent();
            timer_TrackbarForm_Limit.Interval = 1000;
            progressBarTimeLimit.Maximum = 600;
            timer_TrackbarForm_Limit.Enabled = true;
        }
 private void timer_TrackbarForm_Limit_Tick(object sender, EventArgs e)
        {

            timer_now += timer_TrackbarForm_Limit.Interval;

            if ((timer_now >= 500000) && (timer_now <= 600000))
            {
                labelTimeLimit.ForeColor = Color.Red;
                progressBarTimeLimit.ForeColor = Color.Red;
                progressBarTimeLimit.Value = (timer_now / 1000);
            }
            else
                progressBarTimeLimit.Value = (timer_now / 1000);

            if (timer_now > 600000)
            {
                this.buttonExit_Click(sender, e);    // = this.Close()
            }
        }

結果1: Canny


結果2: Sobel



左:ApSize=3, 中左:ApSize=5, 中右:ApSize=7, 右:ApSize=7

結果3: Laplace



上からApSize=3, 5, 7

このページへのコメント

Great topic and well written. Do you have any more resources about this
that you reccommend?

0
Posted by Benny 2016年03月26日(土) 16:29:31 返信

Great topic and well written. Do you have any more resources about this that you reccommend?

0
Posted by Lila 2016年03月26日(土) 16:22:36 返信

Great topic and well written. Do you have any more resources about this that
you reccommend?

0
Posted by Sherri 2016年03月26日(土) 16:10:07 返信

Great topic and well written. Do you have
any more resources about this that you reccommend?

0
Posted by Riley 2016年03月26日(土) 15:36:14 返信

Great topic and well written. Do you have any more resources about this that you reccommend?

0
Posted by Rudolf 2016年03月26日(土) 15:17:49 返信

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

カウンタ

カウンタ




Menu

null

フリーエリア

管理人/副管理人のみ編集できます