想要模糊图像 [英] want to blur an image

查看:117
本文介绍了想要模糊图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究项目.我正在使用网络摄像头使用emgucv在c#中检测人脸.
一切正常,例如当我运行应用程序时,它启动网络摄像头,然后开始检测面部..
但是现在我要做的是,当它检测到人脸时,应该只模糊人脸,而不是整个网络摄像头视频.或显示其他图像而不是检测到的脸部.
我在图片框中显示人脸检测到的视频.
这是我的代码,到目前为止我已经完成了..

i am working on project. I am using webcam to detect faces in c#, using emgucv.
Every thing is working fine,like when i run application it starts webcam then it starts detecting faces..
But now i want to do is, that when it detects faces , it should blur the face only,not the whole webcam video. or it show some other image instead of detected face.
And i am showing the face detected video in picturebox.
this is my code, i have done so far..

Image<Bgr, byte> ImageFrame = capture.QueryFrame();


            if (ImageFrame != null)
            {
                //convert the image to gray scale
                Image<Gray, byte> grayframe = ImageFrame.Convert<Gray, byte>();

                //detect faces from the gray-scale image and store into an array of type 'var'
                var faces = grayframe.DetectHaarCascade(haar, 1.4, 0,
                                                       HAAR_DETECTION_TYPE.DEFAULT,
                                                       new Size(25, 25))[0];


            

            
                //draw a green rectangle on each detected face in image
                foreach (var face in faces)
                {

                    ImageFrame.Draw(face.rect, new Bgr(Color.Green), 2);

                   
                }

                
            }

            camimagebox.Image = ImageFrame;





现在我只想模糊检测到的脸,就这样..请尽快帮助我..
我还用过:

ImageFrame.SmoothBlur(face.rect.Width,face.rect.Height)

但是什么也没发生...





Now i just want to blur the detected face, thats it..kindly help me as soon as you can..
I also used:

ImageFrame.SmoothBlur(face.rect.Width, face.rect.Height)

but nothing happened...

推荐答案

如果您正在使用EMGU(如标签中所述),则可以调用cvSmooth.我在下面讨论了参数,并显示了调用的示例.

If you are using EMGU, as it says in your tag, you can call cvSmooth. I have discussed the parameters below and shown an example of the call.

Image<Gray, float> inputImage;
//Set inputImage to whatever image you want to smooth

Image<Gray, float> smoothedImage = new Image<Gray, float>(inputImage.Width, inputImage.Height);

//You can use whichever smooth type you need, gaussian is fairly common, but not the only way to do it.

int apertureWidth = 10;
int apertureHeight = 10;
//The aperture is the size of the smoothing window
//The smoothing window is typically a square that is a few pixels wide; a 10x10 square is a good place to start.

//if you set parameter3 and 4 to zero it will use default values.

cvSmooth(inputImage.Ptr, smoothedImage.Ptr, SMOOTH_TYPE.CV_GAUSSIAN, apertureWidth , apertureHeight , 0, 0);



请在此处进行解释调用cvSmooth.

您需要按照此处.

另请阅读 [



Look here for an explanation of the call to cvSmooth.

You will need to select the smooth type as explained here.

Also read this[^] on openCV Image Filtering, cvSmooth is about 3/4 of the way down the page.


我们不知道您正在使用哪个库.我的文章包含有关如何模糊图像的说明,您可以将该代码与要检测的区域一起使用以模糊区域.
We have no idea what library you''re using. My articles include instructions on how to blur an image, you could use that code with the areas you''re detecting to blur an area.


这篇关于想要模糊图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