L.Adair |
When in doubt, quote the Bard...
I'm working on a filter that is supposed to handle the image one way if it has transparency, and another way if does not. The filter result will always have a transparent background. However, I have been unable to figure out how to test for a transparent background. "Get Alpha" does find the transparency if there is one, providing a black and white result, but returns a pure white (alpha for the full image) if the image doesn't have a transparent background. Is there anyway to do what I'm trying to do with components? Or will a user input for Use Transparency be required? |
|||
Posted: September 6, 2016 6:19 pm | ||||
CFandM
![]() |
Without seeing some images of what the results are supposed to be there are many things that I could think of but may or may not help....One is are you using the "Set Alpha" as well?.....You can get the alpha but without using the "Set Alpha" it will just be white at the end result....
Here is one of the threads with that info....Get/Set Alpha Then also it depends on how you have set up the filter for the user to load images...Via a control, thru the file menu or is it designed as a plug-in to use in another app...... It also depends on the filters tree and how you want the filter to branch and handle the different aspects of the images..... Not quite a simple "do this" without seeing what the "do this" is... ![]() ![]() Stupid things happen to computers for stupid reasons at stupid times! |
|||
Posted: September 7, 2016 12:07 pm | ||||
L.Adair |
I went ahead and added a checkbox control for the user to tell the filter if the image has a transparent background. But I haven't submitted the filter, so I can change it...
There is a switch controlling the inputs. One is a color input with Allow Images sel ected. The other is the external Image input. (A third input is a demo mode pattern.) I understand how to use both Get Alpha and Set Alpha. What I want to do is have the filter determine if the input image has an alpha layer, (other than for the bounds of the image,) that is different fr om the result of running the image through a Threshold component. To demonstrate: Use one of the built-in preview images and enable the transparency. Run the image through both the Get Alpha and Threshold components in parallel, the black and white result for each each component will be different. ![]() Now run the same preview image through those components after disabling the transparency. The result of the Threshold component will be the same, but the Get Alpha component result has changed. It's now all white. ![]() Is it possible to choose whether to use the result of Get Alpha or Threshold based on the result of Get Alpha? I've come to the conclusion it isn't. But I'd love to be proven wrong. |
|||
Posted: September 7, 2016 7:22 pm | ||||
Rachel Duim
![]() |
Yes there is, but it may not be what you expect. Since operations on this are by the pixel, any result of Get Alpha is a pixel based result. Try adding a Multiply, taking the Get Alpha & Threshold as the inputs. What in effect this does, it turns the Get Alpha into a mask, which only allows the "center" of the Threshold to show when using the transparent lifesaver. For what its worth...
Math meets art meets psychedelia. |
|||
Posted: September 7, 2016 7:48 pm | ||||
ThreeDee
![]() |
If you scale the Get alpha result to, say 5 % around the center of the image and blur it by 5 units and then pick the center point with Lookup, if the result is anything but pure white, there is information on the alpha channel.
You can then use the IF or even the Threshold component to choose from two different inputs depending on whether it is pure white or not. If that is what you mean. |
|||
Posted: September 8, 2016 4:23 am | ||||
CFandM
![]() |
Must have read my mind.. ![]() ![]() Just turn off/on the transparency to see this work... If and Or else.ffxml Stupid things happen to computers for stupid reasons at stupid times! |
|||
Posted: September 8, 2016 12:19 pm | ||||
Rachel Duim
![]() |
Yes, I just coded the same thing at the same time... I had thought of the blur, but not the scale, excellent idea ThreeDee & CF&M.
Math meets art meets psychedelia. |
|||
Posted: September 8, 2016 12:38 pm | ||||
CFandM
![]() |
Lol..."great minds"....or just long time users..
![]() Noticed the one I posted leaves a little grey square in the alpha so tweak the (Lookup X) up to 1.00.... Stupid things happen to computers for stupid reasons at stupid times! |
|||
Posted: September 8, 2016 1:00 pm | ||||
Rachel Duim
![]() |
||||
Posted: September 8, 2016 7:16 pm | ||||
L.Adair |
Thank you all for your time.
ThreeDee, you understood exactly what I was trying to do. CFandM, my version 4 FF wouldn't open your file. It said I needed a later version. Based on the information from all three of you guys, I setup your solution in a new filter in FF. Perhaps the V4 Scale component is different, or more likely, I'm not completely understanding what you were recommending, but with some experimentation I was able to make the solution work. However, the blur component adds a lot of processing time to an already sluggish filter. I read that patterns are very fast, so I tried using Kaleidoscope instead, and was able to force the result to not-white when Get Alpha returns anything but pure white. And thanks to all of you, I now understand how Lookup works. My Kaleidoscope settings are: Source: Mapped with Get Alpha Mode: Hexagon Offset H: 10 Offset V: 10 Shape Size: 10 Repeat H: 100 Repeat V: 100 Thanks again for your help. |
|||
Posted: September 8, 2016 7:57 pm | ||||
CFandM
![]() |
Glad to see that you found a method that works for what you need...
![]()
I built that filter in FF5 so just for the heck of it I installed FF4 version 406 and put together that filter again..... btw this does not use a blur I used a free gradient.. If And Or Else FF4 Version.ffxml Stupid things happen to computers for stupid reasons at stupid times! |
|||
Posted: September 9, 2016 9:56 am | ||||
CFandM
![]() |
||||
Posted: September 9, 2016 12:11 pm | ||||
L.Adair |
Thank you, CFandM, for the version 4 code. I pulled it into FF and tinkered with it.
My Kaleidoscope solution doesn't always work, if the image is white with a transparent background. Your Free Gradient solution doesn't work if an input image without transparency isn't the same ratio as the the filter is working with, (new image, from the file menu.) It "sees" the "missing" sections as alpha, so it bypasses the Threshold output. I'm not sure what you mean when you say I could tweak Lookup to see b/w. However, I tried using Blend to input black into the Lookup Y input. I didn't see any difference. But while tinkering, I discovered inputting a shade of gray into Lookup Y seems to work for any image. I need to do more testing, of course. But it may be the best solution. Thanks again for all your help. |
|||
Posted: September 11, 2016 1:10 am | ||||
ThreeDee
![]() |
Here's my construction. Don't add this to the end of a filter tree, but build the output separate from this and use this piece only to check if the original input has alpha or not, and to select the appropriate output and it won't slow down the filter.
(Here the filter simply makes the image green if there is alpha and red if there isn't.) Alpha or not_.ffxml |
|||
Posted: September 11, 2016 1:07 pm | ||||
SpaceRay
![]() |
This thread is interesting and useful
|
|||
Posted: September 16, 2016 1:23 am |
Filter Forge has a thriving, vibrant, knowledgeable user community. Feel free to join us and have fun!
33,711 Registered Users
+18 new in 30 days!
153,531 Posts
+36 new in 30 days!
15,347 Topics
+72 new in year!
34 unregistered users.