View Full Version : Gradient Transform goose443 10-21-2005, 03:47 PM Alright, here's a questions that has been bugging me for a while.
Suppose you want to stretch or squish an image. You could simply used the free transform tool and size the image however you would like.
Now suppose you want to stretch the same image but you want to do it in such a way that the left side of the image is anchored and the right side is moveable and the stretch occurs in a "gradient" from right to left such that the right side has the most stretch and decreases stretch as you travel from right to left so that the left side has no stretch at all.
I have made a very simple jpg to illustrate the point. The upper lines represent the original picture and the lower lines represent the stretched picture (of course the lines would also increase in thickness from left to right). Now in this instance I could have selected each line and transformed it but what I'm looking for is the ability to do this smoothly across the whole image.
This would have many very useful applications including simulating an image wrapping around a cylinder.
Maybe there's an easy answer but I haven't been able to find it. Kraellin 10-21-2005, 11:07 PM i can think of two possibilities here. one, use the liquify tool (if you're using Photoshop) or the warp mesh (if you're using Paint Shop Pro). and two, make a custom displacement map and use the displacement map tool (Photoshop and Paint Shop Pro).
Craig edgework 10-22-2005, 06:10 AM i can think of two possibilities here. one, use the liquify tool (if you're using Photoshop) or the warp mesh (if you're using Paint Shop Pro). and two, make a custom displacement map and use the displacement map tool (Photoshop and Paint Shop Pro).
Craig
As you noted, Goose, stretching with transform is linear and the effect is spread evenly throughout the selection.
Regarding liquify: I use it a lot when I'm trying to deform text over a surface that recedes or curves away from the viewing plane, i.e. a logo on a football or basketball Use a large brush, large enough to cover the areas being deformed, a high Brush Density setting and a low Brush Pressure. The high density will minimize the natural tendency of the brush effect to be stronger in the middle, with the edges dragging along behind. Low pressure allows you to start with a small stroke at the edge and repeat, each time extending the sweep of the brush.
Another possibility: if you're actually trying for a perspective effect, and have CS2, pasting your gradient into a grid using the perspective tool would accomplish the task effortlessly. If you don't want the vanishing point, you still might be able to stretch the sides back out, depending on the type of image. goose443 10-23-2005, 07:01 PM Thanks for the tips. That's about as close as I've come myself. I was just hoping there was some more precise way of doing this type of transform. I think it would be useful for quite a few situations. Panpan 10-24-2005, 02:39 AM I tried with the displace filter. This meant a lot of tries because there is no visual feedback with this filter. I can now say that other ways like spherize, transform or liquify would be easier.
Basically I used the foreground-to-background gradient from 50% grey to black as the displacement map. I filled the rest of the map with 50% grey (for no displacement). This gives a full tube effect rather than the half tube you requested, but I figure that's even better if you want to wrap around a cylinder anyway.
I applied the map with displacement 350 horizontal and 0 vertical. That's where working blind was a pain. I had to try many values until I found 350. Note that this would change if the image size changed.
In the attachment, I show the displace map I built below. The result is on top.
The glass filter is similar to displace and gives visual feedback, but it does not seem to segregate horizontal and vertical displacements to separate channels (red and green) like displace; it seems to work only with the red channel to displace both directions at once.
So in the end, I would recommend something else if you want a non-linear transform.
Pierre Panpan 10-24-2005, 05:01 AM To get a half-tube effect with a displacement map, using a foreground-to-background gradient of 50% grey to 25% grey doesn't work. It only gets you a full-tube effect half the size of the 50% to 0% gradient.
What you have to do is stretch the 50% to 0% gradient to twice the size of the selection. I've attached an example.
I had to fiddle with the horizontal displacement number again. I thought that since 350 worked for the full tube, 700 would work for the half-tube. The number I had to use was 585 :confused: .
Pierre goose443 10-24-2005, 03:24 PM Thanks for the attempts Pierre. You got a lot farther than I did. I was wondering why there were multiple lines in your results and how that would translate to an actual photograph. In any event it's an innovative and impressive solution.
It's disappointing that Photoshop wouldn't come with a more straightforward filter for this sort of application. It seems like the type of situation people would fall into pretty frequently. Stroker 10-24-2005, 07:42 PM Math 2 (http://tech-slop.serveit.org/math2/index.shtml)
Curve It Squish (http://tech-slop.serveit.org/curveit/index2.shtml)
Cannify with Displace (http://tech-slop.serveit.org/cannify/index2.shtml) goose443 10-25-2005, 11:48 AM Stroker, looks like it's all in the displacement maps! Thanks for the links. I'll have to check them out at length when I have more time. Cameraken 10-26-2005, 08:19 PM Hi Goose.
Stroker writes some great stuff but he really Jumps in at the deep end. I tried reading his links but it just went way over my head.
This link is far more novice friendly and gives enough information to get this job done.
http://www.thegoldenmean.com/technique/displace1.html
I really want to learn about this filter as it is going to be useful with my next little project (Brush Strokes)
Here is a little summary of what I think I have learned so far. From Goldenmean, Worth and Stroker. I hope someone will correct me if I’m wrong.
A D-Map is a PSD file which will manipulate the pixels in another file.
Black moves pixels to the right and/or down. White moved pixels left and/or up
Mid gray in the D-Map produces no movement.
Channel one (Red) produces horizontal movement
Channel Two (Green) produces Vertical movement
The blue channel has no effect.
Goose wants to make a gradient going from no shift at the left to maximum shift at the right. Therefore you will need to construct a D-Map going from mid grey to black
You will only need channel one (Red) as you do not need to change the height.
I tried using your example but it was confusing because there is no reference. So I used a ruler (Courtesy of Stock Exchange)
If you want to play along please download 296245_8226.jpg (Attached)
Step 1.
Open 296245_8226.jpg. Click the channels. Fill the Blue and Green channels with 50% grey as they are not needed.
Fill the red channel with the gradient. Grey at the left and black at the right.
This should give you an image like in my attachment. (converted to jpg)
Save this as 296245_8226DM.PSD. (must be a PSD)
We now have our D-Map.
What we need to do now is enlarge our canvas to make room for the enlarged image so that it won’t get clipped.
Step2.
Open 296245_8226.jpg
Copy it to a new layer. Now go back to the bottom (background layer) and enlarge the canvas size.
Set the background colour to mid grey
Image > Canvas Size
Make the new canvas size 11 Inches Wide which will give plenty of room.
Anchor the picture at the left as we are expanding to the right.
You should have something similar to my attachment.
We are now ready to apply the D-Map.
Step 3
Select (click) the top layer
Filter > Distort > Displace.
This brings up a box and the settings are important.
Horizontal Scale (this will control the effect we want) Set it to 300
Vertical Scale. Set to 0
Stretch to Fit Checked
Repeat Edge Pixels Checked
Click OK and navigate to 296245_8226DM.PSD
And there you Go!
You should now have something similar to my last attachment
A Gradually stretched Image.
I hope this helps. I have certainly learnt a lot from this.
Any questions. Just ask and I’ll learn some more
Stroker where is that rock? This is really simple stuff to you but to a novice (me) it’s heavy going to start with.
Ken Cameraken 10-26-2005, 08:23 PM Last Picture
Ken Stroker 10-27-2005, 03:27 AM The rock is hiding under the bed.
If you want to get serious about understanding Displace, start at the very beginning of Technical Slop and go through it slowly. Displace takes several things into consideration and can be a mess to untangle and understand at first. When I had my first epiphany, it took me 2 days to understand it. Then it took me 2 years to write about it.
Start at the beginning and take it slow.
One of the best ways is to read Power Distort. One chunk at a time and do the exercise. Do not move on to the next chunk and exercise until you understand.
Two quick notes:
1. A D-Map does indeed have to be a PSD and the composite thumbnail preview option has to be turned on when saved. The composite preview is what Displace reads.
2. The Interpolation setting in Options will have an affect. The chosen interpolation method is what is used to sample the D-Map when Stretch to Fit is turned on.
If I get in the mood, I might come out of retirement for a bit and post some stuff specific to this thread. Cameraken 10-27-2005, 01:55 PM Thanks Stroker
Yes that’s what I thought. Power Distort1 Here I come.
I’ve got some great ideas for brush strokes that will need this lot.
I don’t know if it’s possible yet. So I need to know what can be done.
After that I’ve booked 10 Days on Byros Beach with Biker Chic (That’s 1.43 Weeks Byro)
Ken goose443 10-27-2005, 04:08 PM Thanks Ken,
This makes things a whole lot clearer. I noticed in the final pics though that there is quite a bit of distortion (other than the desired one). Is there a way to reduce this? Cameraken 10-27-2005, 06:29 PM Goose.
I'm Glad this made things a bit clearer. (It certainly did for me)
Yes you are right. I did not expect to have to distort by 300% to get this. And there are some diagonal lines in my results which should not be there.
I am going to spend some time here
http://tech-slop.serveit.org/powerdistort/index.shtml
If I find some answers then I’ll be back.
In the meantime there is an easier answer to your initial question if you just need to get the job done.
1) Open Transform.jpg
2) Filter > Distort > Spherize - Amount 100% - Mode > Horizontal Only > OK
You will need to fiddle with the position of the bit you need to transform
That’s it.
This will give you what you wanted.
Hope this Helps.
Ken goose443 10-27-2005, 06:31 PM Ha!
I had never though to pull down the menu in the spherize filter. I hadn't seen you could isolate the horizontal and vertical! That's perfect! Thank you Ken. |