How to copy a mat object to a integer 2D matrix in opencv java ?
Here is my code below:
System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
Imgcodecs imageCodecs = new Imgcodecs();
String file ="File path";
Mat matrix = imageCodecs.imread(file, Imgcodecs.IMREAD_GRAYSCALE);
System.out.println("Image Loaded");
Now I want to see the pixel values of mat object "matrix" as an 2D array. I want it to convert or copy as int[][] format. How to do this please suggest.
can you explain, why this would be nessecary ? (and what for ?)
System.out.println(mat.dump());
I have to convert a grayscale matrix to a 2D integer array( or matrix) so that I can do some Operation on that matrix (which I got from image) and get some different images back again from that output matrix. Previously I was doing with a random large sized matrix but now have to do with the matrix from grayscale image. That is the reason I want to convert it to a 2D matrix with row col.
Previously I was working with random 128*!28 matrix. Bu now I have to work with the matrix i got from that grayscale image. I want to pass this matrix from image as argument but unable to do so. Please suggest.
public static void main(String[] args) { //int row,col=128; //int[][] mat = new int[row][col];
Posting the remaining code below :
public class SampleImage {
what exactly ? why not use opencv for this, too ?