Sei sulla pagina 1di 31

Aligning and adjusting images using

photoshop: Core scan example

1 About this approach


In this approach we use photoshop to align images and make image brightness, contrast and other
adjustments. These instructions are written for photoshop CS6, but they should be applicable to
other recent versions of Photoshop.

This approach has these advantages over aligning images in adobe illustrator or other vector
package:

1. Opportunity to automatically align images

2. Ability to make image brightness, contrast and other adjustments live (and reversibly)

3. Ability to make granular image adjustments (i.e. at the edges of aligned images to make them
match better).

1.1 A note on Scans vs. photos


The input for this is a core scan, which means there shouldn’t be any lens distortion which would be
present in a photo. If you were taking photos, a good approach would be to use Structure from
Motion (SfM, sometimes called photogrammetry) to generate an ortho image from multiple photos
from above. A good package for this is agisoft photoscan.

2 Preparing the images


It’s a good idea to work out, up front, what target pixel count (resolution) you need for your final
product. Aim for 300ppi in print and no more than 20,000 pixels in any direction. For example if you
are aligning 4 images and you want an image that will display A4 portrait it should be ~3500 pixels
high and each image should be about 1000 pixels high (depending on overlap). See also:
o Pixel count, pixel density, document size, dots per inch, optical resolution

If your original images are large or there are many originals you may want to resample before you
put them into Photoshop to align.

2.1 Reducing the pixel count by resampling.


The fastest way to do resampling on a bunch of images is to set up a script in photoshop. There are
detailed instructions on the web covering photoshop scripting. The basic approach is:

1. Open actions panel


2. Create and start recording a custom action

3. Adjust the image size using % (so that each image is reduced by the same amount) to match
your output.

4. Stop recording.

5. Go to File>automate>Batch

6. Select your action

7. Select the “open folder” containing your images

8. Select the output folder

9. Run the action

TIP: I recommend processing all your images through two folders you create: One called script
in and one called script out. This makes it easier to keep track of what you are doing to your
images and saves time selecting folders etc.

3 Aligning the images


Now that you have your suitably sized images it is time to align them in photoshop. It’s worth a go
trying to automatically align the images. But if this doesn’t work they can be manually aligned.

3.1 Automatic alignment.


1. Go to File>Automate>Photomerge and select the images you want to align.

2. If these images are scans you should only need to reposition them to get them in the right place.
So check the Reposition option.

3. Uncheck Blend Images Together. If we need to manually align and adjust colours this makes it
more difficult.
4. Click OK and wait for a bit

5. Your images will be loaded each into a separate layer.

6. Check the alignment by looking at the layers panel.

7. You can also use the Move tool in auto select mode to click on the image and see which layer
that part of the image is in.

8. In our case three of the four images have aligned correctly and 292-317.jpg has not aligned
properly.

3.2 Manual alignment to fix up auto alignment


In the example above we have one image to fix up the alignment.

1. You will probably need to make space for putting in the manually aligned images.

2. Go to Image>Canvas Size

3. Change the units to pixels

4. Set the anchor to top left (or wherever your correctly aligned images start from)

5. Add enough pixels to the height and/or width for your manually aligned images.
6. It’s probably a good idea to add some pixels to one side for putting your unaligned images while
you move them all about.

7. Click OK

8. Select the layer you want to move in the Layers panel

9. Make the Move tool active and turn off Auto select (so that you can select just the layer to
move)

10. Move the layer to the correct location.

11. Save the image in Photoshop document format.

TIP: If you have a few images to move you can switch the Move tool to Auto Selectmode once you
have all the images out from behind each other.
3.3 Complete manual alignment (alternative to auto alignment)
Sometimes the auto alignment is so bad that it actually makes it harder to align manually after. In
which case you can completely align the images manually.

1. Go to file>Scripts>Load files into Stack

2. Select the files to align.

3. Make sure both the boxes are unchecked.

4. Go to Image>Canvas Size

5. Change the units to pixels

6. Set the anchor to top left

7. Add enough pixels to the height and/or width for your manually aligned images.

8. Add some pixels to one side for putting your unaligned images while you move them all about.

9. Click OK

10. Use the move tool with or without Auto-Select checked to get your images aligned. Use the
extra space to put un-aligned images while you work on the rest.
11. Crop the extra space away at the end (don’t crop any of the image – you can always crop it for
export, or if you must use a non-destructive crop).

12. Save in photoshop format

3.4 Photomerge UI plugin


You can get an interactive photomerge plugin for CS5 32 bit version that can help with aligning
images.

4 Adjusting the images


The best way to make adjustments (e.g. brightness, contrast, levels) is using an adjustment layer.

4.1 Adjusting the entire stitched image


In the example I am working on we want to make the whole image lighter.

1. Click on the topmost layer (so that the adjustment layer is created above this).

2. Click on Create fill or Adjustment layer in the bottom of the layer panel

3. Choose Levels (for example)


4. With the levels adjustment layer selected you should see a Histogram in theproperties box
above.

5. Adjust the settings on levels (e.g. the sliders) to set the output to what you want. This is
completely reversible and adjustable.

4.2 Adjusting specific areas using masks


In this example we see a reasonably sharp brightness change between two of the images.

We can correct for this by targeting an adjustment to the image above using and masked adjustment
layer. The mask we want will focus the change on the top image with a gradual reduction in change
above so that we don’t just create a new sharp change. To achieve this we make a mask with a
gradient over the area of interest.

Have a look online for more in depth discussion of how masking works.

1. Create a new Levels adjustment layer underneath the one you just made.

2. Double click and rename the layer e.g. to match the individual image you are working on

3. Click on the Channels tab (next to layers)


4. Make the Adjustment Mask visible. this makes the mask editable and visible by default as a
translucent redT

5. Select the Paint Bucket Tool It should be in the following mode:

6. Make sure Black is the foreground colour:

7. Click the Paint Bucket tool anywhere on the Canvas. It should go red (it’s actually black but the
mask previews as translucent red).

8. Make a rectangular selection over the area you want to adjust.

9. Make the Gradient tool active. Hidden under paint bucket


10. With linear gradient selected drage from one side of the selection to the other to draw a gradient
mask.

11. Click on the adjustment layer (this hides the mask).

12. Select>Deselect

13. Zoom in on the area and adjust the levels until you match between the images.

DONE!

TIP: Turn visibility on/off the adjustment layers to see what you have done
Aligning multiple images in photoshop
We want images stacked
Sometimes we capture images of the same area (e.g. a particular part of a thin section) using
different conditions (reflected light, PPL, XPL, Cathodoluminescence) . We may then want to stack
the images together so that we can see how each different mineral, for instance, appears under the
different conditions.

THE PROBLEM
We can align objects manually because we see recognisable features in each image. It can be a
little tedious and difficult trying to add, manually align, resize and rotate the images in software like:
Adobe Illustrator, photoshop, the gimp, image j or other software.

There is a semi-automated way to speed up this process in photoshop. I’m not sure of the exact
conditions under which this will actually work. But it’s fairly easy to try and could save you a load of
time.

How to do it
The first thing we need to do is to load all the images as layers in a photoshop document.
o Open photoshop
o Go to file>Scripts>Load files into Stack

o Navigate to the folder with your images in it and load these.

You should now see all your images as layers in photoshop with names corresponding to file names
(handy eh?).
o Select all the layers by clicking on the top layer and then shift clicking on the bottom layer. They
should all have a blue background in the layers panel indicating they are all selected.
o Now go to edit>auto-align layers
o I recommend trying collage first which will not distort the image.

