Karim Tarabishy
Karim Tarabishy

Reputation: 1253

Matplotlib imshow low quality compared to OpenCV

I am doing some computer vision with python so I am using both opencv and matplotlib. I want to switch to matplotlib for viewing images but I found that the image quality is low compared to OpenCV imshow also the images are not shown with right size on screen they are all the same size.

This is how I use to

img = cv2.imread('a.png',0)
f = plt.figure(figsize=(img.shape[1],img.shape[0]), dpi=1)
plt.axes([0,0,1,1])
plt.axis('false')
plt.imshow(img,cmap="gray",interpolation=None)

I tried with different values for interpolation but still the quality is very low compared to opencv is there to show image with better quality?

Also when printing I get same low quality not like the opencv write method.

Upvotes: 0

Views: 1801

Answers (1)

Molly
Molly

Reputation: 13610

You are making the figure size too large. img.shape returns the number of rows and columns in img but figsize uses inches.

Also, you probably want the figure to have a different resolution than dpi = 1. Dots per inch should be more like 80 and may need to be higher depending on how you'll display the image.

Upvotes: 2

Related Questions