grayscale

How can i convert images into grayscale?

How can i convert images into grayscale? Question: I have 1000 of images. Now I like to convert those images into grayscale? import tensorflow as tf from tensorflow.keras.utils import img_to_array #df[‘image_name’] = df[‘image_name’].apply(str) df_image = [] for i in tqdm(range(df.shape[0])): img = image.load_img(‘/content/drive/MyDrive/Predict DF from Image of Chemical Structure/2D image/’+df[‘image_name’][i]+’.png’,target_size=(100,100,3)) img = image.img_to_array(img) img = …

Total answers: 1

Detect almost grayscale image with Python

Detect almost grayscale image with Python Question: Inspired by this question and this answer (which isn’t very solid) I realized that I often find myself converting to grayscale a color image that is almost grayscale (usually a color scan from a grayscale original). So I wrote a function meant to measure a kind of distance …

Total answers: 2

How to convert array to Gray Scale Image output?

How to convert array to Gray Scale Image output? Question: I have the data in a txt.How should i do to convert the data to Gray Scale Image output?Thx! The number of rows is 2378 and the number of columns is 5362. I’m a noob in python.I have tried this,but it did not work. from …

Total answers: 3

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

How to detect a specific inner rectangle in a complex shape

How to detect a specific inner rectangle in a complex shape Question: I have the following input image: and I do like to crop the inner max rectangle like this (Expected Output): but when I do contour detection I get the external rectangle (Current Result): import cv2 import numpy as np res = cv2.imread("input.png", 0) …

Total answers: 1

Resizing image and changing into grayscale

Resizing image and changing into grayscale Question: I’m using my trained model in react native whose input size is 48,48,1. Input values are RGB images. So I tried converting the image into tensor3d, then into grayscale, and resized it. But after resizing the model always gives the same prediction values. I don’t understand where something …

Total answers: 2

Editing out part of an image in python

Editing out part of an image in python Question: I have a collection of images featuring ships on or near the horizon in open ocean. I am trying to create an image that removes the ship(s) from the image while leaving most of the background intact. My initial attempt was to scan each row and …

Total answers: 1

Read image grayscale opencv 3.0.0-dev

Read image grayscale opencv 3.0.0-dev Question: I am trying to read images directly as black and white. I recently updated my OpenCv version to 3.0.0-dev, and the code that I used before does not work anymore. img = cv2.imread(f, cv2.CV_LOAD_IMAGE_GRAYSCALE) works fine for 2.4 but does not work for the new version, as there is …

Total answers: 3

displaying the camera feed in grayscale in python with opencv

displaying the camera feed in grayscale in python with opencv Question: i’ve been trying to display the camera feed from my laptops web cam in grayscale and i’ve done it using the following code: import cv2 import numpy as np clicked = False def onMouse(event, x, y, flags, param): global clicked if event == cv2.cv.CV_EVENT_LBUTTONUP: …

Total answers: 2

In OpenCV (Python), why am I getting 3 channel images from a grayscale image?

In OpenCV (Python), why am I getting 3 channel images from a grayscale image? Question: I am using Python (2.7) and bindings for OpenCV 2.4.6 on Ubuntu 12.04 I load an image image = cv2.imread(‘image.jpg’) I then check the shape of the image array print image.shape I get (480, 640, 3), which I expect for …

Total answers: 4