User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 455,973 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,828 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 1073 | Replies: 4
Reply
Join Date: Nov 2007
Posts: 2
Reputation: iamconfused is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
iamconfused iamconfused is offline Offline
Newbie Poster

HELP: Day 0 - Chroma Key Programming

  #1  
Nov 26th, 2007
Hello...
First of all hello to everyone... this is my first post. I did some 'googling' for help with C code and found this place, the reason I need help is because I am working on a (what I consider hard) project and (only) a week and a half to complete it.

Project Details...
To write a C code which extracts the foreground and replaces the background, in other words, chroma key programming, or blue screen editing. Taking a part of an image and replacing the background.

Basically, I have 125 subsequent frames, in which people are moving in and out the frames. The background consists of bushes and trees. The people are walking on a sidewalk. The task at hand is to extract these people and place them walking on an output image, an image of the beach.

So, basically the task consists of... reading in input_image0001.jpg, extracting the foreground, replacing the background with beach.jpg and creating output_image0001.jpg.

What I Know...
So, background information about me: I am not by far a talented coder, but I do love coding and learning. So, I'm here asking for help. So far, I know how to read in the image, i know how write out an image, i know how to isolate each pixel, and "play" with the RGB values.

The input image is 640x140 & the output image is 640x480. I am already aware that vertical offset is going to be necessary to transpose the foreground onto the beach, so the people do not look like they are walking on water, lol.

What I Need Help With...

1. I am trying to figure out an algorithm that will help me extract the people (and clothing, purses, hats, etc) from the original image. The people are not of the same race, therefore not the same color, nor are their clothes the same color. The background is the only thing somewhat constant. I've been considering a "sum of absolute differences." I am confused about how to handle this, because I considered subtracting pixels but then I'm not sure what to subtract from?

One idea I had was if I could somehow run the program to read in all 125 images at the same time and subtract them from each other, meaning any of the background not covered by a person would just be deleted and then take the result and add that to 125 output images. Sounds Crazy?


This is all I can think about for Day 0, it's getting late for me, I'' check back constantly. So, any help is gratelly appreciated it. Thank you and I hope you all have a wonderful Monday.

Sincerely,

I am Confused
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2006
Location: the Netherlands
Posts: 1,817
Reputation: niek_e is a name known to all niek_e is a name known to all niek_e is a name known to all niek_e is a name known to all niek_e is a name known to all niek_e is a name known to all 
Rep Power: 11
Solved Threads: 189
niek_e's Avatar
niek_e niek_e is offline Offline
Posting Virtuoso

Re: HELP: Day 0 - Chroma Key Programming

  #2  
Nov 26th, 2007
If you're not an experienced programmer, this problem will be near impossible to complete in only one week. With that said:

Is the background static or is the camera moving and therefore the background moving?
If the background is static you should loop through the 125 images and compare each one with the previous and deleting pixels that stayed the same and keeping all the others. Then replace the deleted pixels with the pixels from the new image. This means the two pictures would have to be the exact same dimensions.

Niek
Want better/more replies to your questions? Wrap your code in [code] [/code] tags!
do NOT pm me for help, in the best case, you'll get ignored
Reply With Quote  
Join Date: Dec 2005
Posts: 3,834
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 23
Solved Threads: 436
Colleague
Salem's Avatar
Salem Salem is offline Offline
banned

Re: HELP: Day 0 - Chroma Key Programming

  #3  
Nov 26th, 2007
Focus on what "isBackground" rather than everything else.

If it's background, replace with corresponding pixel from background image, otherwise just copy the pixel.
Reply With Quote  
Join Date: May 2006
Location: ★ ijug.net ★
Posts: 1,012
Reputation: ithelp will become famous soon enough ithelp will become famous soon enough 
Rep Power: 6
Solved Threads: 68
ithelp ithelp is offline Offline
Veteran Poster

Re: HELP: Day 0 - Chroma Key Programming

  #4  
Nov 26th, 2007
This could be easily a 3-6 months project, provided some one gives your a readymade image processing algorithm.
Reply With Quote  
Join Date: Nov 2007
Posts: 2
Reputation: iamconfused is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
iamconfused iamconfused is offline Offline
Newbie Poster

Re: HELP: Day 0 - Chroma Key Programming

  #5  
Nov 26th, 2007
Ok, so I've been thinking about this and I've come up with sort of a solution and I need opinions and help.

First of all, I'm going to use the first 5 frames to create a background model, basically train the background.


To train the background, I'm going to track an average & standard deviation for RGB or pixel (i'm not sure which yet) values of 5 frames.

Once, I have a background model, I will compare the next frame to this background model. If the new value is less than a set # above the standard deviation, it is a background pixel and therefore deleted.

so in the end, i will only have 120 output images, which is fine.


The only thing that is left is:
1. implementing this "training method."
2. figuring out how to read in 5 images at a time.
3. figure out how to write a script that takes in 120 input images, applies the code, and outputs 120 images.

any help is appreciated... thank you.

- i am confused
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 9:15 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC