如何在java api中使用OpenCV获取子图像 [英] how to get sub image by using OpenCV in java api

查看:26
本文介绍了如何在java api中使用OpenCV获取子图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过在 Java API 中使用 OpenCV 从输入图像中获取子图像.但是在我阅读了关于 OpenCV java API 的文档后,我找不到像 c 中的 cvGetSubImage(...) 那样的方法.任何帮助或信息?谢谢!

I want to get sub image from input image by using OpenCV in java API. But after I read the doc about OpenCV java API, I can not find the method to do this just like cvGetSubImage(...) in c. Any help or information? Thanks!

推荐答案

您需要做的是找到一个子矩阵或 ROI,以便选择图像的特定部分.

What you need to do is find a submatrix or ROI in order to select the particular part of your image.

事实证明 JavaCV 有一个很好的小方法来做到这一点 submat.

It turns out JavaCV has a nice little method for doing this submat.

这将返回所选区域的垫子.方法定义为:

This returns a Mat of the selected area. The method definition is:

public Mat submat(int rowStart,
     int rowEnd,
     int colStart,
     int colEnd)

来自文档

**运算符为 *this 的指定子数组创建一个新头.它们是Mat.row"、Mat.col"、Mat.rowRange"和Mat.colRange"的最通用形式.例如,A(Range(0, 10), Range.all()) 等价于 A.rowRange(0, 10).和上面的一样,算子都是O(1)操作,即不复制矩阵数据.

**The operators make a new header for the specified sub-array of *this. They are the most generalized forms of "Mat.row", "Mat.col", "Mat.rowRange", and "Mat.colRange". For example, A(Range(0, 10), Range.all()) is equivalent to A.rowRange(0, 10). Similarly to all of the above, the operators are O(1) operations, that is, no matrix data is copied.

这篇关于如何在java api中使用OpenCV获取子图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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