473,418 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

How to turn a colorful image into a black-white one with java?

i have problem with java programming to turn turn a colorful image into a black-white one with java,,,can anybody help me please..
Oct 28 '10 #1
1 4936
Each pixel has red, green, and blue.

If you want a gray-scale image, make all the pixels be the average of the three components in each pixel.

red=(red+green+blue)/3;
green=(red+green+blue)/3;
blue=(red+green+blue)/3;

If you want black and white, you have two color options:

red=green=blue=255
or
red=green=blue=0

I would suggest if (red+green+blue) > (255 * 3/2) then use 255, else use 0.

Use google to help you open up a picture file and gain access to the pixels. Once you can do that, use the formulas above!

Good luck....
Nov 1 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Phil Powell | last post by:
I borrowed this code from a source: for($a=0;$a<imagecolorstotal ($image_id);$a++) { $color = imageColorsForIndex($image_id,$i); $R=.299 * ($color)+ .587 * ($color)+ .114 * ($color);...
4
by: matt tagliaferri | last post by:
We have remote users running MSDE entering information into a database. To send the data back to the home office, we've written some routines that export the data into SQL Scripts in text files: ...
6
by: juglesh | last post by:
hello, here is my dir structure: /private mainaction.php img.jpg /public_html index.php in index.php, I include mainaction.php. In mainaction.php, i want to
2
by: Lucas Cowald | last post by:
Hi, Using ASP and VBScript. How to convert JPEG image into a binary data? Is it possible with a command from ASP / VBScript without having to put it into a database first? I want to take the...
0
by: CG3000 | last post by:
I create a .PNG image ( in Macromedia Fireworks ) which has an gif in it in the top left corner and a lot of empty canvas space to the right. I use about 10 text boxes on a form to populate that...
8
by: MarkAurit | last post by:
I have to display some images kept into a sql server database (image data type) in an asp.net 1.1 page. Is it possible to use an asp control to display the contents of a byte or a MemoryStream?...
2
by: Marcus | last post by:
Here is a toy problem describing what I want to do: I have a web page with a single IMG element (say for a 128 x 128 "screen") which is initially blank (image=black pixels). I have AJAX code...
0
by: Charles A. Landemaine | last post by:
I designed a standard-compliant mockup for PC-BSD's web site. The page is displayed properly in the following browsers: - IE7 - Opera 9 - FF2 - Seamonkey But when I open it in Konqueror...
3
by: birensubudhi | last post by:
hey guys,can anyone tell me what is image processing, how to do it using C. IN KSHITIJ 2007 held at IIT kgp a que by INFOSYS is asked, they hav given an image then cut in different orientation...
2
by: cfps.Christian | last post by:
I'm seeking to make an application that will allow a user to drag an image into IE (potentially Firefox) and it upload to our server. The problem I'm having is when you drag an image into IE7 it...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.