# copyTo not working: Java

Hi,

I'm retrieving a ROI of mat, want to manipulate its values and put the manipulated matrix back into the original matrix but it's not working, though.. I googled that result together as it seems to be the best documentation, but I'm stuck and don't know why the original matrix won't hold the new values. The code is as follows.

```
for (int i = 0; i < objectArray.length; i++) {
Imgproc.rectangle(frame, objectArray[i].tl(), objectArray[i].br(), scalar, 3);
Mat A = frame.submat(objectArray[i]);
A.convertTo(A, CvType.CV_64FC3);
int size = (int) (A.total() * A.channels());
double[] temp = new double[size];
A.get(0, 0, temp);
for (int j = 0; j < size; j++)
temp[j] = (temp[j] / 2);
A.put(0, 0, temp);
A.copyTo(frame.submat(objectArray[i]));
}
```

where objectArray contains Rectangles, my ROIs and frame is my original Matrix, which is, of course, bigger than A. Can someone help me?

Edit: It's working on every webpage i see. In my case, nothing happens. The rectangular is drawn but thats it. Actually the RIO Image should appear darker, but it doesn't. When I try

```
A.copyTo(frame)
```

then the original image/mat has the same size as my ROI, what's definitely not wanted. I also tried applying a mask with the same size as my Matrix 'A', but the image was turned completely black afterwards. Seems like I'm running from one pitfall straight into the other. Would appreciate some help.

Why downvoting wihtout comment? This isn't helping anyone ..