|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. ![]() |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
||||
|
||||
|
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 |
|
#5
|
||||
|
||||
|
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.
|
|
#6
|
|||
|
|||
|
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! |
|
#7
|
|||
|
|||
|
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 ![]() |
|
#8
|
|||
|
|||
|
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?
|
|
#9
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Software Design > analizing pixels |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|