imshow

Python - OpenCV - imread - Displaying Image

你。 提交于 2019-11-28 18:39:58
I am currently working on reading an image and displaying it to a window. I have successfully done this, but upon displaying the image, the window only allows me to see a portion of the full image. I tried saving the image after loading it, and it saved the entire image. So I am fairly certain that it is reading the entire image. imgFile = cv.imread('1.jpg') cv.imshow('dst_rt', imgFile) cv.waitKey(0) cv.destroyAllWindows() Image: Screenshot: Looks like the image is too big and the window simply doesn't fit the screen. Create window with the cv2.WINDOW_NORMAL flag, it will make it scalable.

matplotlib 2D plot from x,y,z values

被刻印的时光 ゝ 提交于 2019-11-28 10:38:58
问题 I am a Python beginner. I have a list of X values x_list = [-1,2,10,3] and I have a list of Y values y_list = [3,-3,4,7] I then have a Z value for each couple. Schematically, this works like that: X Y Z -1 3 5 2 -3 1 10 4 2.5 3 7 4.5 and the Z values are stored in z_list = [5,1,2.5,4.5] . I need to get a 2D plot with the X values on the X axis, the Y values on the Y axis, and for each couple the Z value, represented by an intensity map. This is what I have tried, unsuccessfully: X, Y = np

Matplotlib - sequence is off when using plt.imshow()

有些话、适合烂在心里 提交于 2019-11-28 02:09:18
I write a dog-classifier in a Jupyter notebook that, every time a dog is detected in an image, should show the image and print some text describing it. Somehow, the images are always displayed after all the text was printed, no matter in which order I put plt.imshow() and print() . Does anybody know why this is the case? Thank you! Here is my code-snippet: for i in range (0, 1,1): all_counter+=1 if dog_detector(dog_files_short[i]): img = image.load_img(dog_files_short[i], target_size=(224, 224)) plt.show() plt.imshow(img) time.sleep(5) print("That's a dog!!!!") dog_counter+=1 print("__________

OpenCV & Python - Image too big to display

 ̄綄美尐妖づ 提交于 2019-11-27 17:08:32
问题 I have an image that is 6400 × 3200, while my screen is 1280 x 800. Therefore, the image needs to be resized for display only. I am using Python and OpenCV 2.4.9. According to OpenCV Documentation, If you need to show an image that is bigger than the screen resolution, you will need to call namedWindow("", WINDOW_NORMAL) before the imshow. That is what I am doing, but the image is not fitted to the screen, only a portion is shown because it's too big. I've also tried with cv2.resizeWindow,

Two different color colormaps in the same imshow matplotlib

拟墨画扇 提交于 2019-11-27 16:13:08
问题 Let's suppose the example below import matplotlib.pyplot as plt import numpy as np v1 = -1 + 2*np.random.rand(50,150) fig = plt.figure() ax = fig.add_subplot(111) p = ax.imshow(v1,interpolation='nearest') cb = plt.colorbar(p,shrink=0.5) plt.xlabel('Day') plt.ylabel('Depth') cb.set_label('RWU') plt.show() I want to show the values below zero in a different colormap than the values above zero 回答1: First of all, is it possible that you just want to use a diverging colormap, 'neutral' at zero,

Python xticks in subplots

北城余情 提交于 2019-11-27 11:25:47
If I plot a single imshow plot I can use fig, ax = plt.subplots() ax.imshow(data) plt.xticks( [4, 14, 24], [5, 15, 25] ) to replace my xtick labels. Now, I am plotting 12 imshow plots using f, axarr = plt.subplots(4, 3) axarr[i, j].imshow(data) How can I change my xticks just for one of these subplots? I can only access the axes of the subplots with axarr[i, j] . How can I access plt just for one particular subplot? There are two ways: Use the axes methods of the subplot object (e.g. ax.set_xticks and ax.set_xticklabels ) or Use plt.sca to set the current axes for the pyplot state machine (i.e

Python - OpenCV - imread - Displaying Image

不想你离开。 提交于 2019-11-27 11:04:13
问题 I am currently working on reading an image and displaying it to a window. I have successfully done this, but upon displaying the image, the window only allows me to see a portion of the full image. I tried saving the image after loading it, and it saved the entire image. So I am fairly certain that it is reading the entire image. imgFile = cv.imread('1.jpg') cv.imshow('dst_rt', imgFile) cv.waitKey(0) cv.destroyAllWindows() Image: Screenshot: 回答1: Looks like the image is too big and the window

How to remove gaps between *images* in matplotlib?

孤者浪人 提交于 2019-11-27 09:47:40
Inspired by this question , I've been trying to get images plotted without gaps. In my toy example I have four images that I want to place in two rows. They have different shapes: different number of rows, same number of columns . Despite the differences, they should fit in a single figure without gaps, as in the following illustration: When I try to get them together, though, setting plt.subplots_adjust(wspace=0, hspace=0) doesn't do the trick, because the images have different shapes. Here's the code: from numpy.random import rand import matplotlib.pyplot as plt test_data = [[rand(10,10),

Matplotlib: how to make imshow read x,y coordinates from other numpy arrays?

不羁的心 提交于 2019-11-27 09:31:06
When you want to plot a numpy array with imshow , this is what you normally do: import numpy as np import matplotlib.pyplot as plt A=np.array([[3,2,5],[8,1,2],[6,6,7],[3,5,1]]) #The array to plot im=plt.imshow(A,origin="upper",interpolation="nearest",cmap=plt.cm.gray_r) plt.colorbar(im) Which gives us this simple image: In this image, the x and y coordinates are simply extracted from the position of each value in the array. Now, let's say that A is an array of values that refer to some specific coordinates: real_x=np.array([[15,16,17],[15,16,17],[15,16,17],[15,16,17]]) real_y=np.array([[20,21

update frame in matplotlib with live camera preview

ⅰ亾dé卋堺 提交于 2019-11-27 05:13:00
I am new to both Python and Matplotlib. My computer is connected to two usb cameras, and I intend to use the subplot(1,2,1) and subplot(1,2,2) in matplotlib to plot the frames from the two camera in time series. When I do this with my code, I either get only one frame plotted or get a black screen in the plotting area. My code look like below #import import cv2 import matplotlib.pyplot as plt #Initiate the two cameras cap1 = cv2.VideoCapture(0) cap2 = cv2.VideoCapture(1) #Capture the frames from camera 1 and 2 and display them over time using matplotlib while True: #grab frame from camera 1