ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 greenscreen

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
dracola Posted - Apr 08 2014 : 06:47:05
is imageen have proc like greenscreen?
i have tried imageen.Proc.SetTransparentColors but not working.
20   L A T E S T    R E P L I E S    (Newest First)
w2m Posted - Apr 17 2014 : 06:21:55
For the previously posted picture the correct Min and Max RGB values are
Min: CreateRGB(234,170,1)
Max CreateRGB(255,234,129)

These values have to be calculated for each picture. If any one color in the average of min or max in incorrect, will incorrect results will be produced. You MUST get the min and max values correct There is no other way than that described already in this post.

William Miller
dracola Posted - Apr 16 2014 : 23:12:06
i'v tried

ImageEnView1.IO.LoadFromfile('c:\background.jpg');
ImageEnView1.EnableAlphaChannel:=TRUE;
ImageEnView1.Proc.SetTransparentColors(CreateRGB(255,240,170),CreateRGB(255,210,0), 0); //remove yellow background

but, it's has a little rough edge on the edge between object (like people hair) and background...
just wandering is there a way to add feather like in selection in ImageEnView1.Proc.SetTransparentColors ?

Thank's a lots specialy to w2m, spetric & xequte for the solution ^_^
w2m Posted - Apr 11 2014 : 06:14:26
@Dracola - There is no chromakey procedure.

William Miller
spetric Posted - Apr 11 2014 : 04:10:25
@Bill, @Nigel

You're right. Image can be used as output mask.
I'm inspecting some algorithms that works, let's say, semi-automatic, using user supplied threshold value. Many of them works in a single pass (scanning through image pixels).

Bill's technique may be developed further (automated), i.e. sorting palette with respect to hue, and then check pixels hue against some threshold or tolerance.

dracola Posted - Apr 11 2014 : 03:33:52
is imageen have algoritm like chroma key? beside using imageen.Proc.SetTransparentColors?
w2m Posted - Apr 10 2014 : 19:01:19
I tied to render your image as transparent. My demo could not do it because there were too many colors in non-transparent areas that were also in the transparent area as suggested by Nigel. As a result pixels that should not be transparent were rendered transparent.

This is the first image I have tried where it failed to produce good results. just a little bit simpler images (like the gird picture) always seems work quite well.

There may no way to render this picture transparent other than by doing it manually by editing the pixels, but even that may produce somewhat poor results.

I might add that the reason why I used 256 colors is because with a full color image who wants to take the time to select 16,000 similar colors.... It was a necessity to get this to work reasonably well.

William Miller
xequte Posted - Apr 10 2014 : 18:22:05
@Bill: I'm not sure that there is any reasonable way to sort colours. If you were after a basic hue, such as yellow, you could quite easily create an algorithm that weighted the yellow channel the most, with a lesser weighting given equally to the red and green channels, but it would not work for abstract hues such as dark purple or aquamarine.

@Spectric: Yes, but if Bill has a method that works well in 256 colours, then you could easily use the output as a mask against full colour. Personally however, I am not sure there is an easy solution to this problem, as it is not only a question of colours, but also of boundaries. In your example image there are greens amongst the leaves of the same shade as those in the shadow of the children.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
spetric Posted - Apr 10 2014 : 14:49:41
It seems I'm missing the point. Are we talking about full 24-bit image
or image reduced to 256 colors?

Here is an image I've worked with (found it on the web):
http://susmadik.com/wp-content/uploads/18.jpg

When simple algorithm is applied, there are always border artifacts.
I'm talking about 24-bit output image (plus alpha channel).
w2m Posted - Apr 10 2014 : 14:28:21
@Spetric,

The problem is not with artifacts or setting the alphachannel... the problem is sorting the palette. So far I have not seen any artifacts at all when the colors are selected correctly.

Send me your most difficult image and I'll see how it does. So far I have not fond an image that produces poor results.



William Miller
w2m Posted - Apr 10 2014 : 14:23:13
@Nigel,

That is what I am doing now, but for the yellow background Image shown earlier in this que there are about 200 shades of "yellow" among a palette of 255 that have to be selected and they are scattered all over the palette... If all the yellow hews were all together then selecting the "yellow" would be trivial.

The problem is not calculating the min and max values but how to display a 255 color palette sorted by Hew or similar color.

William Miller
spetric Posted - Apr 10 2014 : 14:13:29
Yes Will, it works good, however problem of border artifact comes when you have 24-bit image.

Here I find some discussion on this topic:
http://www.lac.inpe.br/JIPCookbook/6520-howto-chromakey.jsp

Regarding on palette sorting, it's a complex task. I have some palette functions in my prog. and I sort palette entries using luminance. Then I use binary search to find closest luminance, etc. But, luminance is sometimes not enough, because different hues may have equal luminosity.

