Ask Your Question

Revision history [back]

Getting the matrix of Mat type image

I m doing an image processing using opencv java. I threshold the image to detect red colour and now I want to get the matrix of destination as a printed value. My codes can be presented as follows.please reply me soon..this is an urgent question

Mat source = Imgcodecs.imread("C:\\Users\\My Kindom\\Desktop\\hsv.jpg",Imgcodecs.CV_LOAD_IMAGE_COLOR);
Mat destination = new Mat(source.rows(),source.cols(),source.type());
destination = source;

Scalar lowerb=new Scalar (170,50,50);
Scalar upperb=new Scalar (180,255,255);


Core.inRange(source, lowerb, upperb, destination);
Imgcodecs.imwrite("C:\\Users\\My Kindom\\Desktop\\ThreshZero.jpg", destination);

for(int i=0;i<destination.rows();i++){
    for(int j=0;j<destination.cols();j++){
        System.out.println(destination.row(),destination.cols());
    }
}
click to hide/show revision 2
No.2 Revision

updated 2016-03-22 00:49:07 -0600

berak gravatar image

Getting the matrix of Mat type image

I m doing an image processing using opencv java. I threshold the image to detect red colour and now I want to get the matrix of destination as a printed value. My codes can be presented as follows.please reply me soon..this is an urgent questionfollows.

Mat source = Imgcodecs.imread("C:\\Users\\My Kindom\\Desktop\\hsv.jpg",Imgcodecs.CV_LOAD_IMAGE_COLOR);
Mat destination = new Mat(source.rows(),source.cols(),source.type());
destination = source;

Scalar lowerb=new Scalar (170,50,50);
Scalar upperb=new Scalar (180,255,255);


Core.inRange(source, lowerb, upperb, destination);
Imgcodecs.imwrite("C:\\Users\\My Kindom\\Desktop\\ThreshZero.jpg", destination);

for(int i=0;i<destination.rows();i++){
    for(int j=0;j<destination.cols();j++){
        System.out.println(destination.row(),destination.cols());
    }
}