如何削减使用Emgu CV(或OpenCV中)的图像的一个子部分? [英] How to cut a sub-part of an image using Emgu CV (or OpenCV)?

查看:1134
本文介绍了如何削减使用Emgu CV(或OpenCV中)的图像的一个子部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用Emgu CV(或OpenCV的)切割的图像的一个子purt(或裁剪),并计算出该部分的平均色;寻找变化。



感谢


解决方案

  1. 设置你的投资回报率与此工作将意味着任何计算仅在这方面做的图像(感兴趣区域)。



    image.ROI =新的Rectangle(X,Y,宽度,高度);


  2. 计算投资回报率的平均值,其中类型是图像相关的BGR颜色灰色灰度




类型平均= image.GetAverage(图像);




  1. 当你已完成重置你的形象的投资回报率,所以你可以再次看到整个图像。



所有过程中是循环遍历每个像素增加了它的价值再由像素的总数除以。节省您自己编写的代码。



由于
克里斯


I want to cut a sub-purt of an image (or crop it) using Emgu CV (or OpenCV) and calculate average color of that part; looking for changes.

Thanks

解决方案

  1. Set the ROI (Region of Interest) of the image you are working with this will mean any calculation is only done over this area.

    image.ROI = new Rectangle(x,Y,Width,Height);

  2. Calculate the Average of the ROI where "TYPE" is image dependant Bgr for colour Gray for Grayscale

TYPE average = image.GetAverage(image);

  1. When youve finished reset your image ROI so you can see the whole image again.

All the process does is loop through each pixel adds its value then divides by the total number of pixels. Saves you writing the code yourself.

Thanks Chris

这篇关于如何削减使用Emgu CV(或OpenCV中)的图像的一个子部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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