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 : Thursday, September 20, 2007 7:22:03 PM(UTC)
pshirley

Groups: Registered
Posts: 2


I am new to Leadtools and I cannot seem to find what the best method for removing a blue background on a photo is. I have been playing with the SubtractBackgroundCommand class in the .NET ImageProcessing assembly. We have Leadtools v15. What I am finding is that this tool is best used for grayscale images and not color photos. Is there a better method for doing this that I am missing. I am attaching a sample photo.

Thanks for any help you can offer.
pshirley attached the following image(s):
michael levi.jpg
 

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 : Friday, September 21, 2007 10:08:28 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


What are you wanting to do with the background, what does "removal" entail?  If you simply want to change the color then you can use RasterImage.AddColor[Rgb or Hsv]RangeToRegion method using RasterRegionCombineMode.Set.  If you've tweaked the colorrange correctly then you can run a FillCommand on the image to swap out the color.  If you want to select all of the pixels of the person, you can use the RasterRegionCombineMode.Not.

The only downside to this is if the person has something them (clothes, eyes, makeup) that matches the background and then you'll end up erasing or losing that portion as well.  Also, the shadow that it on the right side of the person will still be there.  Depending on what you're actually doing with the image, this might be acceptable.

If you have problems, please explain your goals in more detail and what problems you're having.
 
#3 Posted : Friday, September 21, 2007 5:03:11 PM(UTC)
pshirley

Groups: Registered
Posts: 2


The approach you specify might work for me. I need to replace the blue background with pure white. The issue is that the image needs to be printed and if the background is anything but pure white then the background is printed. That said I do have the concern about finding the edge of the person. I cannot replace a blue shirt or blue eyes with white. So if you could expand a little on your approach or supply some sample code I would appreciate it.
 
#4 Posted : Monday, September 24, 2007 7:25:13 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


I have created a small C# example that:

1. Shows how to select a color with RasterImage.GetPixelColor
2. Creates a region from a color range with RasterImage.AddColorRgbRangeToRegion
3. Fills the region with the FillCommand class.

This project is very similar to Adobe Photoshop's color range selection tool.

As for the problems such as eyes, shirts, etc. you will either need to make some kind of "safe" area that cannot be selected or you'll have or change your approach completely to some kind of a fill search rather than using AddColorRgbRangeToRegion.  To implement a "safe" area you'll need to play with the different combine modes to find a logic that works for you.
File Attachment(s):
NET - v15 - AddColorRgbRangeToRegion.zip (271kb) downloaded 42 time(s).
 
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.138 seconds.