You will notice there is also a checkbox to try to auto-align layers when you load them into the stack.
You are welcome to have a go with this too.
Macro-photography setup is now ready
The macro-photography setup comprises: a copy stand, a DSLR camera with a macro-lens and a
computer for controlling the camera and capture.

DEMONSTRATION
I will be giving a demonstration of the setup tomorrow (Wed 8/2/2012) at 10:40 am in the graphics
lab. If you wish to use the setup but cannot make this time then you will need to contact me to get
the training at a later date.

What is it for?
Taking photos of samples, specimens etc. close up. The setup has a maximum field of slightly
smaller than an A4 sheet of paper. The smallest field of view is the size of the sensor: 22.2*14.7mm.
Because you can capture 4272 x 2848 (L) pixels on this 22.2*14.7mm sensor your pixel density is
4888 ppi. This is much more than the 300ppi needed for print, so digital zooming and cropping will
get you a lot closer with good results (see sample images in poster below).

Guidelines for use of the macro-photography setup. This poster is beside the equipment.
How to compress powerpoint
presentations

These instructions are applicable to Powerpoint 2011 on MacOS and Powerpoint 2013 on
PC (and probably versions on either side of these).

The size of your Powerpoint presentation is mostly going to be based to the number of images you
have in your presentation, image size (especially if you are using MacOS), and your default
compression settings (only applicable if you are using a windows PC).

1.1 How to compress images in your powerpoint


presentation (PC 2013)
When you are finished preparing your presentation I recommend first saving your working copy.
Then save an export version that is compressed. This is so that you still have a version with high
quality images to work on if need be.

1. To compress your presentation go to File>Save As and choose Tools>Compress


Pictures (next to Save)
2. Then choose the compression level. Try 150ppi and then save. If it still isn’t small enough
try 96ppi.

Note: If any of the options are greyed out it usually means you have already had that compression
level applied by default (see note on checking default options below).

Note: “Delete cropped areas of pictures” will lock in any crops you have made.

If you’re interested in having a bit more control over image resolution check out the instructions
below covering how to check/change the default compression in your power point presentation.

1.2 How to compress images in your powerpoint


presentation (MacOS 2011)
By default on MacOS there is no compression applied and your document size will be greater than
the size of all the images you add to it.

TIP: When you are finished preparing your presentation I recommend first saving your working copy.
Then save an export version that is compressed. This is so that you still have a version with high
quality images to work on if need be.
1. To compress your presentation go to File>Reduce File Size

2. Then choose the compression level. Try 150ppi and then save. If it still isn’t small enough
try 96ppi.

Note: “Delete cropped areas of pictures” will lock in any crops you have made.

1.3 How to check/change the default compression in your


power point presentation (PC 2013)
In recent versions of ms office most systems are set to compress by default as soon as you fits save
a document. So it makes sense to check out what your default options are in PowerPoint. You can
find out what your defaults are by:

1. Go to File>options.

2. Click on Advanced on the left hand side


3. Look at Image Size and Quality for details

4. From here you can change the amount of downsampling (compression) applied.

5. Most systems seem to have 220ppi set as the default. I would leave this set at 220ppi (or even
check “Do not compress images in this file”) so that images aren’t compressed very much for
your working copy.

NOTE: 220ppi applies to the smallest size the image has been when the document is saved and
closed. So if you decide to enlarge an image you have previously shrunk (with a save and close in
between) it will have 220ppi resolution at the smaller size.

1.4 How to check/change the default compression in your


powerpoint presentation (MacOS 2011)
There is no way to set default compression on powerpoint on MacOS (as far as I can tell), you need
to do it manually via File>Reduce file size.

1.5 Problem solving powerpoint compression (for .docx


format: PC and MacOS)
If you have any problems with PowerPoint presentations not compressing properly it might be
because of one or more bad images. There is a little trick you can do to check the size of individual
media files in your presentation. This works because .pptx format is actually a zipped folder format
(as are all office formats that end with x).

1. Make a copy of your presentation.

2. Change the extension from pptx to docx

3. Extract the .zip folder


4. Go to Word>Media to see the media files.

If you find one image that is problematic you can swap it out by right clicking and choose change
picture in powerpoint.
Handling images using MS word PC (2013)

These are detailed instructions for different approaches to handling images in MS word 2013 and
producing PDF export at the end. These instructions also apply generally to versions from 2010
onwards…

Introduction
It is typical to have images embedded in MS word documents (linking images is possible, but
problematic). This document describes how MS word handles images and which methods/settings
should be used to get the best results.

Image file formats


The best thing you can do for your images is make sure you are exporting your images at a
reasonable pixel count (resolution >= 300ppi and image size matches size on page). See Preparing
illustrations for use in theses, reports and publications. Another thing to make sure is that you are
using the correct image file formats. If you aren’t familiar with file formats and options for saving the
safest formats to use are TIFF for photos and PNG for graphics. JPEG uses lossy compression and
if you are not careful about applying settings the quality of the jpeg images in a final document can
be poor.

Importing images into MS word


Recommended approach is to do “INSERT>Pictures” This approach will pull the images in and keep
them in their original file format.

An alternative approach is to drag and drop. But this approach will sometimes produce locked
images (see note below).

Drag and drop issues: locked images that won’t downsample!


In some versions of MS word if you drag and drop an image in it will default to some weird
paragraph formatting. This prevents certain editing and effects being applied in MS word (see
comparison figures below):
It also prevents the image from being down sampled when you save the document.The workaround
is to cut and paste the image in place (Ctrl+x, Ctrl +V). If you put images in from Insert>picture this
will not be an issue.

Handling images in MS word 2013 PC


There are a couple of options for handling images in MS word.
Handling images OPTION 1 – Setting up your MS word document to
220ppi downsampling (recommended for ease of use)
220ppi is a good resolution that you’ve probably been using by default for a while. It’s difficult to tell
the difference between 220ppi and some higher resolution on an average to higher end printer.

MS word has settings for how much images are downsampled (reducing resolution). This is a setting
that is stored for each document but can also be set as a default for all new documents. Usually this
is 220ppi resolution by default. But to make sure we can set it explicitly.

1. Go to File>Options>Advanced

2. Scroll down to Image Size and Quality

3. Using the drop down set this option for all new documents

4. Set default target output to 220ppi

Images will be downsampled as soon as you save the document. In some cases PNG and TIFF will
not be downsampled (I have no idea why this happens).

TIFFs and PNGs will not be compressed, so you could use these formats if you want no JPEG
compression applied. If the images are JPEGs they will be compressed to level 8 (high quality). This
is usually not noticeable for photos but will have a minor effect on graphics type images with high
contrast areas (as a consequence of JPEG compression). But in these cases you should be using
PNG instead of JPEG because PNG is for graphics and JPEG is for photos.

If you want to change downsampling settings for individual documents choose the document you are
working on from the drop down list instead.

Handling images OPTION 2 – Setting no downsampling (Advanced


method for maximising quality)
If you want to get no downsampling in MS-word:

1. Go to File>Options>Advanced

2. Scroll down to Image Size and Quality

3. Choose the current document from the drop list


4. Check the “Do not compress images in file” box

This will also not apply any compression to JPEGs.

PDF save or export


In general it is best to print or publish documents as a PDF rather than an MS word document. The
main reason is that PDFs will generally look the same regardless of which OS (mac, windows, linux)
or software package opens them. This is not necessarily the case for MS word (though this is
generally much improved in recent versions of MS word). Another reason is that the output to PDF
generally reflects what the output in print will be. So if there are some issues in the document you
can catch them at this stage.

PDF export OPTION 1 – Print to PDF using Adobe PDF printer


(Preferred method)
Use the Adobe PDF printer which is installed as part of the Adobe creative suite to make high
Quality PDFs. Instructions for other PDF printers follow.

