# opencv java 2.4.9 pixel operations

Hello everyone!

I am a noob to opencv java and I've been having trouble performing pixel operations on 2 mats. I've already looked at http://answers.opencv.org/question/5/...

But it doesn't seem to work....

In opencv c++ the following is pixel division I have performed between 2 Mats which are split into arrays.

```
split(top, top_chs);
split(input.clone(), bot_chs); // split into channels which are vector<Mat>
split(input.clone(), dst_chs);
for (int i = 0; i < top.rows(); i++){
for (int k = 0; k < top.cols(); k++){
for (int j = 0; j < top.channels(); j++){
float a,b,c;
a = top_chs[j].at<float>(i,k);
b = bot_chs[j].at<float>(i,k);
if (a <= 0){a = top_min;} // make sure you don't divide by zero
if (b <= 0){b = ms_min;} // make sure you really don't divide by zero
if (a <= b){c = 1.0 - a/b;}
else {c = 1.0 - b/a;}
dst_chs[j].at<float>(i,k) = c;
}
}
}
merge(dst_chs, dst);
```

However to get the same effect in java I am having trouble... getting nothing but run time errors at this part of my code, I've tried the following. However, I get invalid Mat type error 5

```
top = UP_Pyramid.get(PyrSize-1);
bot = MeanShift.clone();
// might be needed.... we'll see
// Core.split(top, top_chs);
// Core.split(input, bot_chs);
// Core.split(input, bot_chs);
// **********************************************************
float a,b, c;
for (int i = 0; i < top.rows(); i++){
for (int j = 0; j < top.cols(); j++){
a = top.get(i,j);
b = bot.get(i,j);
if (a <= b) {c = 1.0 - a/b;}
else {c = 1.0 - b/a;}
dst.put(i,j, c);
}
}
```