Mat img=imread("image_location");
I studied that ‘img’ variable is like an object reference variable in java which refers the original object(an image in this case).
Out of curiosity i thought to find out what the ‘img’ variable holds.If it refers to the actual object,it should hold an address and return the address when i use
cout<<img;
But,Shock,it is returning the actual image(pixel values) to the output.
I think there is something wrong with my understanding.
Plz help,I’m a noob programmer who’s trying to make my brain understand these concepts.
cv::Matholds the data representing the image in an array, plus other data specific to thecv::Matinstance. The data array itself depends on the image’s format. You can have different numbers of channels and channel depth, and when you useimreadyou can pass a second parameter that gives you some control over this. Socv::Matdoes not have a pointer to the original object, it has a pointer to an array containing data representing that object.On top of that, in newer versions of OpenCV, the
ostream& operator<<is overloaded forcv::Mat, and that tries to produce a nice printout of the array values in matrix format. This is what you see when youstd::cout << someMat;