how to grayscale an image in python

Ads
 

how to grayscale an image in python

Hi,

I have may images and it want to greyscale all with python.

can it be done?

how to grayscale an image in python?

Thanks

View Answers

July 22, 2019 at 1:44 AM

Hi,

You can do this with opencv. here is code example:

from PIL import Image
img = Image.open('img.jpg').convert('LA')
img.save("img-gray.png")

Thanks

Ads









Related Tutorials/Questions & Answers:
PHP GD image grayscale
*$imgh)) { echo "The image is grayscale."; } else { echo "The image is NOT grayscale."; } ?> After running the program you will get the following output OUTPUT:The image is NOT grayscale
PHP GD Grayscale
<?php $file = 'images.jpg'; header('Content-type: image/jpeg'); list($width, $height) = getimagesize($file); $source = imagecreatefromjpeg($file); $bwimage= imagecreate($width, $height); for ($c=0;$c<256;$c
Advertisements
How to run external command in Python?
How to run external command in Python?  Hi, I am writing an application in Python and there is requirement of calling the external command from... external command. How to run external command in Python? Thanks   Hi
how to update image in php
how to update image in php  how to update image in php
How to put an image on a JButton?
How to put an image on a JButton?  How to put an image on a JButton
how to insert image into server
how to insert image into server  how to insert an image into sql server and retrieve it using jSP
how to set background image
how to set background image  how to set image in background in that image i want over lay text how it possible in jsp? using flash image how it is overlayed in jsp page? thanks
How to store an image in database
How to store an image in database  Hi........... How to store an image in postgresql using a query. I mean tell me the way to store an image using datatype. I am using the datatype bytea but tell me how to insert the image
how to display image with listview
how to display image with listview  How can i display the list view with the related images from database
How to store image into database
How to store image into database  Hi, all I want to store image into database using Java. Can anyone help me that how can i store image into database... through the following link How To Store Image Into MySQL Using Java
How to write image in Jmagick
How to write image in Jmagick  hi, I am new in Java I am using the Jmagick library, how can I write an image in Jmagick ? Thanks.   hi, You can try this snippet into your code ImageInfo ii = new ImageInfo("abc.jpg
How to Increase / decrease the contract of an image?
How to Increase / decrease the contract of an image?  How to Increase / decrease the contract of an image
How to Increase / decrease the brightness of an image?
How to Increase / decrease the brightness of an image?  How to Increase / decrease the brightness of an image
how to use image tag in jsp
how to use image tag in jsp  How to use image tag in JSP
Jmagick how to add image on an existing image
Jmagick how to add image on an existing image  hi, I am using...) on an existing image. can any one explains how ? Thanks.   hi, In Jmagick you... you to understand how to use these methods and values in to adding an image
How to write text on image
How to write text on image  hi, I am using the Jmagick library. I want to write text on image, how is it possible ? Thanks.   hi, I am new in Jmagick but, I used the following code and it might also help you
how to convert string to image in java
how to convert string to image in java  how to convert string to image in java? I know we need to convert image to a byte array at some point in my application but do not know how to convert a image into byte string. Please
how to set image - EJB
how to set image   public ActionForward execute(ActionMapping mapping... coding to ireport. this coding only getting database fields. i need add one image in this pdf, how can i set pls help me sir, my image in E:/rose.jpg,how can
How to retrieve image from database
How to retrieve image from database  hi........ How to retrieve image from database when it is stored. I have stored image in postgresql and want... but it retrieves as a string and not complete image can u tel me the conversion
how to display the image in center - Ajax
how to display the image in center  i want to dispaly the image as center of the screen using javascript..while i am clicking the button ..any one give me the code for this one
How to Store Image using JSF
How to Store Image using JSF  Hi How to upload images in db. using jsf. For jsf photo uploading .. I used this one code for upload image.. But this code haven't option to upload any images . i want to store image in db
How to save image on the server by applet
How to save image on the server by applet  HI, in my project I am using applet and creating a chart by jcchart. Now when the chart has ploated... as a gif image on the server directory. Can any Body help me how can I do it Thanks
How to save image on the server by applet
How to save image on the server by applet  HI, in my project I am using applet and creating a chart by jcchart. Now when the chart has ploated... as a gif image on the server directory. Can any Body help me how can I do it Thanks
how to show random image in ASP.net?
how to show random image in ASP.net?  hello bros i saw in many websites..there is a programming of random image changing.... i want to use this in my ASP.NET websites, can any one suggest me code or any kind of help..so that i
How to use flickr image in Flex
How to use flickr image in Flex  Hi, I want to diaply the flickr image in my Flex application. Do I need a crossdomain.xml file on flickr? Please let's know how I can develop such applications. Thanks   Ans
how to set a image in frame? - Swing AWT
how to set a image in frame?  how to set a image in frame using swing
how to use a image in background in your application form?
how to use a image in background in your application form?  how to use a image in background in your application form
how to get the image of a selected JRadioButton to another panel?
how to get the image of a selected JRadioButton to another panel?  how to get the image of a selected JRadioButton to another panel
how to fetch image from mysql using jsp
how to fetch image from mysql using jsp  how to fetch image from mysql using jsp
How to display image in Swing?
How to display image in Swing Application? Swing is used... requirement to display the image in your swing application then you can learn to display image in swing application here. In this example user enters the name
How to store and retrieve image from database in JSP?
How to store and retrieve image from database in JSP?  Hi, In one of my application I have to store and then display the image in JSP. How to store and retrieve image from database in JSP? Thanks   HI, You can use

Ads