So, for such kind of task, maybe it's better to sort palette entries according to color hue.

@xecute

>Sorry, I may have missed the point, but why not iterate all colors in a selection of the image calculating the minimum and maximum RGB values? (though naturally may have unexpected consequences if the color range is broad)

I use simple algorithm for such task. When iterating through colors
simply find difference (if green screen is examined) between green channel and max(r, b):


// loop through image pixels and set alpha channel
// threshold - value specified by user
gDiff = g - max(r,b);  
if (gDiff > threshold)
   alpha = 0;
else
   alpha = 255;    	


But, I still have border artifacts if background has a broad color range.
xequte Posted - Apr 10 2014 : 14:06:03
@Bill

> I wish I could figure out how to sort the colors then it would be simple matter of selecting the rows of the background color.

Sorry, I may have missed the point, but why not iterate all colors in a selection of the image calculating the minimum and maximum RGB values? (though naturally may have unexpected consequences if the color range is broad)

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
w2m Posted - Apr 10 2014 : 13:32:03
Spectric... Yes this is the best I have seen, although I must admit that for some images selecting all the background colors is not as easy as it should be when there are a lot of similar colors scattered in the 255 color palette. But even for moderately complex backgrounds it is relatively simple... If you select the correct background colors it returns a perfect result each time.

I wish I could figure out how to sort the colors then it would be simple matter of selecting the rows of the background color.

William Miller
spetric Posted - Apr 10 2014 : 13:03:43
I made a mistake: SetTransparentColor method will actually create alpha channel,
so the line ImageEnView1->IEBitmap->AlphaChannel isn't necessary.

It's very interesting how this image came out very good, without border artifacts that usually comes when simple algorithms for removing background are used.

w2m Posted - Apr 09 2014 : 15:49:45
There is no other known way to get the min and max that I know of, but if you select the colors correctly... it works perfectly regardless of how complex the background is. for many images you only have to select a couple of rows of colors with SHIFT-Click... you do not have to select each color individually.

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Custom ImageEn Development
dracola Posted - Apr 09 2014 : 15:45:30
yeah, that the problem now how to get min & max from image background?
i'v tried your demo program, which i must select almost every similar color from pallete to get select all the background to get perfect result like your result image.
but how to determine optimal min & max color in a image?
w2m Posted - Apr 09 2014 : 10:17:38
Do you have some way to pick the correct RGB colors that I am not aware of? How will you set the Min and Max for other images?

William Miller
dracola Posted - Apr 09 2014 : 09:49:26
oh my gosh...shame on me...
i just used min & max color that you gave and viola it's work...

thank's a lot w2m for all your help & trouble
w2m Posted - Apr 09 2014 : 08:42:24
The yellow you are trying to make transparent is not all pure yellow. There are many shades of yellow in the image as I am sure you aware. You came pretty close to guessing the RGB values:
Min: CreateRGB(255,240,170)
Max: CreateRGB(255,210,0)

But the correct Min and Max RGB values are
Min: CreateRGB(234,170,1)
Max CreateRGB(255,234,129)

My "Select Similar Colors Demo" at http://www.imageen.com/ieforum/topic.asp?TOPIC_ID=1446 will reveal the yellow shades.

It is difficult to render a background with many different shades of yellow as transparent but my other demo "Make Selection Transparent Demo" shows you how to do this.

It works by calculating the minimum and maximum RGB color values so that the correct values are set with SetTransparentColors. It is nearly impossible to "guess" at the minimum and maximum color RGB values. As far as I know the only way to do this is by calculating the minimum and maximum RGB values for all the shades of yellow from all the pixels in the image.

Here is your photo rendered as transparent and saved as a png image with my demo:

This particular picture is quite difficult to deal with because there are about 200 shades of yellow in the image out of a palette of 255 colors.

This will render the yellow shades as transparent:
ImageEnView1.Proc.SetTransparentColors(CreateRGB(234,170,1),CreateRGB(255,234,129), 0);
  ImageEnView1.Update;

so if you use the correct RGB values the transparency will be rendered correctly.

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Custom ImageEn Development
dracola Posted - Apr 09 2014 : 07:48:05
thank's spetric for your help

i'v add to be like this, but it's seems still doesn't do anything

ImageEnView1.IO.LoadFromfile('c:\background.jpg');
ImageEnView1.IEBitmap.AlphaChannel;
ImageEnView1.EnableAlphaChannel:=TRUE;
ImageEnView1.Proc.SetTransparentColors(CreateRGB(255,240,170),CreateRGB(255,210,0), 0); //remove yellow background

may be if i add the image that i used if that helps

i want to make yellow background become transparent so i can add new layer for the background like beach or mountain picture ^_^