1. Choose File>Print and then pick Adobe PDF from the printer list

2. Go to Printer properties. I recommend setting Default settings to High Quality Print (300ppi for
images above 450ppi). This will set images that are larger than 450ppi to 300ppi and set
compression level to 9 (slightly less than max quality). It will not change images or their file types
if they are less than 450ppi.
3. Be Sure to also set PDF page size to A4

4. You can edit/check the “High Quality Print” settings by clicking on Edit.

Note: Even though it says PDF page size is A4 it will still deal with A3 pages

PDF export OPTION 2 – Print to PDF using cutepdf writer (some


issues with certain TIFF and PNG files)
1. Go to print

2. Choose CutePDF writer from the printer list


3. Go to printer Properties, click Advanced and change the print Quality to 1200ppi, this will fix
some issues with PNG files.

This will produce pretty good results. But I did notice some spurious colours for PNG and TIFF files
when CUTEPDF resampled the image. Setting the PDF output to 1200ppi (as noted above) should
fix the problem for PNG files.

PDF export OPTION 3 – Save as pdf from ms word (lower quality


PDFs)
This method creates PDFs with low quality images, but it is quick and ok for general purposes

1. Go to file>save as and choose a location to save.

2. Choose PDF from the Save As type.

3. Choose optimize for “Standard (publishing online and printing)”

Compression and downsampling


If you just choose save from here it will save a PDF with images downsampled to 200ppi and highly
compressed (JPEG-0)!

There are options for how much downsampling is applied at export (but no way to change the JPEG
compression). To set these: go to Tools>Compress pictures

What are the options?


o If you choose “Use document resolution” whatever setting you choose in image size and quality
in word will be used.
o If you choose not to compress images in MS word and pick “use document resolution” you will
get 200ppi images.
o If you pick from one of the options available you will get that resolution.

So basically the best you can get using this method is 220ppi images at high JPEG compression (0=
bad quality).

Left: Uncompressed PNG | Right: Low quality (highest compression) JPEG created when saving to
PDF in ms word
Note: if you use PNG for images then PNG lossless compression will be retained (i.e no lossy JPEG
compression).
Preparing illustrations for use in theses,
reports and publications

Considerations
What software are you making your thesis in? The two main ones are ms word and latex. Please
note that due to the variation in versions of ms-word on pc and mac, it is difficult to write consistent
instructions for it.

Create a figure template


Figure Width: make your figures so that they are always the width of the page minus the margins
(see figure below). For publications you will have a template for one or two columns.

Figure Length:Make your figure length to suit the figure up to a maximum that leaves room for the
caption to appear on the same page (see figure below).

Figure template guide.

Why not just scale each figure as necessary to fit in the word doc or
LaTeX?
There are various reasons why using a template is the best approach:
o Image sizes won’t get bloated. You can set resolution of output (e.g. 300ppi) and know that the
image will be 300ppi.
o Font size, stroke width etc. will be consistent
o Easier to make figures.

File formats
MS-word
For ms-word use EMF format to get vector graphics. Or use PNG/JPEG depending on whether the
format is graphics like or photo like (refer to the poster in the graphics lab for this).

LaTeX
Best to just use PDF format. Occasionally there are issues with transparency, gradients and nested
hidden objects.

Journals
Journals are sometimes restrictive in what format they accept. They usually focus on people
submitting a particular file format at a particular resolution rather than assessing the quality (e.g.
optical resolution of rasters) or file size issues. Ideally you would just submit PDF for vector figures.
Sometimes they won’t accept PDF but will accept EPS which is a similar format. For rasters they
tend to prefer .tiff at 600ppi or 1200ppi, even though PNG is much better at lossless compression of
some rasters.

Techniques using Adobe illustrator


Make sure you check the use artboards thing on export. Refer to this post on pdf linking embedding
and saving in illustrator

