Linked Questions

21 votes
1 answer
59k views

Use Numpy to convert rgb pixel array into grayscale [duplicate]

What's the best way to use Numpy to convert a size (x, y, 3) array of rgb pixel values to a size (x, y, 1) array of grayscale pixel values? I have a function, rgbToGrey(rgbArray) that can take the [r,...
SlothFriend's user avatar
0 votes
1 answer
5k views

How do I convert a 3D image array into a 2D image array in numpy? [duplicate]

I have a three-dimensional array of a image stored in a NumPy array. Using an algorithm, I converted the RGB image into grayscale. But in the third dimension the RGB values are same (for gray, the RGB ...
thesamiroli's user avatar
2 votes
2 answers
3k views

changing the depth of an image? [duplicate]

I am trying to make my own dataset of handwritten images to test my hand written digit classifier. so to make it I wrote the images in a paint box and resized the images to 28x28 pixels same as the ...
Bogorovich's user avatar
0 votes
1 answer
1k views

changing colorful dataset to Grayscale using keras [duplicate]

I loaded a dataset from the AstroNN library. Since i believe the color of images is not a factor for classifying galaxy formations, I want to convert all the dataset to Grayscale to reduce the size of ...
maryam gh's user avatar
  • 193
1 vote
1 answer
612 views

Python3 reduce array from (x,y,3) to (x,y,1) (rgb to greyscale) [duplicate]

I am quite new to python, therefore I might risk a duplicate (but I don't know how to ask the web yet). I have coded the following method. It converts an array(ROWS,COLS,3) to array(ROWS,COLS,1) def ...
jaecktec's user avatar
  • 442
1 vote
1 answer
493 views

change a colored image represented as a numpy ndarray to greyscale [duplicate]

I have an image, loaded from a file thus: img = misc.imread('mypic.jpg') it is a 3 dimensional, RGB numpy.ndarray. I wish to turn it into a greyscale ndarray (1-D).
eran's user avatar
  • 14.8k
0 votes
1 answer
434 views

How convert image's to black and white? (with scipy or matplotlib) [duplicate]

I need to take this image and rotate it 90d and print it in black and white colors. I need to do it with matplotlib or scipy. import scipy.misc import matplotlib.pyplot as plt from scipy import ...
Fusu's user avatar
  • 17
0 votes
0 answers
31 views

Displaying an image in grayscale on matplot lib [duplicate]

How do I plot an image in gray scale? I would imagine the following example would do this, but I get a color image. Do I need to apply the colormap in some other way? import numpy as np import ...
Chogg's user avatar
  • 389
59 votes
8 answers
6k views

Problems with using a rough greyscale algorithm?

So I'm designing a few programs for editing photos in python using PIL and one of them was converting an image to greyscale (I'm avoiding the use of any functions from PIL). The algorithm I've ...
Adi219's user avatar
  • 4,784
12 votes
1 answer
51k views

Converting an RGB image to grayscale and manipulating the pixel data in python

I have an RGB image which I want to convert to a grayscale image, so that I can have one number (maybe between 0 and 1) for each pixel. This gives me a matrix which has the dimensions equal to that of ...
lovespeed's user avatar
  • 4,905
5 votes
4 answers
18k views

How to convert a RGB image (3 channel) to grayscale (1 channel) and save it?

Working with a deep learning project and I have a lot of images, that don't need to have colors. I saved them doing: import matplotlib.pyplot as plt plt.imsave('image.png', image, format='png', cmap=...
J. Devez's user avatar
  • 329
3 votes
3 answers
9k views

Pytorch: load dataset of grayscale images

I want to load a dataset of grayscale images. I used ImageFolder but this doesn't load gray images by default as it converts images to RGB. I found solutions that load images with ImageFolder and ...
user3582433's user avatar
1 vote
2 answers
4k views

Python: Perform Grey Image to RGB

I have a grey image and I want to convert it into RGB. How will I do it in OpenCV? image = cv2.imread("image.jpg", cv2.IMREAD_GRAYSCALE) cv2.imshow('Grey Scale Image', image) cv2.waitKey() backtorgb ...
alyssaeliyah's user avatar
  • 2,244
2 votes
3 answers
13k views

Converting RGB to grayscale python

I have been converting rgb images to grayscale images, below is the code import numpy import glob import cv2 import csv import math import os import string from skimage.color import rgb2gray from PIL ...
Vamsi Shankar's user avatar
-1 votes
2 answers
12k views

Convert a 3-channel RGB mage into a 1-channel binary image

I can convert the RGB image into binary but its dimensions are still too large (1280x720x3). Since each pixel of the binary image only has a value of 0 or 1, I want to reduce its dimension to (...
Huy Vo's user avatar
  • 2,462

15 30 50 per page