Java OpenCV convertScaleAbs()使用详解
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Java OpenCV convertScaleAbs()使用详解,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1492字,纯文字阅读大概需要3分钟。
内容图文
![Java OpenCV convertScaleAbs()使用详解](/upload/InfoBanner/zyjiaocheng/713/45c305136e71430a9ac8850164478e03.jpg)
函数说明
用于实现对整个图像数组中的每一个元素,进行如下操作:
dstrow,col? = ∣alpha?srcrow,col?+beta∣
参数说明
Core.convertScaleAbs(src, dst, alpha, beta);
src – 原图
dst – 目标图
alpha – 乘数因子
beta – 偏移量
测试代码
import org.opencv.core.*;
public class OpenCVTest {
static{ System.loadLibrary(Core.NATIVE_LIBRARY_NAME); }
public static void main(String[] args) {
Mat mat = new Mat(new Size(3,3), CvType.CV_8UC1, new Scalar(0));
mat.put(0, 0, 0);
mat.put(0, 1, 1);
mat.put(0, 2, 2);
mat.put(1, 0, 0);
mat.put(1, 1, 1);
mat.put(1, 2, 2);
mat.put(2, 0, 0);
mat.put(2, 1, 1);
mat.put(2, 2, 2);
Mat dst = new Mat();
Core.convertScaleAbs(mat, dst, 1, 0);
System.out.println("----------原图-----------");
for (int row = 0; row < mat.rows(); row++) {
for (int col = 0; col < mat.cols(); col++) {
System.out.print(mat.get(row, col)[0] + " ");
}
System.out.println();
}
System.out.println("----------处理结果-----------");
for (int row = 0; row < dst.rows(); row++) {
for (int col = 0; col < dst.cols(); col++) {
System.out.print(dst.get(row, col)[0] + " ");
}
System.out.println();
}
}
}
代码测试
alpha = 1, beta = 0
----------原图-----------
0.0 1.0 2.0
0.0 1.0 2.0
0.0 1.0 2.0
----------处理结果-----------
0.0 1.0 2.0
0.0 1.0 2.0
0.0 1.0 2.0
alpha = 2, beta = -1
----------原图-----------
0.0 1.0 2.0
0.0 1.0 2.0
0.0 1.0 2.0
----------处理结果-----------
1.0 1.0 3.0
1.0 1.0 3.0
1.0 1.0 3.0
内容总结
以上是互联网集市为您收集整理的Java OpenCV convertScaleAbs()使用详解全部内容,希望文章能够帮你解决Java OpenCV convertScaleAbs()使用详解所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。