Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

the fastest way is not accessing single bytes.

please use:

Mat bgr  = ...; // your input
Mat gray = new Mat();
cvtColor( bgr, gray, Imgproc.COLOR_BGR2GRAY);

http://docs.opencv.org/java/org/opencv/imgproc/Imgproc.html#cvtColor(org.opencv.core.Mat,%20org.opencv.core.Mat,%20int)

the fastest way is not accessing single bytes.

please use:

Mat bgr  = ...; // your input
Mat gray = new Mat();
cvtColor( Imgproc.cvtColor( bgr, gray, Imgproc.COLOR_BGR2GRAY);

http://docs.opencv.org/java/org/opencv/imgproc/Imgproc.html#cvtColor(org.opencv.core.Mat,%20org.opencv.core.Mat,%20int)

the fastest way is not accessing single bytes.bytes at all.

please use:

Mat bgr  = ...; // your input
Mat gray = new Mat();
Imgproc.cvtColor( bgr, gray, Imgproc.COLOR_BGR2GRAY);

http://docs.opencv.org/java/org/opencv/imgproc/Imgproc.html#cvtColor(org.opencv.core.Mat,%20org.opencv.core.Mat,%20int)

the fastest way is not accessing single bytes at all.

please use:

Mat bgr  = ...; // your input
Mat gray = new Mat();
Imgproc.cvtColor( bgr, gray, Imgproc.COLOR_BGR2GRAY);

http://docs.opencv.org/java/org/opencv/imgproc/Imgproc.html#cvtColor(org.opencv.core.Mat,%20org.opencv.core.Mat,%20int)

[edit]

if you ever must access bytes, at least put/get the whole batch:

byte[] bytes = new byte[ mat.total() * mat.elemSize() ];
mat.get(0,0, bytes);
// ...
mat.put(0,0, bytes);