Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 12th, 2004, 04:40 AM
echo buzz echo buzz is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 9 echo buzz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
analizing pixels

hi all,
i want to write a simple program thats going to analize pixel colors in a bitmap. for example, if i load some bitmap, it will prosess every pixel in it and output on the screen or in a text file something like: R: 243, G: 132, B: 034 ( 20 pixels );
R: 121, G: 232, B: 123 ( 10 pixels );
R: 012, G: 123, B: 230 ( 15 pixels);
ect...
and so on for all pixels of the same color.

can someone sugest what will be the best suited language for this, as C++ is abit confusing with GDI libs,
and maybe point me in the right direction on how to go about it.
thanks.

Reply With Quote
  #2  
Old June 14th, 2004, 07:20 AM
WoR WoR is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Posts: 23 WoR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
A good idea would be to start by keeping for each letter a list of the n last references. Each list would be organized as a fifo (old entries get thrown out, e.g. circular list implementation).
If a certain enry (letter that is ) appears more often you ould start a sublist of two letter combinations starting with that letter.
So with each new letter you would find the maximum depth/length match in your tree of lists and do any appropriate coding with your repeated substrig, then modify the tree of lists to reflect the new statistics.

This scheme allows you to keep the table (list) size finite and yet have hte most current and/or longest patterns on hand.
The lists/trees might be implemented as (selforganizing) priority queues (e.g. splay trees).


You may also try to read into Huffman coding (which does someting similar with (typically) 1-letter statistics) or into Markov-coding (multi-level statistics) to find more ideas.

Reply With Quote
  #3  
Old June 14th, 2004, 08:13 AM
DevCoach DevCoach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,254 DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 8 h 9 m
Reputation Power: 265
The simplest algorithm is to use a hashmap of RGB value to count. Iterate through every pixel and increment the count for that pixel value.

The answer to the question "which is the best language" is "it depends..."

... are there speed constraints? How fast is it acceptable to process a single image of a given size? Milliseconds? seconds? minutes?

...What platform(s) does it need to run on? Does it need to be cross platform?

...How quickly do you need to write it? There is a trade off between speed of development and running speed.

...does it need to be integrated into some larger program? If so, does the other program impose language constraints (e.g. it is a function in a callable library?).

...what are the format of the images? GIF, JPG, BMP, TIFF etc all have different internal formats, so you will need some way of reading your target image type and converting it to an array of RGB values.

If processing speed is critical then C/C++ is the best bet. However the C++ standard does not include any way of handling images, so you will need to use a third party library, or write the whole thing from scratch (not recommended).

Other languages may have image processing incuded as part of their standard library, so they may be faster to develop with but run slower.

Dave - The Developers' Coach

Reply With Quote
  #4  
Old June 14th, 2004, 07:09 PM
dog135's Avatar
dog135 dog135 is offline
Doggie
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2003
Location: Seattle, WA
Posts: 751 dog135 User rank is Corporal (100 - 500 Reputation Level)dog135 User rank is Corporal (100 - 500 Reputation Level)dog135 User rank is Corporal (100 - 500 Reputation Level)dog135 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 10 h 38 m 25 sec
Reputation Power: 7
So you're just counting the number of unique colors in a bitmap? (.bmp file) Just about any language will work, since almost all allow some kind of file reading.

Do you currently know any languages? Even basic (ie: qbasic) will work for this, as long as speed isn't an issue.

If speed is an issue, you can't beat C++. And this would be an easy program to write in C++. But you may not want to learn it just for this one project.
__________________
"Science is constructed of facts as a house is of stones. But a collection of facts is no more a science than a heap of stones is a house." - Henri Poincare

Reply With Quote
  #5  
Old June 16th, 2004, 01:28 PM
medialint's Avatar
medialint medialint is offline
Type Cast Exception
Click here for more information.
 
Join Date: Apr 2004
Location: The Comfy Chair
Posts: 12,927 medialint User rank is General 32nd Grade (Above 100000 Reputation Level)medialint User rank is General 32nd Grade (Above 100000 Reputation Level)medialint User rank is General 32nd Grade (Above 100000 Reputation Level)medialint User rank is General 32nd Grade (Above 100000 Reputation Level)medialint User rank is General 32nd Grade (Above 100000 Reputation Level)medialint User rank is General 32nd Grade (Above 100000 Reputation Level)medialint User rank is General 32nd Grade (Above 100000 Reputation Level)medialint User rank is General 32nd Grade (Above 100000 Reputation Level)medialint User rank is General 32nd Grade (Above 100000 Reputation Level)medialint User rank is General 32nd Grade (Above 100000 Reputation Level)medialint User rank is General 32nd Grade (Above 100000 Reputation Level)medialint User rank is General 32nd Grade (Above 100000 Reputation Level)medialint User rank is General 32nd Grade (Above 100000 Reputation Level)medialint User rank is General 32nd Grade (Above 100000 Reputation Level)medialint User rank is General 32nd Grade (Above 100000 Reputation Level)medialint User rank is General 32nd Grade (Above 100000 Reputation Level)  Folding Points: 260297 Folding Title: Super Ultimate Folder - Level 1Folding Points: 260297 Folding Title: Super Ultimate Folder - Level 1Folding Points: 260297 Folding Title: Super Ultimate Folder - Level 1Folding Points: 260297 Folding Title: Super Ultimate Folder - Level 1Folding Points: 260297 Folding Title: Super Ultimate Folder - Level 1Folding Points: 260297 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Day 3 h 26 m 42 sec
Reputation Power: 3094
One time when I was bored I wrote an image manipulation program in Visual Basic. It works but it is incredibly slow. However, if you can effectively harness the API you can do a lot even within VB. Beyond that, C++ is certainly your best bet.

Reply With Quote
  #6  
Old June 29th, 2004, 07:56 PM
chuck54 chuck54 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Andorra / England
Posts: 80 chuck54 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 40 m 8 sec
Reputation Power: 5
I am interested in writing little programs like this one, for fun. Have you thought about doing a write up on it? I've been learning to use curses with c, and it would be really fun to and to try to print a bitmap image with curses.

On a side note, does anyone remember the curses version of quake? Man that was cool!

Reply With Quote
  #7  
Old July 2nd, 2004, 02:50 AM
echo buzz echo buzz is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 9 echo buzz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thnx guys for answering, i almost given up on this post.

the speed is critical to me, so ill be using c++, im also thinking of using Taged Image File Format, im learning openGL right now, openGL allows me to work with pixels in memory fairly easy,(you guys think its the way to go?) the reason i needed output in a: R : 123, B : 123, G : 123 format is so i could filter the colours i didnt want and keep track of deleted colours.
this is my 2nd year at uni so im still learning it all, but the sad thing is is that we only have one subject for graphics and its intro openGL
thnx again to everyone who answered, and if anyone has more sugestions please post them

thnx

Reply With Quote
  #8  
Old July 2nd, 2004, 12:37 PM
chuck54 chuck54 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Andorra / England
Posts: 80 chuck54 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 40 m 8 sec
Reputation Power: 5
OpenGL? Cool. I was reading a post about blender somewhere, and they quoted some opengl function. Drawing a line, i think. It seemed simpler than i'd thought previously. How is it for you?

Reply With Quote
  #9  
Old July 3rd, 2004, 01:51 AM
echo buzz echo buzz is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 9 echo buzz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i find openGL very easy and fun to learn, not like GDI, if you want to, try these links out:

http://www.opengl.org/resources/tutorials

and

http://www.opengltutorial.co.uk <-- very good link to start with, but sometimes is down.

cheers.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreSoftware Design > analizing pixels


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT