Manipulation et analyse d'images...
-
Upload
hoangkhuong -
Category
Documents
-
view
223 -
download
4
Transcript of Manipulation et analyse d'images...
1
Your images
Image processing and analysis
Monique Vasseur et Gabriel Lapointe
BCM6013 Summer 2011
2
Image processing for what?
Image processing for what?
Processing for different purposes
3
What can you do with an imaging software?
Make your image nicer
Crop only one person
Zoom on details
Erase what you don’t want
Replace a spot by an other image
Make a montage of pictures
Change its format, colors…
Can you do that for scientific images?
What are you allowed to do
with scientific images?
NOT EVERYTHING IS PERMITTED!
There is rules and ethics in imaging
Certain manipulations will destroy your data
Quantification needs more caution
Be aware that some softwares will
automatically and irreversibly modify your
image (scaling, stretching, loose metadata )
4
Ethics in scientific imaging
Images are data
Always keep the originals
Work on copies
Always compare images acquired and processed
in the same way
Do not modify partially an image
Log all image modification details, reviewers can
ask for them
Imaging software, what for?
Image processing
Image - Image
Image Segmentation
Image - objects
Image Analysis
Objects/Image - Informations
5
Imaging Introduction
Why ImageJ?
Main interface
Menus
What is a digital Image?
Pixel characteristics
Intensity in greyscale, pseudocolor and color images
Intensity and dynamic range
ImageJ image types
Image formats and conversion
10
Why ImageJ ? Software in the public domain open source: IT’S FREE!
Can run on any system where you can install Java A laptop at home is enough for 95% of the cases If missing memory on your laptop, use one of ESI servers at UdeM
Supports multiple types of programming languages
Macro in "Java Simplified" (uses existing ImageJ functions)
Plugins in Java (add new features)
Javascript and Python
Frequently updated (every month)
Supported by an active community
6
ImageJ
ImageJ Menus
©2011 Gabriel Lapointe Certains droits réservés 11
©2010 Gabriel Lapointe Certains droits réservés 12
The main interface
Open, Save, New image
Assembly,
drawing tools
Modification and conversion, geometric operation
Filters &
Operations
Statistics, Measures,
graphic
Access to plugins
Window Management
Shortcuts to the
website, information and
updates
7
©2010 Gabriel Lapointe Certains droits réservés 13
Menu : Edit
Maximum memory ● Windows 32-bit:
the smallest number, 75% of total or 1.4 Gb
● Windows 64-bit: 75% of total
● Mac OSX 32-bit: the smallest number, 75% of total or 1.8 Gb
● Linux 32-bit: 3 Gb ● Linux 64-bit: Unlimited
©2011 Gabriel Lapointe Certains droits réservés 14
Menu : Image
8
©2011 Gabriel Lapointe Certains droits réservés 15
Menu: Process
©2011 Gabriel Lapointe Certains droits réservés 16
Menu : Analyze
9
©2011 Gabriel Lapointe Certains droits réservés 17
Menu : Plugins
©2011 Gabriel Lapointe Certains droits réservés 18
The Plugins
ImageJ can be viewed as a collection of small programs or "plugins" written in java
This modular structure has the advantage of allowing easy addition of new features in ImageJ
10
©2011 Gabriel Lapointe Certains droits réservés 19
Recording macro commands and operations register Plugins > Macros > Record...
Records the actions taken and implement macro language
Can also be used as a logging tool for future references
©2010 Gabriel Lapointe Certains droits réservés 20
Menus : Help
11
©2011 Gabriel Lapointe Certains droits réservés 21
Exercises 0:
Launch ImageJ Folder: Logiciels spécialisés
1) Create a new image (assembly)
2) Look at the pictures provided as examples
File / Open Samples
3) Have a look on your experimental images
22
What is a digital image?
12
Digital image
Matrix of pixels (Picture Elements)
Digital image
Pixel: smallest subunit of an image
Pixel characteristics
x and y coordinates
Intensity value (values for color image)
The maximum intensity value is
defined by the bit depth
13
©2011Gabriel Lapointe Certains droits réservés 25
Each pixel has an xy coordinate & intensity
(?,?) (3,4)
(0,0) (x,y)
Each pixel has an xy coordinate & intensity
Analyse > Plot profile
Analyse > Surface plot
14
27
How does it work with
color images?
Colors
In everyday’s life
Painting colors
Our eye view
Light sources
On screen
Digital images
Does it work the same way?
15
Formation of colors
Object colors
Paint mix
Human view
Light sources
On screen
Digital images
Light absorbed by
object is not visible
Light reflected by
object is visible
Screen: self-luminous light source
Colors are subtractive Primary colors: magenta, cyan & yellow
Colors are additive Primary colors: red, green & blue
How intensity of a color pixel is written?
Pixel intensity: (R,G,B):
WHITE: (255, 255, 255)
BLACK: ( 0, 0, 0)
RED: (255, 0, 0)
YELLOW: (255, 255, 0)
GREEN: ( 0, 255, 0)
CYAN: ( 0, 255, 255)
BLUE: ( 0, 0, 255)
RGB color image Standard images, fluorescence images
16
Intensity of an HSB color image?
Pixel intensity:
(Hue, Saturation, Brightness)
WHITE: ( 0, 0, 255)
BLACK: ( 0, 0, 0)
RED: ( 0, 255, 255)
YELLOW: ( 60, 255, 255)
GREEN: (120, 255, 255)
CYAN: (180, 255, 255)
BLUE: (240, 255, 255)
HSI (HSB) color image (more suitable for histology stained images)
©2011 Gabriel Lapointe Certains droits réservés 32
RGB Color Image intensity matrix
17
As we move the cursor over different parts of the image, the color values appear in the status bar of the program.
Color Image intensity value Main interface bar Analyze > Tools > Color Histogram
RGB color image intensity Image > Plugins > Graphics > RGB profile plot
RGB color
Analyse > Plot profile
Plugins > Graphics > RGB Profiles plot
18
35
Intensity values
Max. intensity is defined by bit depth
Max intensity of
1bit image: 1
19
Max intensity of
8 bit image: 255
12 bit image: 4 095
16 bit image: 65 536
Bit depth defines the max. intensity
©2011Gabriel Lapointe Certains droits réservés 38
Bit depth and Dynamic range
2 (2¹ tones)
256 (2⁸ tones)
65 536 (2¹⁶ tones)
4 096 (2¹² tones)
4 294 967 296 (2³² tones)
...
...
...
Binary: Fax, Mask
8-bits: Camera, Computer screen...
12 et 16-bits: CCD Camera, PMT...
32-bits: deconvolved images...
4 (2² tones)
8 (2³ tones)
16
32
64
128
Higher dynamic range permits to see more details; low and high signals together
20
Image type: Binary
Only 2 possibilities: Black or white
No dynamic range
Black = 0
White = …
1 bit image: 1
8 bit image: 255
12 bit image: 4 095
16 bit image: 65 536
Image type: Greyscale
Monochrome (one color) in levels of greys
Min. = 0
Max. intensity of …
8 bit image: 255
12 bit image: 4 095
16 bit image: 65 536
21
Image type: Color - Pseudocolor
Monochrome, each grayvalue is represented by a different color
Color is not related to specimen color, but to pixel intensity
Min. = 0
Max. intensity of …
8 bit image: 255
12 bit image: 4 095
16 bit image: 65 536
Image type: Color - Monochrome
Monochrome, colored in levels of one color
Min. = 0
Max. intensity of …
8 bit image: 255
12 bit image: 4 095
16 bit image: 65 536
22
Image type: Color - Multicolored
Mix of 3 colors
Red, Green and Blue: RGB
Bayer mask in
Standard digital
camera
NOT FOR
QUANTITATIVE
MEASURES
You are getting
only
¼ red photons
¼ blue photons
½ green photons
3 frames with
CCD camera
OK FOR
QUANTITATIVE
MEASURES But expect delay!
For each frame:
Min. = 0
Max. =…
8 bit image: 255
12 bit image: 4 095
16 bit image: 65 536
Image type: Color - Multicolored
Mix of 3 colors
Red, Green and Blue: RGB
Bayer mask in
Standard digital
camera
NOT FOR
QUANTITATIVE
MEASURES
You are getting
only
¼ red photons
¼ blue photons
½ green photons
3 frames with
CCD camera
OK FOR
QUANTITATIVE
MEASURES But expect delay!
! Note that… Max. intensity for each
individual frame is the same as the total
added frames in the RGB overlay image:
3 x 8 bit image: 24 bit RGB 255
3 x 12 bit image: 36 bit RGB 4 095
3 x 16 bit image: 48 bit RGB 65 536
23
Image type: Multi-dimensional
Image types in ImageJ
Binary: 1 bit (21)
Greyscale: 8, 12, 16 bit
Color
Pseudocoloured: 8, 16, 32 bit indexed colors
Monochrome color: 8, 16 bit color
Multicoloured: 8, 24 or 32 bit RGB
Composite: “stack of channels”: keeps originals as is
Multidimensional: hyperstacks
24
©2011 Gabriel Lapointe Certains droits réservés 47
Image types in ImageJ 8-bit
Binary images are considered as 8-bit images
with only 2 values from 0 (black) and 255
(white)16-bit
32-bit: addition of 4 8-bits images
8-bit Color
Grayscale with artificial coloring (Lookup Table)
RGB Color
Standard color images
RGB Stack
Images whose colors have been separated into
their red, green and blue in a stack (group of
pictures stacked on top of each other).
HSB Stack
Images whose colors have been separated into
their components Hue, Saturation and
Brightness.
©2011 Gabriel Lapointe Certains droits réservés 48
Need info about your image? Image > Show info Image > Properties
25
49
Image conversion
In ImageJ
8 or 16 bit color TO RGB color Image > Type > RGB color
Original
monochrome
16 bit green
Transformed to
RBG color
Be careful each
16 bit channel will
be decreased
to 8 bits
R
G
B
26
2011-06-09 ©2011 Gabriel Lapointe some rights reserved. 51
16 bit color images TO Hyperstacks Image > Color > Merge Channels… (Create composite)
Hyperstack Advantages:
Preserves bit depth
Multi-color (the first 4 colors are easy,
more requires a macro)
Multidimensional (Z and T axis
supported)
Can be spilt to original image without
data loss
Look at:
Image > hyperstack > Channels tools...
Composite
preserves the16 bit
Dynamic range of
original channels
RGB color TO individual channels Image > Color > Split Channels
Original RGB color
Split in 3 grayscale images Image > LUT
27
RGB color TO a montage Plugins > Color Function > RGB to montage
Original RGB color
If pseudocolour option is OFF,
each channel will be greyscale
RGB color to greyscale Image > Plugins > Graphics > RGB profile plot
RGB color To greyscale
Each color intensity
is divided by 3,
And then added together
To give the new grey value
28
RGB color TO individual channels Image > Color > Split Channels
RGB color of 4 channels Split in 3 grayscale images Image > LUT
If not a composite image,
you can not get back to
your 4 original images
©2011 Gabriel Lapointe Certains droits réservés
56
Image formats
Commun format
Generally limited to 8 bit, no meta-data
and unique image.
Lossy
.jpg
.gif
Lossless
.tif
.png
.raw
.gif
Specialized
Contain all the information (lossless), with
meta-data, and can be multidimensional
Standard: Can be opened in most software
.tif
.ics
.ome.tif and .ome
Proprietary: Frequent incompatibility.
.stk (Metamorph)
.lei & .lif (Leica)
.lsm (Zeiss LSM)
.oif (Olympus Floview1000)
.nd2 (Nikon)...
29
©2011 Gabriel Lapointe Certains droits réservés 57
Conversion to smaller files or other formats Compression hazards
Pre-processing: Enhance Visualisation
Image histogram
Brightness and contrast
LUT
Single pixel operations on single image
Single pixel operations on multiple images
58
30
Image Histogram
To enhance visualisation
59
©2011 Gabriel Lapointe Certains droits réservés 60
Histogram Analyze > Histogram
Représentation de la répartition de
l'intensité lumineuse d'une image où
l'on porte en abscisse le numéro des
niveaux de gris et en ordonnée pour
chaque niveau le nombre de pixels
ayant l'intensité correspondante à ce
niveau.
Linear
Logaritmic Frequency distribution of the image intensity
The abscisse represents the gray level
The ordinate, the number of pixels
31
©2011 Gabriel Lapointe Certains droits réservés 61
The interpretation of the histogram
Normal Underexposed Overexposed
Reduced dynamic range
©2011 Gabriel Lapointe Certains droits réservés 62
Histogram and Microscopy images
In fluorescence image
The biggest peak is often
the background!
An easy image to work with
might have a signal 3X higher
than the background
32
Brightness and Contrast
63
To enhance visualisation
Comparison of images
Tubuline control PABP control (no tubuline marquage)
BE CAREFUL TO
Autoscale display
Adjustment of brightness and contrast
Display range: 140-240 Display range: 143-3722
Why do I see red where it was supposed to negative?
What is the problem?
33
Comparison of images
Tubuline control
Why do I see something strong in red.
I didn’t expect this!
To be comparable, the images issued from the
same channel (same filter cube) should be
displayed with the same range of values
Same display range for both images
Display range: 143-3722
PABP control (no tubuline marquage)
Display range: 143-3722
©2011 Gabriel Lapointe Certains droits réservés 66
Adjusts the maximum and minimum value of the pixels and change the brightness and contrast of an image
Works on all types of images
For RGB images, Color Balance allows you to control each color individually
Will not change the value of the pixels
Unless you press Apply (for 8-bit and color images only)
Set can directly enter the maximum or minimum values
Useful to normalize multiple images
Adjusting brightness and contrast Image > Adjust > Brightness/Contrast...
34
©2011 Gabriel Lapointe Certains droits réservés 67
Adjusting brightness and contrast Image > Adjust > Brightness/Contrast...
LUT: Lookup tables
68
To enhance visualisation
35
©2011 Gabriel Lapointe Certains droits réservés 69
Lookup Table (LUT) Image > Lookup Table
Image is not converted into RGB Pixel values are preserved Image can be used in subsequent testing
Notes:
©2011 Gabriel Lapointe Certains droits réservés 70
Exercises 1: Texte-1.tif
Read the text without changing the contraste
Make text white on black background
Cellules-1.tif
Identify:
Image creation date
software used
exposure time
pixel size
Make transfected cells visible (only)
36
Operations on pixels
Point
or Single pixel
Local
Global
72
Operations
Changes the pixel values according to different mathematical functions
Single pixel operations:
Change the value of a pixel without considering the value of adjacent pixels
Filters :
Change the value of a pixel depending on the value of adjacent pixels
37
Single pixel operations To enhance visualisation
•Addition and subtraction
•Multiplication and division
•Histrogram stretching
•Gamma
©2011 Gabriel Lapointe Certains droits réservés 74
Intensity
Pixels
Intensity
Pixels
Addition
Intensity
Pixels
Multiplication
Intensity
Pixels
Logarythmic
Mathematics and images !
Subtraction
Division Exponential
38
©2011 Gabriel Lapointe Certains droits réservés 75
Addition and subtraction Process > Math > Add...
Original -125 +125
Addition and subtraction = change the image brightness
©2011 Gabriel Lapointe Certains droits réservés 76
Multiplication and division Process > Math > Multiply...
Original X 0.5 X 2
Multiplication and division = change the image contrast
39
Intensity
Pixels
Addition
Intensity
Pixels
Multiplication
Mathematics on images
Subtraction Division
Fluorescence light emission
is an additive process
Transmitted light absorption
is a multiplicative process
So background correction
operations seems better when
using a substraction for
fluorescence image and
division for transmitted light
images.
Automatic contrast enhancement Process > Enhance Contrast
40
©2011 Gabriel Lapointe Certains droits réservés 79
Automatic contrast enhancement Process > Enhance Contrast
©2011Gabriel Lapointe Certains droits réservés 80
Gamma (γ) : logarithmic or exponential factor Process > Math > Gamma
Bring non-linear change to the pixel intensity
41
Color image gamma 1.0
Gamma 2.2 on the same image
42
©2011 Gabriel Lapointe Certains droits réservés 83
The importance of gamma (γ)
©2011 Gabriel Lapointe Certains droits réservés 84
The influence of gamma (γ) Brightness & Contrast Original Gamma 0.5 Gamma 2
43
©2011 Gabriel Lapointe Certains droits réservés 85
Gamma correction (γ)
Process > Math > Gamma... Plugins > Filters > Gamma scroll
Image enhancement
44
Single pixel operations
87
To help visualisation of multiple images
Overlay of images
©2011 Gabriel Lapointe Certains droits réservés
88
Image Overlay Process > Image Calculator...
Convert to RGB
16-bit Images
with LUT
Addition You can also use plugins: ●Color Merge
●2 images at a time ●Choice of several colors ●images 16-bit supported
●RGB Gray Merge ●Up to 4 images at a time ●Weak color choice ●Transform 16 bit to 8-bit (24 bit result)
●Image > Color > Channel Merging... ●Up to 4 images at a time ●Weak color choice ●8, 16 et 32 bit ●Can provide an Hyperstack (depth conserved)
45
©2011 Gabriel Lapointe Certains droits réservés 89
Subtraction
16-bit images
with LUT Addition
Con
vert to
RG
B
Image Overlay Process > Image Calculator...
©2011 Gabriel Lapointe Certains droits réservés 90
Additions + Subtractions
Image Overlay Process > Image Calculator...
Additions
46
©2011 Gabriel Lapointe Certains droits réservés 91
Inverted Mask
Mask subtraction for data mining Process > Image Calculator...
Subtraction
Is there a signal of tubulin in the nuclei?
©2011 Gabriel Lapointe Certains droits réservés 92
Background correction
Edit / Invert
+ =
Background (illumination problem) – to eliminate
47
©2011 Gabriel Lapointe Certains droits réservés 93
Exercises 2:
Restore-1.tif
Improve image
Cellules-3_*.tif
Improve images (Contrast, γ, etc.)
Make a color assembly
Pre-processing: Enhance Visualisation
Local operations on pixels:
Median filter
Mean filter
Modal filter
FFT Bandpass filter
94
48
©2011 Gabriel Lapointe Certains droits réservés. 95
Filters in imagery
©2011 Gabriel Lapointe Certains droits réservés. 96
The concept of Kernel
49
©2011 Gabriel Lapointe Certains droits réservés. 97
Kernel size and shape
r=0.5 r=1.0 r=1.5 r=2.0 r=2.5 r=3.0
r=3.5 r=4.0 r=4.5 r=5.0 r=5.5 r=6.0
2010-11-12 ©2010 Gabriel Lapointe Certains droits réservés. 98
The noise Random variation in the
intensity of the pixels. Do not
confused with the background,
the black level or a nonspecific
signal.
Salt & pepper : Black pixel in a
clear area and white in a dark
area. Often caused by a dead
pixel in the camera.
Gaussien : Variation with a
Gaussian distribution,
independent of the intensity of the
pixels. Generally increases with
the voltage applied to the
detector.
50
©2011 Gabriel Lapointe Certains droits réservés. 99
Noise correction Process > Filters > ...
Median
Mean
Gaussian
©2011 Gabriel Lapointe Certains droits réservés. 100
The impact of the size of the kernel
Median
r=0.5 r=1.0 r=2.0 r=6.0
Mean
51
©2011 Gabriel Lapointe Certains droits réservés. 101
Edge Enhancement Process > Filters > ...
Sharpen
Unsharpen
Variance
©2011 Gabriel Lapointe Certains droits réservés. 102
Edge Enhancement : a bad idea Process > Filters > ...
Sharpen
Unsharpen
Variance
52
©2011 Gabriel Lapointe Certains droits réservés. 103
The space of sequences Fourrier transform (Fast Fourrier Transform)
©2011 Gabriel Lapointe Certains droits réservés. 104
Bandpass Filter Process > FFT > Bandpass Filter...
53
©2011 Gabriel Lapointe Certains droits réservés. 105
Periodicity and frequency
©2011 Gabriel Lapointe Certains droits réservés. 106
Images rebuild with FFT Process > FFT > ...
FFT
Inverse FFT
54
©2011 Gabriel Lapointe Certains droits réservés. 107
Exercises 3:
Restore-3.tif
Remove image noise using the filters
Try several and see the differences, which seems most appropriate?
Cellules-5_*.tif (series of images)
Enhancing images using filters…
Attempt to obtain greater precision of details
Afternoon workshop
Work on your images
Follow the procedures which will be given to improve your images
Questions, problems ... Ask us, we're here for you!!
55
©2011Gabriel Lapointe Certains droits réservés 109
Ressources Official website :
http://rsbweb.nih.gov/ij/index.html
Macbiophotonics :
http://www.macbiophotonics.ca/imagej/
Wiki :
http://imagejdocu.tudor.lu/doku.php
Diffusion list :
https://list.nih.gov/archives/imagej.html
Burger et Burge : Digital Image Processing, An Algorithmic
Introduction using Java; Springer Verlag, 2008
http://www.imagingbook.com/
©2011 Gabriel Lapointe Certains droits réservés 110
Plugins : Installing and Compiling (1)
The plugins are easily installed simply by placing them in the plugins folders
To find the plugins folder:
Plugins > Utilities > ImageJ Properties...
Find the line that begins : Menus.getPlugInsPath
The plugins are found in 3 formats *.java : Source code, can change the plugins. Need to be compiled to use them (Plugins> Compile and run ...)
*.class : File already compiled that can be used directly by ImageJ
*.jar : Plugins for more complex, requiring multiple class files are grouped in an archive file. Can be used directly by ImageJ
56
©2010 Gabriel Lapointe Certains droits réservés 111
All *. class, *. jar and *. txt in the plugins folder, and contain a "_"in their name, will be recognized by ImageJ and accessible in the menu Plugins.
Plugins : Installing and Compiling (2)