Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Hi I have a problem with my memblock. It's not taking out all the colors for see through

Author
Message
darkvee
20
Years of Service
User Offline
Joined: 18th Nov 2005
Location:
Posted: 12th Oct 2012 19:19 Edited at: 12th Oct 2012 19:20
Hi I'm having a problem taking out all of the color values of rgb(255,0,255) in the memblock. I want to get rid of any color value that matches that and make it see through.

Here is the code that shows it. Notice on the rabbit I still have 255,0,255 color pixels in it.
I'm going to upload the rabbit image i'm using.

Anyone know how to take all that 255,0,255 out?



darkvee
paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 12th Oct 2012 19:54
Dont really see much wrong with this code,try this and see if its what you were expecting,the image is definitely transparent as the cube shows once the texture is applied.
darkvee
20
Years of Service
User Offline
Joined: 18th Nov 2005
Location:
Posted: 12th Oct 2012 20:08
Hi paul,

I still see the color Magenta rgb(255,0,255) When I zoom in. but thanks for the help though

darkvee
Scraggle
Moderator
23
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 13th Oct 2012 11:50 Edited at: 13th Oct 2012 11:53
Your code is sound. From that you will be removing all of the 'pure' magenta. What you are probably seeing is the pixels that are close to but not magenta caused by anti-aliasing in the initial image creation.

If you made the image, then I would suggest making it again but turn off anti-aliasing. Or better still, make it with a transparent background.

If you really must use this image then instead of removing the pure magenta, remove everything that isn't pure green. It may give you hard edges though, so perhaps create your own anti-aliasing by setting the transparency level of the pixels depending on how far off the pure colour they are.

The edge of your image - not pure green/pure magenta:
darkvee
20
Years of Service
User Offline
Joined: 18th Nov 2005
Location:
Posted: 16th Oct 2012 15:55 Edited at: 16th Oct 2012 15:56
Hi Scraggle,

Thanks man.

So I need to also make it anti-aliasing for it to work.
I'm thinking after I take out all the magenta. Use another function that goes around it and adds a same pixels for up,down,left,right. This should solve the problem.

darkvee
Scraggle
Moderator
23
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 16th Oct 2012 19:21
Quote: "Use another function that goes around it and adds a same pixels for up,down,left,right."


That sounds like a lot of effort when you could achieve the same thing by doing what I suggested:

Quote: "remove everything that isn't pure green"
The Weeping Corpse
14
Years of Service
User Offline
Joined: 19th Sep 2011
Location: United Kingdom
Posted: 16th Oct 2012 19:50
A few years ago I was working with green screens. Searching for and removing pure green pixels is a bad idea, you need to implement some kind of tolerance or do as Scraggle suggested, remove everything that isnt pure green.

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th Oct 2012 20:10 Edited at: 16th Oct 2012 20:12
As scraggle suggested, remove anything that isn't pure green. All you have to change to your existing code is this:



Might get rough edges, but all the magenta will be gone. Also noticed your "green" is really rgb(0,255,30).

But, if you really want the edges to have AA and simply remove that slight bit of magenta from it, then we could do that too!

I'll state that this method only works as simply as it does here because only two solid colors are involved in the overall makeup of the image, and we know what those two colors are.

Using linear interpolation, determine the amount the green has faded into the magenta to result in the particular color we see. For pure magenta, green has faded completely so we replace those pixels with green with an alpha value of 0. As for the edges, some green will be there resulting in values between 0 and 1. Replace those edge pixels with solid green and adjust their alpha accordingly.


Try this.


"You're not going crazy. You're going sane in a crazy world!" ~Tick
The Weeping Corpse
14
Years of Service
User Offline
Joined: 19th Sep 2011
Location: United Kingdom
Posted: 16th Oct 2012 21:15
I don't want to go off on a tangent but this is an optimized version of Phaelax's code (just the for loops)



darkvee
20
Years of Service
User Offline
Joined: 18th Nov 2005
Location:
Posted: 17th Oct 2012 15:27
Hi Phaelax,

Thanks helping me out.
Hi The Weeping Corpse, so that is faster as in looping. I wasn't worried about speed right now but thanks for the tip.

darkvee
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 20th Oct 2012 19:42
I think someone should ask, Why are you using a Color Key to achieve transparency instead of using Alpha level opacity?

Why not simply save an image as being partially transparent in the first place?


I think answering this question might allow people to give you a fundamentally better approach if it exists.

Login to post a reply

Server time is: 2026-07-11 03:55:11
Your offset time is: 2026-07-11 03:55:11