Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > Java

Reply
 
LinkBack Thread Tools Display Modes
Old 02-16-2005, 03:25 AM   #1 (permalink)
inox
Registered User
 
Join Date: Feb 2005
Posts: 5
inox is on a distinguished road
Help me out with Counting Colours

Hi Everyone,

This had wandering over me for weeks now. Any help is very much appreciated.

I am working on image processing stuff now. I am now required to count the number of unique colours in an image so that I can identify few prominent colours to be my threshold values for further image segmentation.

I am working this out with both Java and JIU (Java Imaging Utilities) and able to get each pixel R,G and B value out. My problem is how can I put these values together and compare each pixel colour to another so that one which is similar will be ignored. I know that I can make use of Set as well as ArrayList even Vector in order to count these colours but not sure which one is better to use.

Hope u guys can help me out with this :-)

inox
inox is offline   Reply With Quote
Old 02-16-2005, 08:10 AM   #2 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,175
Belisarius is on a distinguished road
How about creating your own Pixel object that implements Comparable? Define equals() and compareTo(), and then shove them into a Set of some sort (doesn't really matter which type). A Set will ignore duplicates, so all of the elements will be unique.
__________________
GitS
Belisarius is offline   Reply With Quote
Old 02-16-2005, 08:23 AM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,530
sde is on a distinguished road
it sounds like he also needs to setup a way to count how many times that RGB value has been counted if he wants to identify the 'prominent' colors.
__________________
Mike
sde is offline   Reply With Quote
Old 02-16-2005, 08:27 AM   #4 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
This might be easier to visulaize if you move it form RGB color space to Hue, Saturation, and Value colorspace. That way you can set thresholds for each dimension rather than having to remember that green is 30% stronger in our perception of color and that blue is going to be inherently darker than red in terms of color perception.

EDIT: Just for reference Hue is what actual color you see, such as red or magenta, or yellow. Saturation is the amount of color in it a saturation of zero is a grayscale image whereas a full saturation would yield pure color. Value represents how light or dark the color is.
teknomage1 is offline   Reply With Quote
Old 02-17-2005, 03:08 AM   #5 (permalink)
inox
Registered User
 
Join Date: Feb 2005
Posts: 5
inox is on a distinguished road
Counting unique colours

Hi Teknomage1,

I actually had thought about using Hue rather than to consider the RGB values. Indeed by using hue it makes my life easier. One question though, will it be correct if I am using hue so as to count distinct colour in an image? I have tried this and had a number but not sure whether the amount is correct. Or do I need to consider both saturation and value as well?

Thank you and hoping to hear from you.

~inox
inox is offline   Reply With Quote
Old 02-17-2005, 09:26 PM   #6 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
It depends on how limited you want your palette, but I would consider all three values. A change in hue will have the greatest impact of course, but a blue with full value will look very different than one with half value and same for saturation. I'm not sure if there are algorythms for this, but to get an idea of how it all works together maybe you should just play with the color picker of your favorite image editting program. By playing with the visual display you can get an idea for your tolerance ranges.
teknomage1 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Character Counting Program DemosthenesB Standard C, C++ 8 04-03-2003 06:10 PM


All times are GMT -8. The time now is 12:49 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting