I'm trying to convert a color in a ROI of an matrix with OpenCV Java with following Code
public Mat detect(Mat image){
Rect roi = new Rect(new Point(50, 50), new Point(image.width() - 50, image.height() - 50));
Mat mask = image.submat(roi);
Mat temp = new Mat();
Imgproc.cvtColor(mask, temp, Imgproc.COLOR_BGRA2GRAY,0);
temp.copyTo(mask);
return image;
}
But the result is the same as the given image. If I change the Imgproc.cvtColor() call with a Imgproc.medianBlur() effect for example:
...
Imgproc.medianBlur(mask, temp, 11);
...
There is a blurred rectangle visible. I think while the process of Imgproc.cvtColor() the references to the original image are replaced by some newly created. So how else can I convert the color of a ROI in a matrix without loosing the references?
I appreciate any help, thanks!
P.S: I wanted to add some sample images but my reputation is not high enough. I'm sorry for this and hope you can imagine my problem even without samples.