imshow function in openCV

c++, opencv

Solution

First of all, you are using the C and C++ libraries interchangeably - IpIImage belongs to C and Mat belongs to C++, this could be the source of your problem. Instead, try just using the C++ interface and your code will be as follows :

Mat image = imread("Black&White.jpg"); 
imshow("Image",image);
waitKey(0);

That should fix your problem, if not, try using the C interface

IplImage* image = cvLoadImage("Black&White.jpg");
cvNamedWindow( "Image", CV_WINDOW_AUTOSIZE );
cvShowImage("Image", image);
cvWaitKey(0);

Problem

I am using imshow function to display images in OpenCV. It works fine, there is just a little thing though: the title I write for the image is not correctly displayed. For example, when I write "Original" or "inverted" they are displayed with some extra and unintelligible data in the beginning. However, when I write "thresholded Image" a long line of unintelligible words is displayed instead of the title... It does not effect anything else but it seems queer to me. Do you have any idea why that happens? Here is my code: ``` IplImage* image=cvLoadImage("Black&White.jpg"); Mat image1; image1=Mat(image,false); imshow("Image",image1); cvWaitKey(0); ```

Original source