pixel

Matplotlib displaying RGB pixels weirdly

Matplotlib displaying RGB pixels weirdly Question: I have a set of RGB pixels I gathered from an image, but when I try to save them and display them, they come out very weirdly, as 3 separate colors. It seems like it’s not reading my array as a list of RGB values. I have an abbreviated …

Total answers: 2

Python plot heatmap from csv pixel file with panda

Python plot heatmap from csv pixel file with panda Question: I would like to plot a heatmap from a csv file which contains pixels position. This csv file has this shape: 0 0 8.400000e+01 1 0 8.500000e+01 2 0 8.700000e+01 3 0 8.500000e+01 4 0 9.400000e+01 5 0 7.700000e+01 6 0 8.000000e+01 7 0 8.300000e+01 …

Total answers: 1

Why does Python Pillow swap x and y axis

Why does Python Pillow swap x and y axis Question: I tried this example from GeeksForGeeks where you create a blue picture. And I wanted to try something more out of it, so I wanted to change a single pixel from blue to red. Meanwhile, I did that successfully, I notice that position of the …

Total answers: 1

TypeError: cannot unpack non-iterable int object occurring with grayscale file

TypeError: cannot unpack non-iterable int object occurring with grayscale file Question: I want to convert a file to grayscale in python using PIL and then get the x,y and rgb value of the pixels but I am getting an error. Code: from PIL import Image,ImageOps file_name = "test.png" og_image = Image.open(file_name) gray_image = ImageOps.grayscale(og_image) gray_scalefile …

Total answers: 2

No module named 'tqdm'

No module named 'tqdm' Question: I am running the following pixel recurrent neural network (RNN) code using Python 3.6 import os import logging import numpy as np from tqdm import trange import tensorflow as tf from utils import * from network import Network from statistic import Statistic However, there was an error: ModuleNotFoundError: No module …

Total answers: 8

How to get matplotlib figure size

How to get matplotlib figure size Question: For a project, I need to know the current size (in pixels) of my matplotlib figure, but I can’t find how to do this. Does anyone know how to do this ? Asked By: Tristan || Source Answers: import matplotlib.plt fig = plt.figure() size = fig.get_size_inches()*fig.dpi # size …

Total answers: 3

Count all values in a matrix less than a value

Count all values in a matrix less than a value Question: I have to count all the values in a matrix (2-d array) that are less than 200. The code I wrote down for this is: za=0 p31 = numpy.asarray(o31) for i in range(o31.size[0]): for j in range(o32.size[1]): if p31[i,j]<200: za=za+1 print za o31 is …

Total answers: 6

Get pixel's RGB using PIL

Get pixel's RGB using PIL Question: Is it possible to get the RGB color of a pixel using PIL? I’m using this code: im = Image.open(“image.gif”) pix = im.load() print(pix[1,1]) However, it only outputs a number (e.g. 0 or 1) and not three numbers (e.g. 60,60,60 for R,G,B). I guess I’m not understanding something about …

Total answers: 5

Multiply each pixel in an image by a factor

Multiply each pixel in an image by a factor Question: I have an image that is created by using a bayer filter and the colors are slightly off. I need to multiply RG and B of each pixel by a certain factor ( a different factor for R, G and B each) to get the …

Total answers: 6

Make a 2D pixel plot with matplotlib

Make a 2D pixel plot with matplotlib Question: I got the following data from some calculations: x, y, temp where x and y are the coordinates of a point in a 2D box of dimensions 10×10. Spacing is equal to 0.1. So there are 10000 different points and the resulting file looks like: 0.0 0.0 …

Total answers: 1