This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Suggestions on colour convertor program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Suggestions on colour convertor program" Watch "Suggestions on colour convertor program" New topic
Author

Suggestions on colour convertor program

Mikpo Siru
Ranch Hand

Joined: Apr 09, 2009
Posts: 54
Hi,

I want to write a program that maps the colours of a user-selected image to the closest matching colours in a given set. Here is the basic operation:

-User opens an image using the program
-The program checks the colour of each pixel in the image
-For each pixel, the program chooses the closest matching colour from a set of eight colours (red, green, blue, cyan, magenta, yellow, white, black)
-The program makes a new image from the 8 colours
-The program displays the new image

I have GUI programming experience in Java, but it's been some months since my last project (this is abit of a refresher).

I am looking for is suggestions on how to proceed. For example, useful classes, good methods of implementation (should I go through pixel by pixel?), etc.

Thanks
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4522
    
    5

Take the easy way ;)

-- Load your image
-- Create a IndexColorModel with the required colors
-- Construct a BufferedImage the same size as your image, of TYPE_BYTE_INDEXED and the index color model
-- Obtain the Graphics reference of the second image
-- Draw the first image to the second image
-- Profit


luck, db
There are no new questions, but there may be new answers.
Mikpo Siru
Ranch Hand

Joined: Apr 09, 2009
Posts: 54
Hi,

Thanks for the reply. I have started a sister thread specifically on making an IndexColorModel: http://www.coderanch.com/t/504292/GUI/java/Creating-IndexColorModel-Colours.

I will post problems I have with the overall convterter program in this thread.

Regards.
Mikpo Siru
Ranch Hand

Joined: Apr 09, 2009
Posts: 54
Thanks Darryl, I have a working program now.

For reference, here is the part of the program that does the conversion:


IndexColorModel colourModel was generated using Darryl's code snippet in http://www.coderanch.com/t/504292/GUI/java/Creating-IndexColorModel-Colours:

Regards.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Suggestions on colour convertor program
 
Similar Threads
Plugin in ImageJ giving random output, can't find reason.
Setting a color from a string
Logical operation on Image
Getting pixel information for mouse movement
average of colour