使用openCV转换图像中的像素颜色

时间:2022-09-11 23:46:01

So what i'm basically trying to do is converting the pixel in image to the color i want, i'm not finding anything in openCV for java , the only way i come up with is this :

所以我基本上要做的是将图像中的像素转换为我想要的颜色,我在openCV中找不到任何东西,我想出的唯一方法就是这样:

     for (int i = 0; i < image.cols(); i++) {
     for (int j = 0; j < image.rows(); j++) {

     double[] data = image.get(i, j);
     data[0] = 255;
     data[1] = 255;
     data[2] = 255;
     image.put(i, j, data);
     }
     }
     Utils.matToBitmap(image, bmp);
     return bmp;;

trying to imtate this c++ code in java, but its not working

试图在java中模仿这个c ++代码,但它不起作用

1 个解决方案

#1


0  

ok found out why it is not working, i should have write :

好的,发现为什么它不工作,我应该写:

for (int i = 0; i < image.height(); i++) {
            for (int j = 0; j < image.width(); j++) {

instead of :

代替 :

 for (int i = 0; i < image.cols(); i++) {
     for (int j = 0; j < image.rows(); j++) {

#1


0  

ok found out why it is not working, i should have write :

好的,发现为什么它不工作,我应该写:

for (int i = 0; i < image.height(); i++) {
            for (int j = 0; j < image.width(); j++) {

instead of :

代替 :

 for (int i = 0; i < image.cols(); i++) {
     for (int j = 0; j < image.rows(); j++) {