imshow

opencv cv2.imshow automatically add padding to small image

房东的猫 提交于 2019-12-12 02:25:52
问题 I try to use cv2.imshow() to display images, however I find that the result is padded with blank automatically. The code I use is as following: import cv2 if __name__ == '__main__': img = cv2.imread('test2.png') cv2.imshow('dafasf', img) key = cv2.waitKey(0) if key == 27: # ESC cv2.destroyAllWindows() 回答1: By default imshow creates window object with WINDOW_AUTOSIZE attribute. It means that window size is determined by some frontend (GUI) which OpenCV was compiled with. Your image are not

How to remove grey boundary lines in a map when plotting a netcdf using imshow in matplotlib?

你说的曾经没有我的故事 提交于 2019-12-12 02:19:45
问题 Is it possible to remove the grey boundary lines around the in following map? I am trying to plotting a netcdf using matplotlib . from netCDF4 import Dataset # clarify use of Dataset import matplotlib.pylab as plt fnc = Dataset(ncfile, 'r') lat = fnc.variables['latitude'][:] lon = fnc.variables['longitude'][:] level = fnc.variables['level'][:] mydata = fnc.variables['Data'][0, 0, :, :] plt.figure(figsize = (8, 4)) imgplot = plt.imshow(mydata, cmap = 'YlGn') plt.colorbar() plt.show Edit: I

imshow in C++, toolbar disappeared

[亡魂溺海] 提交于 2019-12-11 17:05:12
问题 I have been using the same code to show a matrix image in my Ubuntu system, but recently, out of the blue, the display window automatically changed and is now not functioning properly. For starters, the tool bar that should be there on the display window had disappeared, So I can't save the image using the GUI, and secondly, I can no longer scroll to zoom into the image. Mat dataMatrix1(2048,2048,CV_8UC1, m); imshow( "Display window", dataMatrix1 ); waitKey(10); Both these features were there

How to increase contrast when plotting a netcdf using imshow in matplotlib?

余生长醉 提交于 2019-12-11 12:59:09
问题 Is there a way to increase contrast when plotting data (from a netcdf) using imshow? In ArcMap this can be done using the 'stretch' function but I would like a solution using matplotlib. from netCDF4 import Dataset import matplotlib.pylab as plt fnc = Dataset(ncfile, 'r') lat = fnc.variables['latitude'][:] lon = fnc.variables['longitude'][:] level = fnc.variables['level'][:] mydata = fnc.variables['Data'][0, 0, :, :] plt.figure(figsize = (8, 4)) imgplot = plt.imshow(mydata, cmap = 'YlGn') plt

python matplotlib, get pixel value after colormap applied

喜夏-厌秋 提交于 2019-12-11 12:07:52
问题 I display an image with matplotlib using imshow() . imshow apply a LUT and I would like to retrieve a pixel value (at x, y) after LUT applied. For exemple I have a full black image I display with imshow The image becomes yellow (cause of LUT) get_pixel(x, y) -> yellow Is there a way to code the function get_pixel ? 回答1: So, to get to the color of pixels, you have to look at how matplotlib maps the scalar values of the pixels to colors: It is a two step process. First, a normalization is

Visualize matrix with colormap in grid

自闭症网瘾萝莉.ら 提交于 2019-12-11 10:56:06
问题 I have a matrix that looks like this: 0.06 -0.22 -0.10 0.68 NaN -0.33 0.04 -0.07 0.12 0.23 NaN -0.47 NaN NaN NaN NaN NaN 0.28 0.37 0.36 0.14 0.58 -0.14 -0.15 NaN 0.11 0.24 0.71 -0.13 NaN 0.57 0.53 0.41 0.65 -0.43 0.03 I want to color in each value based on a colormap. In Python, I know I can use imshow to assign a color to each box. How can I do it in MATLAB? 回答1: You could use imshow as well, but every pixel would have the size of a pixel of your screen. So you may rather use imagesc. A = [.

Imshow - splitted with different pixel sizes

旧街凉风 提交于 2019-12-11 10:43:19
问题 I try to get the following which should be illustrated in the figure below. Let us assume, for simplicity, I have a numpy array (10x10) which I want to plot with matplotlib imshow. The condition is to have different pixel sizes, for instance: the first five rows should have a size of 0.5cm the last five rows should have a size of 1cm. The columns should have the same size. How could I easly implement this? I already tried to do this, but I do not like this solution; in particular I still have

How to obtain correct size for a second colorbar in matplotlib plot?

假如想象 提交于 2019-12-11 10:33:19
问题 I wish to create a "split plot", i.e. to use different colormaps in the left and the right half of my plot. Accordingly I will need two different colorbars. Unfortunately I have to set the position of the second colorbar by hand and modify everytime a label or title is included. Is there a way to automatise that? I wondered if I could extract the rect parameter of the following minimal example from the right colorbar. That would help me as I only had shift it a bit. Any other (/better) idea

Matplotlib imshow() grid uneven when grid size is large

半城伤御伤魂 提交于 2019-12-11 09:45:28
问题 I am trying to use the imshow() function in matplotlib to plot color values in a 177 X 177 grid. When I run the following code on a small (30X30) grid (i.e. I set width = 30 ), the image that it produces has nice, evenly sized squares. When I run it on a larger grid (150X150), the squares are not evenly proportioned. Some are stretched in one or both dimensions. Here's a simplified version of the code I'm using: grid = [[]]*width for i in range(width): grid[i] = [[]]*width for j in range

Color mapping of data on a date vs time plot

為{幸葍}努か 提交于 2019-12-11 06:37:37
问题 I am trying to plot 3 variables x,y,z on a 2d plot, with x (date) on the x axis, y (time) on the y axis and z (temperature) mapped with a colorscale. I have the three variables available within a pandas Dataframe and created an extra column with the datenumber so that matplotlib can work with it. import pandas as pd import matplotlib.pyplot as plt import matplotlib.dates as mdates data=pd.DataFrame() data['datenum']=mdates.date2num(data['Date']) Example: Date Time Tgrad datenum 0 2016-08-01