Basic Image Processing (using ImageJ) Image Processing2011.pdf · Dr. Arne Seitz PT-BIOP course,...
Transcript of Basic Image Processing (using ImageJ) Image Processing2011.pdf · Dr. Arne Seitz PT-BIOP course,...
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Basic Image Processing(using ImageJ)
Dr. Arne SeitzSwiss Institute of Technology (EPFL)
Faculty of Life Sciences Head of BIOIMAGING AND OPTICS – BIOP
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
2
MotivationWhat is the difference
Biological Question ExperimentImage AcquisitionImage AnalysisConclusion
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Image Analysis
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Can we trust our eyes....
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Seeing is believing, measuring is science
0 100 200 300 400
110120130140150160170
0 100 200 300 400
110120130140150160170
grey
value
s
Pixels
grey
value
s
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Definition Digital imageA digital image is a representation of a two-dimensional image
using ones and zeros (binary). (Wikipedia)
Analog = continuous valuesDigital = discrete steps
Digital Images are raster images consisting of pixels (or picture elements). Pixels are the smallest addressable units.
1
0
01
01
1 10 01
1 110 0
11 01 11 1
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Images are artefacts
This is the same object (sample) imaged with the same objective!
Object Imageof Object
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Images are artefacts
- Images are a representation of an object.- Image of an point is not necessarily a point
(point-spread function).- The content/information of a pixel is affected by the
setting of the microscope.- Images without metadata are useless!!!
- Sampling of the image- Remember Nyquist- Sampling affects pixel information
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Overview
• File formats (data storage)• Programs for image viewing / processing /
representation• Basic Image Processing (using ImageJ)
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
File Formats – data storage
• Lossless image formats• Lossy compresion formats• Custom formats (microscope companies)• Sequence vs. single image per file• 8bit, 12bit, 16bit, 32bit, RGB
Storage: – Always have at least 1 copy of the data– Very suitable fileservers (automatic backup)
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Lossless Image Formats
TIFF (with our without compression)BMP (windows uncompressed)GIF (graphics interchange format)PNG (portable network graphics)Raw data‘text image’
Microscopy Primerhttp://micro.magnet.fsu.edu/primer
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Image Format: TIFF
Tag Image File Format– Image header with flexible set of ‘tags’ which can be used to
store e.g. microscopic settingsFlexible in color space and bit depth
– Microscopy: grayscale 8bit, 16 bit (12bit data)– Color (e.g. Overlay): RGB (red green blue 8bit each)– Quantification: 32bit (floating point values)
Always lossless: Uncompressed or compressedMultiple images possible in one file
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Image Compression: TIFFRun Length Coding (RLE): first number discribes the color, the second the
number of following pixels having the same color.
LZW (Lempel-Ziv-Welch): Find repetative patterns of values and give them a number which is points to an entry of a „dictionary“ (LUT).
(0,0,0), 6 (0,255,0), 9 (0,0,0), 2 (255,0,0), 6
1 2 3
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Image Compression: TIFFPros:Extra infos can be written in the ‚tags‘
(e.g. microscope data like objective lens, voxel size)Everybody can read it LosslessFlexible (8, 16, 32bit grayscale, 8:8:8bit RGB)
Cons:Big filesCompressed files can´t be loaded by ImageJ
25665536 graylevels
Floating point values
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Lossy Image FormatsThe lossy compression algorithm takes advantage of the limitations
of the human visual senses and discards information that would not be sensed by the eye.(like mp3 in audio).
Compression level is usually flexible, but the more compressed the more information is lost and artifacts become visible by eye
From: www.wikipedia.org
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Image Compression: JPGSplit image into color and gray-scale information (color is less important than bounderies) reduce high frequency color information.
Group pixel into 8x8 blocks and transform through discrete cosine transform…
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Image Compression: JPG
Pros:Small FilesTrue ColorUsable for most photos (real life) and
presentations (powerpoint)
Cons:Do not use for quantification !„Unrelevant“ photoinfos get lostEvery file-saving reduces the quality
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Image Viewers
ImageJ (Java based, freeware, Win/MAC/Linux)Irfanview (www.irfanview.com/)
– Freeware– Convert (e.g. tif jpg)– Batch processing
ACDSee (ACD Systems)Microscope companies
– Zeiss Image Browser / Axiovision LE– Leica LCS Lite– Olympus Viewer
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Image RepresentationImageJImaris (Bitplane):
– 4 floating licenses– installed on image processing workstations
Photoshop, Paintshop, Illustrator, Corel Draw (, Powerpoint)
Volocity (Improvision): Custom software of microscopes
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Image Processing
ImageJ(http://rsb.info.nih.gov/ij/index.html)– installed on all image processing workstations– Installation: http://pacific.mpi-cbg.de/wiki/index.php
(Fiji=ImageJ+plugins+regular automatc udate)– Manual: www.uhnresearch.ca/facilities/wcif/imagej/
(also available as pdf)– Additional plugins: http://rsb.info.nih.gov/ij/plugins/index.html
Metamorph (Universal Imaging), – installed on 2 image processing workstations
Custom software of microscopes
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Image Processing Basics
Visual Image Inspection Lookup tables (LUT) and LUT operationsHistogram, brightness, contrastFilterThresholdMeasurementsColor functions
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Visual Image InspectionDisplaying images, histogram
Intensity value
Pixe
l cou
nt
Microscopy Primerhttp://micro.magnet.fsu.edu/primer
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
LUT operationsLookup table (LUT)
– Displays can only show 256 gray values (8bit) per color – Data is unchanged, it´s only “mapped” differently
Data Intensity
Displayed Intensity
0 0
… …
179 0
180 5
181 10
… …
226
227
228 255
229 255
65535 255
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Brightness, Contrast
Contrast is the difference in visual properties that makes an object distinguishable from other objects and the background. Caution: Apply modifies the data!
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Color LUTThe pixel contains a „pointer“ to an array, where the actual pixel
values are storedold LUT:1: (0,102,255)2: (51,102,2553: (10,100,200)
1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 1 1 3 3 3 3 3 3
1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 1 1 3 3 3 3 3 3
new LUT:1: (0,0,0)2: (0,255,0)3: (255,0,0)
“HiLo” LUT“Rainbow” LUT
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Non-linear Histogram StretchEnhance contrast by (changing data):
Raw data“Equalization” non-linear stretch based on square root of the intensity
Linear stretch“Normalization”
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Equalization
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
GammaGamma is a non-linear histogram adjustment8 bit images:
New intensity = 255 × [(old intensity/255) gamma]
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
FilteringImage processing filters are mainly used to:
– suppress the high frequencies in the image, i.e. smoothing the image, noise reduction
– or suppress the low frequencies, i.e. enhancing or detecting edges in the image
An image can be filtered either in the frequency or in the spatial domain. – Filtering in the frequency domain requires Fourier
transform first and re-transformation after application of the filter.
– Filtering in the spatial domain is done by convolving the image with the filterfunction.
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
FilteringShifting and multiplying a filter kernel
Filtered image
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Noise Reduction: Mean
mean
Mean 1pt
19
19
19
19
19
19
19
19
19
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Noise Reduction: Gaussian
Filtering with a gaussianbell-shaped kernel:
1 2 1
2 4 2
1 2 1
116
10 25 3
9 33 5
4 6 8
10 50 3
18 132 10
4 12 8
116
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Noise Reduction: Median
median
Median 3x3
Median 5x5
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Noise Reduction: Median, Mean
Median, 1pt
Mean, 1pt
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Median-, Mean-, Max-, Min-Filter
Median, 5pt Mean, 5pt
Min, 2pt Max, 2pt
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Mean-, Gauss-Filter
Mean, 2pt, 4 pt Gauss, 2pt, 4 pt
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Mean-, Median-Filter
Mean, 2pt, 4 pt Median, 2pt, 4 pt
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Min-, Max-Filter
Min, 2pt Max, 2pt
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Sharpen / Blur-1 -1 -1-1 9 -1-1 -1 -1
sharpen
1 1 11 2 11 1 1
blurring
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Example: Edge-Finding with derivatives
-1 -1 -10 0 01 1 1
-1 -1 -10 1 01 1 1
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Background SubtractionEven background:
– subtract average background from image
Subtract “backgound image” (same exposure time without illumination)
Uneven background: Rolling ball filter– Use kernel larger than diameter of largest object
Original Image
“Opening”
Original Image - Opening
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Line ProfileWithout background subtraction
After rolling ball (50) background subtraction
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
ThresholdingThresholding is used to change pixel values above or below a certain intensity value (threshold):
Threshholding is a simple method for Segmentation (separation and location of objects of interest)
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Measuring Sizes
Set Scale with pixel (voxel) sizeInclude Scalebar
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Measuring Length
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Area Measurement
16bit image 32bit image 32bit image,background thresholdedto “Not a Number”
16bit image,same thresholdas in 32bit imagebut not applied
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Analyze Particles
Segmented objects
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Threshold and Opening/Closing
dilate erode
Closing: Dilate/ErodeOpening: Erode/Dilate
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Color FunctionsRGB Merge /RGB Split
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
Conclusions
• Keep environment constant and convenient• Use powerful dyes• Think about required resolution
(x, y, z, t, brightness, channel number) to minimize photostress
• Use appropriate microscopy method
Dr. Arne Seitz PT-BIOP course, Image Processing, EPFL 2011
BioImaging &Optics Platform
• Use lossless file formats for archiving important data• Image processing is an important step in generating
(optimal) results• Only use documented image processing
steps/routines
Summary