fisholith |
Assuming I already have an image loaded into the "Image" component (I'll call it the "main" image), is there a way to load a second image using a "color control" component, such that the second image's scale is 1-to-1 relative to the main image?
That is, the pixels in the main image and the second image are the same size. The "color control" component has an option menu called "Placement", which has the options "Fit", "Stretch", and "Fill", but no "1:1" or "Don't scale" option. e.g. If the main image is 400 x 400, and the second image is 200 x 200 and it's at 1-to-1 scale, then the second image should be half the width and height of the main image. The "color control" component only gives me options that stretch the second image in various ways, but unfortunately I don't want to stretch it. Is it possible to load a second image at 1-to-1 scale using a script? It would certainly be nicer to use an open dialogue, but if the "color control" component doesn't give you a 1-to-1 option, and doesn't tell you what the second image's dimensions are, I'm thinking there might not be a way to automatically rescale the image with further nodes. The only thing I can think of at the moment is to open the properties of the second image in windows explore, read the dimensions, type them into value sliders in filter forge, and then use some components to do the appropriate scaling math to make the second image 1-to-1 with the main image. And that might work if I only have to do it for one image, but doing it hundreds of times seems like it could take a while ![]() |
|||
Posted: January 16, 2013 3:52 am | ||||
Sharandra
![]() |
You could use the scale component (under transforms) to scale the second image up or down.
|
|||
Posted: January 16, 2013 8:34 am | ||||
Vladimir Golovin
Administrator |
This is a good suggestion. We'll look into it. (Note to self: also implement wrapping beyond the image boundaries similar to how it's done in the Image component). |
|||
Posted: January 17, 2013 3:18 am | ||||
Betis
![]() |
wow you actually managed to convince vlad to consider your suggestion with just one post.
![]() ![]() Roses are #FF0000
Violets are #0000FF All my base are belong to you. |
|||
Posted: January 17, 2013 1:30 pm | ||||
fisholith |
Thanks Sharandra, Vladimir, and Betis for the replies.
![]() I've included an explanation of the current workaround I've settled on below, along with an example filter, and a walkthrough for building one of the scaling methods I used, (since some of the steps might not be immediately obvious fr om simply looking at the wires in the editor). Hopefully if anyone comes across this post with the same question I had, it will help them out. ![]() A workaround: For situations wh ere the second image is perfectly square, the workaround I'm using for now is to use a combination of the "Scale" component and a script to output the "SIZE" value of the main image, since I need to know what the main image's dimensions are if I want to resize the second image to be 1-to-1 with it. (I know there are likely faster ways to get the SIZE value without a script but I went with it for simplicity.) For situations wh ere the second image is not perfectly square, I used a script to output the width and height of the main image, and then used a "Lookup" component and a horizontal and vertical gradient to scale the UV space correctly for the secondary image. (I could also have used the Scale component here, but it was a bit easier for me to think about the math in terms of UV space at the time.) On the plus side, I was able to get the second image to be scaled 1-to-1 relative to the main image, and thankfully no aliasing occurs in the second image. Unfortunately, you still have to manually type the pixel dimensions of the second image into a pair of value sliders to get it to scale correctly. All in all, it's a good solution for the time being. ![]() Example filter snippet: https://dl.dropbox.com/u/38240401/Publ...0118.ffxml (Note: You may need to right-click the link to download the filter.) This filter demonstrates a method for scaling an image loaded in a "Color Control" component, to be at a 1-to-1 pixel scale relative to the primary source image's dimensions. Two different methods are presented in this demo. One method specifically for square images, and another more general method for rectangular images. You can switch between these scaling methods using the slider control labeled "Square, Rect, None". Controls: "Square, Rect, None": Select the scaling method. 1 = Square. 2 = Rectangle, 3 = Show the primary image only. "Square Image": This is the image to be used when the Square scaling method is selected. "Square SizeXY px": This is the size (in pixels) you want the square image to be scaled to. If you enter the pixel size of the image you loaded into the "Square Image" Color Control, then it will be at 1-to-1 pixel scale with the primary image. "Rectangle Image": This is the image to be used when the Rectangle scaling method is selected. "Rect SizeX px": This is the horizontal size (in pixels) you want the rectangle image to be scaled to. "Rect SizeY px": This is the vertical size (in pixels) you want the rectangle image to be scaled to. "Blend": This is the opacity of the "Square Image" or "Rectangle Image", as overlaid on the source image. (Note that all the "Built in" images in Filter Forge are 600 x 600 pixel squares. To better test out this demo, you may want to try loading some images of your own into the "Square Image" and "Rectangle Image" controls. You'll want to take note of the pixel dimensions of any custom images you load in so that you'll know what to type into the size controls.) Walkthrough: Here's a brief overview of the setup I used for square images. It can undoubtedly be optimized, but it works decently for the time being. 1. Create a "Color Control" component and load an image into it. In the "Image placement" dialogue, set "Horizontal Anchor" to "Left" "Vertical Anchor" to "Right" "Placement" to "Fit" 2. Create a "Map Script" component and make it output the global "SIZE" value on the R, G, and B channels. e.g. return SIZE , SIZE , SIZE , 1 ; 3. Create a "Value Control" component and set the value to the pixel size of the second image you loaded into the "Color Control" component earlier. (e.g. If the second image is 1024 x 1024, then enter the value "1024".) 4. Create a "Divide" component. Link the "Value Control" component to "Dividend". Link the "Script" component to "Divisor". 5. Create a "Scale" component. Link the "Color Control" component to "Source" Link the "Divide" component to "Scale" 6. That should be it. ![]() |
|||
Posted: January 18, 2013 7:07 am | ||||
SpaceRay
![]() |
Good idea and interesting
This was in 2013 and it did not appear in FF 5, so could it be for FF 6? |
|||
Posted: May 10, 2016 1:12 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!
17 unregistered users.