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);
imshow() method is used to display an image in a window. The window automatically fits to the image size. Syntax: cv2.imshow(window_name, image) Parameters: window_name: A string representing the name of the window in which image to be displayed.
Description. imshow( I ) displays the grayscale image I in a figure. imshow uses the default display range for the image data type and optimizes figure, axes, and image object properties for image display.
Working of imshow() function in OpenCVThe imshow() function takes two parameters namely window_name and image. The parameter window_name is the name of the window within which the given image must be displayed. The parameter image is the image to be displayed in a window.
The matplotlib function imshow() creates an image from a 2-dimensional numpy array. The image will have one square for each element of the array. The color of each square is determined by the value of the corresponding array element and the color map used by imshow() .
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With