imshow

Getting error in cv::imshow() - ASSERT: “false” in file qasciikey.cpp, line 501

岁酱吖の 提交于 2021-02-18 11:29:30
问题 I am getting this error whenever I call cv::waitKey(): ASSERT: "false" in file qasciikey.cpp, line 501 I am not sure why I am getting this error. I am running on an Ubuntu Server 14.04 EC2 instance connected through MobaXterm on Windows. If I run all of the same code on a normal ubuntu machine, all works great. This is the line where this happens: char key = cvWaitKey(33); 回答1: A workaround in MobaXterm is to uncheck "Unix-compatible keyboard" in X11 settings. 回答2: Try this. pip install

How can I generate and display a grid of images in PyTorch with plt.imshow and torchvision.utils.make_grid?

一曲冷凌霜 提交于 2021-02-18 10:49:52
问题 I am trying to understand how torchvision interacts with mathplotlib to produce a grid of images. It's easy to generate images and display them iteratively: import torch import torchvision import matplotlib.pyplot as plt w = torch.randn(10,3,640,640) for i in range (0,10): z = w[i] plt.imshow(z.permute(1,2,0)) plt.show() However, displaying these images in a grid does not seem to be as straightforward. w = torch.randn(10,3,640,640) grid = torchvision.utils.make_grid(w, nrow=5) plt.imshow(grid

Can we plot image data in Altair?

邮差的信 提交于 2021-02-16 15:55:09
问题 I am trying to plot image data in altair, specifically trying to replicate face recognition example in this link from Jake VDP's book - https://jakevdp.github.io/PythonDataScienceHandbook/05.07-support-vector-machines.html. Any one had luck plotting image data in altair? 回答1: Altair features an image mark that can be used if you want to plot images that are available at a URL; for example: import altair as alt import pandas as pd source = pd.DataFrame.from_records([ {"x": 0.5, "y": 0.5, "img"

imshow() not showing image correctly

我是研究僧i 提交于 2021-02-11 15:28:56
问题 The data I am trying to map out is a matrix of shape 5x64 called 'field_matrix' field_matrix = [ [0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 2 2 2 2 2 2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1] [0 0 0 0 0 0 0 1 0 0 1 2 2 2 2 2 2 2 2 2 0 0 2 2 2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 2 2 2 2 2 2 2 2 2 0 2 2 2 2 2 2 2 0 0 0 0] [0 0 0 0 0 0 0 1 0 1 0 2 2 2 2 2 2 2 2 2 0 2 2 2 2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 2 2 2 2 2 2 2 1 1 1 1 1] [0 0 0 0 0

adding line plot to imshow and changing axis marker

不羁的心 提交于 2021-02-07 03:44:08
问题 I have made the attached plot using the following codes: a = 1 theta = np.linspace(0,2*np.pi,101) x = np.linspace(-3*a,3*a,1001, dtype='complex') y = np.linspace(-3*a,3*a,1001, dtype='complex') X,Y = np.meshgrid(x,y) # come manipulations with V # (same shape and type as X,Y) not shown here plt.subplot(1,2,1) plt.scatter(a*np.cos(theta), a*np.sin(theta)) plt.imshow(V.real) plt.colorbar() plt.subplot(1,2,2) plt.scatter(a*np.cos(theta), a*np.sin(theta)) plt.imshow(V.imag) plt.colorbar() What I

adding line plot to imshow and changing axis marker

两盒软妹~` 提交于 2021-02-07 03:43:43
问题 I have made the attached plot using the following codes: a = 1 theta = np.linspace(0,2*np.pi,101) x = np.linspace(-3*a,3*a,1001, dtype='complex') y = np.linspace(-3*a,3*a,1001, dtype='complex') X,Y = np.meshgrid(x,y) # come manipulations with V # (same shape and type as X,Y) not shown here plt.subplot(1,2,1) plt.scatter(a*np.cos(theta), a*np.sin(theta)) plt.imshow(V.real) plt.colorbar() plt.subplot(1,2,2) plt.scatter(a*np.cos(theta), a*np.sin(theta)) plt.imshow(V.imag) plt.colorbar() What I

cartopy: how to add an image on top of map

烂漫一生 提交于 2021-01-28 05:22:53
问题 How to overlay a custom image on top of a cartopy map? If I do ax = plt.axes(projection=map_quest_aerial.crs) ax.set_extent([lon_0, lon_1, lat_0, lat_1]) plt.imshow('myimage.png', extent=(x0,x1,y0,y1)) plt.show() my image shows up correctly in the axes. But, if I try to add the background map image, my image no longer appears: ax = plt.axes(projection=map_quest_aerial.crs) ax.set_extent([lon_0, lon_1, lat_0, lat_1]) ax.add_image(map_quest_aerial, 10) plt.imshow('myimage.png', extent=(x0,x1,y0

Remove white border when using subplot and imshow in python (Matplotlib)

邮差的信 提交于 2021-01-22 04:24:59
问题 import numpy as np import sys import matplotlib as mpl import matplotlib.pyplot as plt i use the following code to save an image fig, ax = plt.subplots(frameon=False) ax.axis ('off') ax.imshow (array[:,:,0,0,0]) fig.savefig ("file.png", bbox_inches='tight') However, what I get is and this obviously still has a white border. How do I get rid of it? The array.shape is: (256, 256, 1, 1, 3) 回答1: Look at my example it may help you: import numpy as np import matplotlib.pyplot as plt def save_image

Matplotlib: imshow with second y axis

混江龙づ霸主 提交于 2021-01-20 04:17:56
问题 I'm trying to plot a two-dimensional array in matplotlib using imshow(), and overlay it with a scatterplot on a second y axis. oneDim = np.array([0.5,1,2.5,3.7]) twoDim = np.random.rand(8,4) plt.figure() ax1 = plt.gca() ax1.imshow(twoDim, cmap='Purples', interpolation='nearest') ax1.set_xticks(np.arange(0,twoDim.shape[1],1)) ax1.set_yticks(np.arange(0,twoDim.shape[0],1)) ax1.set_yticklabels(np.arange(0,twoDim.shape[0],1)) ax1.grid() #This is the line that causes problems ax2 = ax1.twinx()

Matplotlib: imshow with second y axis

时光总嘲笑我的痴心妄想 提交于 2021-01-20 04:15:54
问题 I'm trying to plot a two-dimensional array in matplotlib using imshow(), and overlay it with a scatterplot on a second y axis. oneDim = np.array([0.5,1,2.5,3.7]) twoDim = np.random.rand(8,4) plt.figure() ax1 = plt.gca() ax1.imshow(twoDim, cmap='Purples', interpolation='nearest') ax1.set_xticks(np.arange(0,twoDim.shape[1],1)) ax1.set_yticks(np.arange(0,twoDim.shape[0],1)) ax1.set_yticklabels(np.arange(0,twoDim.shape[0],1)) ax1.grid() #This is the line that causes problems ax2 = ax1.twinx()