JavaCv 高效实现图像的遍历

来源:互联网 发布:姓氏笔画排列软件 编辑:程序博客网 时间:2024/06/05 23:46

写这篇博客的时候心情真有点复杂,高兴的是我知道怎么在Android手机上实现图像的高效遍历,这对于我现在手头的项目真的很有帮助;但是有一点遗憾,到现在才知道这么简单的东西,自己的JAVA基础真是差。不废话了直接上代码。

ByteBuffer buffer=iplImage.getByteBuffer();        byte[] bb=new byte[buffer.remaining()];        buffer.get(bb);//获取byte数据        int width=iplImage.width();        int height=iplImage.height();        int widthStep=iplImage.widthStep();        int nchannal=iplImage.nChannels();        long startTimeSkin=System.currentTimeMillis();         for(int y=0;y<height;y++){        for(int x=0;x<width;x++){        int index=widthStep*y+nchannal*x;        bb[index+2]=0;        bb[index]=0;        }        }iplImage.getByteBuffer().put(bb);// 将数据更新到图像中

这里最关键的是ByteBuffer这是java里面的新I/O。详细说明请自行查看Java编程思想

1 0