You might also find the post on optimising pdfs in acrobat pro useful.
Optimising PDFs in acrobat pro (including
downsampling and compressing rasters)
Sometimes we are required to reduce the file size of a pdf so that it can be uploaded, emailed etc.
When we are printing something we always want to use an uncompressed version though.

Some concepts
There are a couple of key concepts that are useful to understand when reducing the file size of a
pdf. Usually vector text graphics etc. take up a small proportion of the pdf file size and the thing that
makes pdfs large are embedded rasters (aka bitmaps, images) such as photos. To make these
rasters smaller we can do two things to them.

1 Downsampling
This is the process of reducing the number of pixels in an image. Typically downsampling will be
achieved by choosing a lower pixel density (PPI) such as 150ppi rather than 300ppi. This will result
in a squared reduction in file size. For example if you downsample from 300 to 100ppi the new file
will be ¼ the size of the original. You might choose to downsample an image if you don’t expect
someone to view it at a high pixel density (i.e. for images that will only be viewed on screen).

2 Raster compression
This is the process of storing the information about an image more efficiently. Compression falls into
two categories: lossy and lossless and there are a variety of file types that utilize different
compression algorithms. Jpeg compression is lossy and stores information about how the colours
change from one corner of an 8×8 pixel square to the other corner (if you look closely at highly
compressed JPEGs you can see this effect . Sometimes compression is used generally to refer to
any kind of activity that will reduce the file size, I will use raster compression to explicitly refer to the
compression to a raster image not including downsampling.

More concepts
For a bit of background check out the blog post I did about pixel count resolution etc.

The quick and dirty method: saving as reduced size pdf


from acrobat pro
This is a bit of a mystery approach. I’ve looked into it and I cannot figure out what this actually does
to the rasters. Sometimes this works ok. This is the quick and dirty approach.
Save as options from Acrobat pro

The better approach: save as optimising pdf


Saving as optimised pdf gives you a lot more options including the ability to see what is taking up
space in your pdf (Click on Save as> Optimized PDF>Audit space usage).

Pdf optimiser options. Each of the boxes on the left hand side are submenus.

Clicking on audit space usage will bring up a box listing the size and percentage for each element in
your pdf. In the example below there are three main contributors to the large file size:

1. Images

2. X-object Forms: the vector graphics in the document

3. Piece information: In the case of this document this turns out to be information created by the
program that made the pdf (LaTeX) and we don’t actually need it.
Audit space usage dialog box

We can do stuff to make 1 and 3 Smaller but there’s not much we can do about 2 (in some rare
cases rasterising the really complex vector graphics may help).

Other optimising things


Before we start downsampling and compressing the images it’s useful to look at what can be done to
the rest of the pdf. I found this useful information out from http://chris-
hummersone.blogspot.co.nz/2011/01/how-to-reduce-size-of-your-document.html . Chris’s post deals
specifically with pdfs created from LaTex but the principles should be transferable to any pdf.

Below are the settings he recommends for each tab (for more detail read his post).

Recommended options for PDF optimising

I recommend saving these settings so you can use them again. In the example above where piece
information contributed ~50MB the file size was reduce by approximately 50MB.

Image downsampling and raster compression


The amount of downsampling and raster compression that you choose to use is going to depend on
the purpose for the document. The lower limit I would go to is bicubic downsampling to 100ppi for all
image types and JPEG at high quality. This should produce a much smaller pdf for viewing on a
computer (e.g. 20MB vs. 150MB). You may want to save various configurations for downsampling
and compressing that are fit for different purposes.

Do not do any compression to the version you want to print. Print is much higher resolution than on
screen and any compression is much more noticeable.

Some notes on saving PDFs with illustrator compatibility


and/or embedded images.
I’m not entirely sure if optimising a pdf will get rid of extra images that are stored when pdfs are
saved from illustrator with ai compatibility checked and embedded images. See my previous post
for information about best saving practices from AI.

Potrebbero piacerti anche