emgucv mean shift

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.Util;
using Emgu.CV.Structure;
namespace meanshift
{
    public partial class Form1 : Form
    {
        static string name;

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            if (open.ShowDialog() == DialogResult.OK)
            {
                name = open.FileName;
               
            }
        }



        private void test(string name)
        {
            Image<Bgr, byte> src = new Image<Bgr, byte>(name);//读取原图像


            
            pictureBox2.Image = src.ToBitmap();
            Image<Bgr, byte> src1 = new Image<Bgr, byte>(src.Size);
            CvInvoke.cvPyrMeanShiftFiltering(src, src1, trackBar1.Value, trackBar2.Value, trackBar3.Value, new MCvTermCriteria(1));
            
            pictureBox1.Image = src1.ToBitmap();//将处理后的图像显示出来
            src.Dispose();
            src1.Dispose();

            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            test(name);
        }

        private void trackBar1_ValueChanged(object sender, EventArgs e)
        {
            label1.Text = trackBar1.Value.ToString();
            test(name);
        }

        private void trackBar2_ValueChanged(object sender, EventArgs e)
        {
            label2.Text = trackBar2.Value.ToString();
            test(name);
        }

        private void trackBar3_ValueChanged(object sender, EventArgs e)
        {
            label3.Text = trackBar3.Value.ToString();
            test(name);
        }



    }
}


效果可以更改滑动条来改变。


Parameters
src – The source 8-bit, 3-channel image.
dst – The destination image of the same format and the same size as the source.
sp – The spatial window radius.
sr – The color window radius.
maxLevel – Maximum level of the pyramid for the segmentation.
termcrit – Termination criteria: when to stop meanshift iterations


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值