# Sticky  Correcting sloping tank sides



## niko

When shooting a rectangular object there is a common distortion problem that is often seen in pictures of aquariums. The sides, the top and bottom lines of the tank appear tilted or bowing. That problem is a result of zooming the camera lens to a length that renders the straight lines as crooked. The simplest fix would be to zoom the lens to a "normal" length (50 mm for 35 mm. film photography) and retake the picture. But that is not always possible due to the space available in the room or other reasons.

If you want to straighten the lines using Photoshop you can use the "Distort" function. The process is very straightforward and takes very little time. I'm going to use Luis Navarro's 75 gal. tank so I can pretend that I'm improving the work of the master. This is the original picture which we will manipulate:









First we will select the area that we are going to work with. For this use the Rectangular Marquee Tool to draw a rectangle around the tank:









Then select the "Distort" function from the menu. This fucntion allows you to alter the image to your liking - even "flipping it over" if you wish:









Upon selecting the "Distort" function 8 small squares will appear on the selection frame. 4 are in the corners and 4 are in the middle of each side. You can use them to "get hold" of the image and distort it - that's why they are called "handles":









Drag the top left handle to the right and you will see how the tank side starts to slope. Don't overdo that because the tank may break. That's a lame joke but the idea is clear - dragging the handle allows you to change the shape of the tank:









You can do the same in the opposite direction - dragging to the left:









After you learn how to use the Distort function and play with it for a while you may find it hard to align the sides of the tank to perfectly vertical. There are no guides to show you what is perfectly vertical (or horizontal for that matter). Instead of trying to draw lines on your screen with a marker make use of the "Rulers" that are available in Photoshop. They are basically vertical and horizontal lines that help you with the alignment. To display them use the View | Rulers menu. (To hide them go back to the same menu and uncheck the check mark to the left of the word "Rulers"):









Two white rulers appear as shown below:









The white rulers can be used for measuring the image, but in our case we are interested in having some vertical and horizontal guidelines. The Rulers have Temporary and Permanent guidelines. 
To display the Temporary lines drag the rectangle shown in the picture below to the right or to the bottom. The guidelines appear, but they evaporate as soon as you release the mouse button. Temporary lines... good for quick reference:









To display the Permanent guidelines drag the side or the top Ruler. This time the guidelines will stay superimposed over your image after you release the mouse button:









To move the guidelines select the Move tool and place the mouse cursor over the line. The cursor will change to a double line showing you that it has "sensed" the line and you are all set to move it.









Move the vertical guideline closer to the side of the tank. That way when you start to Distort the side you can use the guideline as a closely positioned reference line:









In the picture below I've added an additional vertical guideline on the right (yes you can draw as many guidelines as you wish). Use the handles to distort the sides and align them with the two vertical guidelines.:









To accept the new changes you need to "Apply" them. Hit the "Enter" key to do that. If you go ahead and try to select another tool before applying the changes Photoshop will ask you to apply or to cancel the new distortion.

The horizontal guideline shows that there is another small problem with the lines. The top of the tank is not perfectly horizontal. Use the top right handle to pull the right side a little bit up:









Adjusting the horizontal line leaves us with a nice leveled tank top but with some extra black background sticking out:









To fix that I've resorted to a cheap trick that you may or may not want to learn. I use the Rectangular Marquee Tool to select the area that should be white. This tool selects in a perfect vertical and horizontal way so the straight line is guaranteed. After the selection I use the "Brightness/Contrast..." dialog (found under Image | Adjustments) to dodge the selected area to innocent white. You can see the settings for Brightness and Contrast on this picture:









This is the finished adjusted picture of the tank:









And here's a comparison of the original and the adjusted tank:









As you see the whole process is very easy. I hope that we will see fewer unadjusted tanks in the future planted tank contests.

If someone has an idea how to fix bowing lines please chime in.

--Nikolay


----------



## jerseyjay

Niko, 

Great tutorial. 

If you allow me to be picky entire bottom and top still has "bow effect". You fixed the sides but middle top / bottom has less black framing than corners.


----------



## hir0

Niko, nice tutorial... however - there is a much simpler way to do this.
Use your crop tool, and click the box that says perspective. then you can move the corners to the four corners of the tank (or wherever you want them) and crop.


----------



## niko

Jay,

I mentioned in the end that I don't know how to correct bowing lines and if someone knows to let us all know.

Actually I know one way but I'm not sure I like it too much - using the Filter | Distort | Pinch function. 

Hiro,

I didn't know that the Crop tool did that. It is certainly faster. The only problem I see is that I have to enlarge the image so I get fine control over the movement of the Crop lines. The problem maybe my computer - the lines seem to "jump" abruptly from one position to another, in small increments, as if they are sticky. I cannot find a setting that disables that behaviour. If I enlarge the image I can move the line smoothly and then what you suggested works beautifully.

--Nikolay


----------



## dennis

Great tutorial Niko!

Anyone know how to do this using Gimp?


----------



## JoeHoetzl

In Gimp - the Perspective tool (Shift-P) will do similar...

Have a download/read here:
http://www.math.ubc.ca/~cass/graphics/manual/pdf/ch10.pdf


----------



## Bert H

Thanks Niko, great tutorial!


----------



## Ben Belton

Excellent Nikolay!!


----------



## standoyo

hi Niko,

nice work putting it up...

BTW, Hiro the perspective thing in crop is great tip!

i'm so used to apple[ctrl in windows]A, apple[ctrl in windows]T then holding apple[ctrl in windows]+shift and click+dragging on 'knobs' to adjust...

i agree the pinch punch thing is a hit and miss for the common barrel distortion in wideangle settings...

try liquify in filter menu
click bloat tool.
brush size ~1/2-1/3 image diameter, brush density 10, brush pressure 1, brush rate ~80, turbulent jitter 50.

the skill part comes when you drag lightly area over out of image especially near the 'fat' area...i use a wacom pen tool so it looks pretty decent and is less cranky than mice.
if you don't like it you can click restore all and retry.

even if it's not perfect a simple crop[or black bars top and bottom] should do the trick.


----------



## dido9

You can also use Filter->Distort->Lens Correction... Remove Distortion in the dialog. It's been designed to remove such distortions in wide-angle shots.

Edit: It's a CS2-introduced tool only as far as I remember...


----------



## rashev

Lens correction plugin  :

http://www.highend3d.com/3dsmax/downloads/tools/photoshop_plugins/2429.html


----------

