Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Monday, November 14, 2005 6:20:37 AM(UTC)
Digital Widgets

Groups: Registered
Posts: 3


Using the .NET classes...I'm trying to create a green screen type of knock out effect.  Basically, I have an image (jpg) from a digital camera, of a subject in front of a large piece of chroma green paper.  I've played with the SelectiveColorTest Sub that I found in the instructions, and I can manipulate the color of the green background rather well using:

Dim command As Leadtools.ImageProcessing.Color.SelectiveColorCommand = New Leadtools.ImageProcessing.Color.SelectiveColorCommand

command.ColorsData(Leadtools.ImageProcessing.Color.SelectiveCommandColorTypes.Green).Black = 100

command.Run(image)

This code snipet seems to do an excellent job of darkening my green background (and not touching my subject).  I've played with other ColorsData values and can easily tweak the green background way up as well.  My thinking is, if I can manipulate the colors over a range of hues, there must be some way to manipulate it to transparant.  Or perhaps create some kind of mask based on a range of colors.  In addition, I've played with the AddColorRgbRangeToRegion to select the green area, but it didn't seem to affect the range of greens as effectively as manipulating with the ColorsData commands.

What I can't figure out is how to tweak that green to become transparent.  Once I had the green screen areas knocked out, I then will lay that image on top of another background.  Could someone please help send me in the right direction.  I'm new to the .NET classes, so any sample code for any of the steps would also be greatly appreciated.

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Wednesday, November 16, 2005 1:22:13 AM(UTC)

Amin  
Amin

Groups: Manager, Tech Support
Posts: 367

Was thanked: 1 time(s) in 1 post(s)

You can combine the image on top of another image, and exclude certain
areas. To do that, you need to define a region in the image. Anything
outside the region will not be copied to the destination (background)
image.

To define a region based on color (such as green), you can use the
RasterImage.AddColorToRegion Method. However, this only works if the
color is completely uniform.

To define a region based on a color range instead of a specific color,
you can use AddColorHsvRangeToRegion or AddColorRgbRangeToRegion.

Since you want to exclude the color or color range, not include it, the RasterRegionCombineMode to use is SetNot.

Once the region is defined, use CombineCommand or CombineFastCommand.
There's a help topic named "Combining Images With Regions" that gives
some details about this.

Edited by user Tuesday, December 6, 2016 3:41:44 PM(UTC)  | Reason: Not specified

Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#3 Posted : Sunday, November 20, 2005 2:03:52 PM(UTC)
Digital Widgets

Groups: Registered
Posts: 3


I've used the AddColorRbgRangeToRegion command with limited success.  The problem is that one color range doesn't quite get all of my background (shadows, slight variations in lighting, etc.).  What I need to do is add a color range to the region, then add another color range, then perhaps another, until I have my entire green backdrop selected.  I'd then like to fill that with transparent color...then combine the resultant image onto my final background image.  Or...keep adding to my region, and then some how change my region to the reverse of what it is.   Is it possible to add to the region several times (using the AddColorRgbRangeToRegion command), before I try to combine?  I'm having real difficulty getting this process working in my code...the examples in the help file have no commenting as to what each line is doing, so I'm guessing quite a bit as to how to get my code working.
 
#4 Posted : Tuesday, November 22, 2005 2:31:32 AM(UTC)

Amin  
Amin

Groups: Manager, Tech Support
Posts: 367

Was thanked: 1 time(s) in 1 post(s)

Yes, it is possible to add a new region to an existing region without
removing the old. You can also invert an existing region. All possible
options are explained in the help topic "RasterRegionCombineMode
Enumeration"

Alternatively, if you post a sample image with a sample green screen or
send it to support@leadtools.com, we could check it and possibly
suggest an appropriate range to use.

Edited by user Tuesday, December 6, 2016 3:42:07 PM(UTC)  | Reason: Not specified

Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#5 Posted : Thursday, November 24, 2005 9:39:23 PM(UTC)
Digital Widgets

Groups: Registered
Posts: 3


Well...I finally found the AddColorHsvRangeToRegion command and it works much better than using RGB colors to get all my greens added to my region.  That leaves me with one last issue to solve:

I've now got a selected "green" region.  I can invert that region selection to just get my subject.  I've cloned that region (just the subject) into the floater image of my background, and the user can move it around to their hearts content.  And double click to merge it with the background....all working great....except:

I want to resize my subject down (the floater image over the background).  When I resize him, I end up with the original image resized (and all of my green back).  Now I realize that the floater image must be the original image and it's region selection (which creates a mask so my background shows through).  What I'd like to do is "apply" that knockout/transparancy to the floater image before resizing it.  The reason I'd like to do it at this stage (as opposed to earlier in the process) is to hopefully anti-alias the hard pixel edges created by the region when we resize.   

Is it possible to take a selected region, place it in a new image of transparent pixels and resize it to maintain that transparency (and maybe even anti-alias a bit of that transparency in the process)?  Then would it be possible to take that resulting image and use it as a floater while maintaining that transparancy?

 
#6 Posted : Sunday, November 27, 2005 11:50:59 AM(UTC)

Amin  
Amin

Groups: Manager, Tech Support
Posts: 367

Was thanked: 1 time(s) in 1 post(s)

I'm not sure about the exact details of all your code, but you might be
able to do this by keeping the original image that has the final
region. If you use Leadtools.ImageProcessing.SizeCommand on an image
that has a region, both the image and region are resized together.

So to use this approach, you keep the subject+greenscreen+region image
alone and background alone. You then resize one or both of them
separately, then perform the merging.

This doesn't solve the "hard pixel edges" problem, but there is another
way to solve it. You could use the FadedMaskCommand Class to create a
special mask image based on your region. Then use this mask with
FeatherAlphaBlendCommand to make smooth combining instead of using the
plain Combine function.

Edited by user Tuesday, December 6, 2016 3:42:37 PM(UTC)  | Reason: Not specified

Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.182 seconds.