GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #11  
Old 09-Oct-2007, 13:56
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,218
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: How to get the pixels' value of a bmp image?(Pelles C)


Quote:
Originally Posted by davekw7x
The original poster wanted to get the grayscale values of the pixels into an array so that he could execute an edge detection algorithm consisting of a 2-D convolution.

Another mental error on my part.

Actually that was another thread that kind of died. This thread had something to do with encryption, but we never got far enough into the bitmap part to worry about the encryption part.

I think I need to take a break.

Oh, well...

Regards,

Dave
  #12  
Old 09-Oct-2007, 15:00
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,218
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: How to get the pixels' value of a bmp image?(Pelles C)


Quote:
Originally Posted by davekw7x
[edit]The first two bytes in a bmp file are ascii 'M' and 'B' in that order. Think of it as a "little-endian 'B','M'. [/edit]

Another oops in the descriptiion.

ASCII 'B' is 0x42; ASCII 'M' is 0x4d.

The first two bytes in the file are 'B', 'M'---a big-endian 'B', 'M'. SInce I read the whole header with one operation, the bytes are stored in the buffer in the same order as they occur in the file. So 'B' is in address zero of the buffer and 'M' is in address 1

With a little-endian machine, when you fetch a 16-bit integer from location zero, it places the first byte in the lower eight bits of the integer and the second byte in the upper eight bits of the integer.

And that's why the value is shown as 0x4d42.

Regards,

Dave
  #13  
Old 10-Oct-2007, 09:21
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 803
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: How to get the pixels' value of a bmp image?(Pelles C)


Quote:
The first two bytes in the file are 'B', 'M'
That's what I was seeing. I WAS scratching my head all day about it.
The ordering of the bytes (for say, an int) has always been confusing to me too. But I press on...
Quote:
I think I need to take a break.
For as many lengthly replies as you make it would be well deserved, but yer doin fine!
We all aprecionado...
I'll continue into this over the next few days-weeks. Interesting stuff to see.
I had always wondered how image files were put together. Now I'm seeeing it...
Thanks for the assignments, (like I need more temptation to avoid work stuff)
++Howard;
  #14  
Old 15-Oct-2007, 14:21
Soundzz Soundzz is offline
Awaiting Email Confirmation
 
Join Date: Oct 2007
Posts: 14
Soundzz is on a distinguished road

Re: How to get the pixels' value of a bmp image?(Pelles C)


thank you very very much, dave

I want to send a pdf file to you to let you see what I really wanna do actually...

could you give me a private message of your email or so on?

Thank you very much again,
Regards
Sound
  #15  
Old 15-Oct-2007, 20:08
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,218
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: How to get the pixels' value of a bmp image?(Pelles C)


Quote:
Originally Posted by Soundzz
I want to send a pdf...

How about just telling us? Think of it as good training for the day when you are someone's boss (maybe mine) and you want to create a Program Specification of a small program in a text file.

If we can't figure it out, we'll ask again.



Regards,

Dave
  #16  
Old 25-Oct-2007, 02:51
Soundzz Soundzz is offline
Awaiting Email Confirmation
 
Join Date: Oct 2007
Posts: 14
Soundzz is on a distinguished road

Re: How to get the pixels' value of a bmp image?(Pelles C)


dear dave

actually, i would like to do something like this:
www. ibiblio. org / e-notes/ Chaos/ baker.htm
  #17  
Old 25-Oct-2007, 06:11
Soundzz Soundzz is offline
Awaiting Email Confirmation
 
Join Date: Oct 2007
Posts: 14
Soundzz is on a distinguished road

Re: How to get the pixels' value of a bmp image?(Pelles C)


dear dave

actually, i would like to do something like this:
www. ibiblio. org / e-notes/ Chaos/ baker.htm

and

www. sciencedirect .com/science?_ob=ArticleURL&_udi=B6TJ4-4FGX7X7-2&_user=13304&_coverDate=10%2F31%2F2005&_rdoc=1&_f mt=&_orig=search&_sort=d&view=c&_acct=C000001598&_ version=1&_urlVersion=0&_userid=13304&md5=86381792 a0d50c3b993233e365085ed8

and

www. springerlink. com/content/t0638763n4207m7j/fulltext.pdf

and

www. informatica. si/PDF/31-1/22_Ahmed-An%20Efficient%20Chaos-Based%20Feedback...pdf
Regards..><
  #18  
Old 25-Oct-2007, 11:19
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,218
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: How to get the pixels' value of a bmp image?(Pelles C)


Quote:
Originally Posted by Soundzz
..actually, i would like to do something...

Assuming that your output will be an 8-bit gray-scale bitmap, here's a game plan:

Step 1. Determine the size of the bitmap by reading the height and width values from the header. Allocate an array[height][width] of unsigned chars. This is your input matrix. (Alternatively, you could have declared a fixed array whose dimensions are as large as the largest bitmap that your program will have to deal with.)

Step 2. Read in the bitmap pixel values, convert to 8-bit gray-scale values if necessary, and store them in your input matrix.

Step 3. Do whatever you want to with the element values in the matrix.

Maybe a formal transformation consisting of a sequence of multiplications by other matrices.

Maybe an ad-hoc nested-loop routine that swaps values among matrix elements, or, maybe, copies elements of the input matrix to different positions of another matrix that you will use for writing an output bit map file.

Step 4. Write out the bitmap file.



Now, if it's not an eight-bit gray-scale, then you have a number of choices. Maybe the simplest would be to declare a struct of pixel values. The struct elements will represent Red, Green, and Blue values for a pixel. Then your input matrix is an array[height][width] of the pixel structs. Matrix manipulation is performed on this array. The principle is the same, you simply make your data structure consistent with your problem. The point is: get the pixel data into a 2-D array that you can work on to do the required transformations.

Regards,

Dave
  #19  
Old 04-Nov-2007, 13:32
Soundzz Soundzz is offline
Awaiting Email Confirmation
 
Join Date: Oct 2007
Posts: 14
Soundzz is on a distinguished road

Re: How to get the pixels' value of a bmp image? (Pelles C)


Dear ALL,

after several days... I still cannot pass all the pixels' values into an 2D array correctly (8/16/24-bit color)... can anyone help me more about this... very upset at this moment..><

Regards
  #20  
Old 04-Nov-2007, 14:11
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,218
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: How to get the pixels' value of a bmp image? (Pelles C)


Quote:
Originally Posted by Soundzz
...can anyone help me...

Am I missing something?

I can't find a single line of code that you have posted. Since we have absolutely no way of knowing what you have tried, how could you reasonably expect anyone to be able to help???

1. Show your code. If you can trim it down to a small subset that shows your specific problems, that would be a Good Thing.

2. Tell us what exactly happened when you tried to compile and/or execute the code. (Be specific.)

3. Tell us what exactly you don't understand. (Be specific.)

Regards,

Dave
 
 

Recent GIDBlogProgramming ebook direct download available by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about locking surfaces to directly access pixels, SDL. george89 C++ Forum 0 18-Jun-2006 22:16
Pixels dan_ielle20 C++ Forum 0 23-Mar-2005 09:54
Checking source codes of image, audio and video files onauc C Programming Language 5 26-Feb-2005 22:47

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:23.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.