Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Borland Delphi > Fast way of spl...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 37 Topic 3714 of 3852
Post > Topic >>

Fast way of splitting an image into bit planes ?

by "Skybuck Flying" <BloodyShame@[EMAIL PROTECTED] > Apr 27, 2008 at 09:23 PM

Hello,

Input points to the pixel data of an image, which is in RGB format.

Another way to look at the image is:

24 bit planes.

I want to extract each bit plane and put all the bits in sequence and then

stick them together.

The following code does that :

Input is a pointer
vBit is a pointer, (pointing to a large buffer)
the rest are integers

 for vBitPosition := 0 to 23 do
 begin
  for vPixelIndex := 0 to vPixelCount-1 do
  begin
   if GetBit( Input, (vPixelIndex * 24) + vBitPosition ) then
   begin
    SetBit( vBit, vPixelIndex + (vPixelCount * vBitPosition) );
   end else
   begin
    ClearBit( vBit, vPixelIndex + (vPixelCount * vBitPosition) );
   end;
  end;
 end;

The only problem is:

It's probably hellish slow.

How would you optimize this code ?

I am about to go to sleep, so I am too tired to try and optimize it
myself.

But maybe somebody else wants to ****ne his/her light over it and come up 
with something nifty.

I myself was thinking something in the lines of:

Use ****fts, and and's and then some more ****fts and some more and's.

Only question remaining is which way of walking through memory will be
more 
efficient ?

Walk through input source once ? and split everything up.

Or walk through input source 24 times and split a plane at a time.

^ Good question.

I don't understand the memory sub system well enough to make a good guess.

Walking 24 times through the same memory doesn't seem to smart...

But then again walking once through the input memory and then doing
massive 
random access for the output doesn't seem smart as well.

So both methods have their drawbacks.

At least getting rid of the bitset/bitget instructions should improve 
performance somewhat ;)

Oh yeah I was thinking something in the lines of:

Try to collect 32 bits for one bit plane. Then write the longword to the 
pointer.

Then continue.

Hmmm since this is graphics related, maybe graphics cards have a special 
ability to do this ?????

Bye,
  Skybuck.
 




 37 Posts in Topic:
Fast way of splitting an image into bit planes ?
"Skybuck Flying"  2008-04-27 21:23:00 
Re: Fast way of splitting an image into bit planes ?
"Skybuck Flying"  2008-04-27 21:46:14 
Re: Fast way of splitting an image into bit planes ?
"Skybuck Flying"  2008-04-27 21:53:57 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-28 20:43:33 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-29 09:39:52 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-29 10:14:23 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-29 10:25:46 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-29 10:27:56 
Re: Fast way of splitting an image into bit planes ?
Ivan Levashew <octagra  2008-04-28 02:58:04 
Re: Fast way of splitting an image into bit planes ?
Robert Redelmeier <red  2008-04-27 21:35:35 
Re: Fast way of splitting an image into bit planes ?
"Skybuck Flying"  2008-04-28 09:07:10 
Re: Fast way of splitting an image into bit planes ?
Wolfgang Draxinger <wd  2008-04-28 11:12:18 
Re: Fast way of splitting an image into bit planes ?
"Skybuck Flying"  2008-04-28 11:59:50 
Re: Fast way of splitting an image into bit planes ? (How would
penang@[EMAIL PROTECTED]   2008-04-29 03:42:18 
Re: Fast way of splitting an image into bit planes ? (How would
"Ken Hagan" <  2008-04-29 12:46:09 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-29 13:56:42 
Re: Fast way of splitting an image into bit planes ? (How would
penang@[EMAIL PROTECTED]   2008-04-29 05:35:15 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-29 14:59:43 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-29 18:54:19 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-29 19:02:51 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-29 21:14:29 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-29 21:19:49 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-30 11:19:55 
Re: Fast way of splitting an image into bit planes ? (Skybuck's
"Skybuck Flying"  2008-04-30 17:20:12 
Re: Fast way of splitting an image into bit planes ? (Skybuck's
"Skybuck Flying"  2008-04-30 17:39:30 
Re: Fast way of splitting an image into bit planes ?
Bo Schwarzstein <Bo.Sc  2008-05-01 03:54:28 
Re: Fast way of splitting an image into bit planes ? (Skybuck's
pg <penang@[EMAIL PROT  2008-05-01 08:21:30 
Re: Fast way of splitting an image into bit planes ? (Skybuck's
"Skybuck Flying"  2008-05-01 20:19:01 
Re: Fast way of splitting an image into bit planes ?
Terence <tbwright@[EMA  2008-05-01 16:06:03 
Re: Fast way of splitting an image into bit planes ?
pg <penang@[EMAIL PROT  2008-05-02 18:01:31 
Re: Fast way of splitting an image into bit planes ? (Skybuck's
pg <penang@[EMAIL PROT  2008-05-02 18:03:40 
Re: Fast way of splitting an image into bit planes ? (Skybuck's
"Skybuck Flying"  2008-05-03 19:40:48 
Re: Fast way of splitting an image into bit planes ?
"windenntw@[EMAIL PR  2008-05-04 13:09:13 
Re: Fast way of splitting an image into bit planes ?
"Skybuck Flying"  2008-05-04 22:54:19 
Re: Fast way of splitting an image into bit planes ?
Nils <n.pipenbrinck@[E  2008-05-04 23:11:31 
Re: Fast way of splitting an image into bit planes ?
"Skybuck Flying"  2008-05-05 01:40:01 
Re: Fast way of splitting an image into bit planes ?
"Skybuck Flying"  2008-05-05 01:55:31 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 19:31:41 CDT 2008.