a (very brief) introduction to image processing and 3d printing with imagej

30
This document is published under Creative Commons License: Attribution 4.0 International (CC BY ) If you have any questions, please contact me via twitter at @ PJMignone

Upload: paul-j-mignone-phd

Post on 15-Apr-2017

130 views

Category:

Design


2 download

TRANSCRIPT

Page 1: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

This document is published under Creative Commons License:

Attribution 4.0 International (CC BY)

If you have any questions, please contact me via twitter at @PJMignone

Page 2: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

A (very brief) introduction to image

processing with ImageJ

Paul John Mignone

June, 2016

© Copyright The University of Melbourne 2013

Page 3: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

A bit about me…

2001 2016

Page 4: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

What tonight is about?

• Digital image basics

• Digital image processing

• The ImageJ and Meshmixer software interfaces

• Good Reference: Gonzalez, R., Wood, R., “Digital Image

Processing”, Second Edition, 2002, Upper Saddle River,

N.J., Prentice Hall

• ImageJ documentation: http://imagej.net/docs/

Page 5: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Digital Images• A digital image is a numerical

representation of a, two-dimensional

image. They can be of vector or raster

type.

• Vector images (.svg) use geometrical

primitives (e.g lines and curves), to create

an image based on mathematical

expressions (not covered).

• Raster images have a finite set of digital

values (i.e. pixels). Pixels are the smallest

individual element in an image, holding

quantized values that represent the

intensity of a given colour at any specific point.

(Raster)

http://en.wikipedia.org/wiki/Vector_image

Page 6: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Image (pixel) resolution

• The term resolution is often used for a pixel count in raster images.

• Traditionally defined with a two positive integer numbers:

– Number of pixels across (width)

– Number of pixels down (height)

– Example: 7680 by 4320

• Can also be defined by a number of ‘megapixels’.

– Example: An image that is 2048 pixels in width and 1536 pixels in height has a total of 2048x1536 = 3,145,728 pixels or 3.1 megapixels.

– Typically used to define the resolution of digital cameras.

Page 7: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Sampling and Quantisation• On taking a photo, images are

converted to digital via two processes:

• Sampling: The discretisation of the continuous image into a series of pixels in 2D Cartesian space.

• Quantisation: Discretisation of the intensity (i.e. colour) values at each pixel.

• Intensity of colour images are defined with RGB vales (right), while greyscale images use ‘grey-levels’ (above right).

Sampling of a greyscale image

Quantization of a colour

image using Red, Blue

and Green (RGB)

values.

Page 8: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Greyscale Images

Grey scale images digitized at varying bit-

depths

• Grey scale images are digital

images with a single intensity

value (or grey level).

• Number of grey levels depends

on the bit-depth of the image.

• Calculated as 2 to the power of

the bit depth value:

• Example an 8-bit image can

save 28 or 256 grey levels.

• ‘Binary’ images are 1-bit.

• Generally, the intensity value 0

is assigned the colour black

and the maximum grey level

value (e.g. 255 in an 8-bit

image) is white.

Page 9: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Image Histogram• Acts as a graphical representation of

the intensity distribution in a digital image.

• Plots the number of pixels (y-axis) for each intensity value (x-axis).

• The left side of the x-axis represents the darker areas, and the right side represents the lighter areas.

• Used to determine whether image detail has been lost due to blown-out highlights or blacked-out shadows.

• Generally, the contrast of an image can be improved by ‘spreading out’ the most frequent intensity values (i.e. equalization).

Examples of dark (a) and bright (c) images.

Examples of dark (b) and (d) image

histograms.

Page 10: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Digital Image Processing

• The use of computer algorithms to enhance the quality of images.

• Used in the medical and scientific fields for datasets created from imaging devices (PET, MRI, CT, microscopy etc).

• ImageJ is an open source program for multidimensional image processing.

• FIJI (Fiji Is Just ImageJ) is "batteries-included" distribution of ImageJ, bundling a lot of plugins relevant for scientific image analysis.

Page 11: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Guided Demonstration

• Image processing of Alumina foam microstructure.

• Images created using micro-computed tomography (MCT).

• Image stack is composed of x99 2D images (tiff format), each with a resolution of 99 by 99 pixels.

Alumina foam sample (left), the MCT procedure (top), and

the Alumina microstructure (above)

Page 12: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Before we begin…

• Install Fiji Is Just ImageJ (FIJI)

– Installation on USB sticks

– Link to install: http://fiji.sc/

– Please install the latest updates before lesson!

• Install AutoDesk Meshmixer

– Link to install: http://www.meshmixer.com/

• Datasets:

– Alumina Foam Demo: https://goo.gl/5cG2lo

– Head: https://goo.gl/jis0Jg

– Hip: https://goo.gl/QHcgka

– Pelvis: https://goo.gl/JBTRrP

– Shoulder: https://goo.gl/bijBMH

Page 13: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Before we begin…

• Extract 01_Alumina_Foam_Sample.rar to a folder

• Open FIJI and go to:

File Import Image Sequence

• Select the first image in the extracted Alumina Foam Sample directory

• Accept the defaults in the sequence options and select OK.

Page 14: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Record a Macro (optional)!

Can be used to write (JavaScript) workflows and plugins. You can access then from top tool bar at Plugins Macros.

Link to documentation: https://imagej.nih.gov/ij/docs/guide/146-15.html

Page 15: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Data Snapshot in ImageJ

Slice Number

Slice Name

Image Dims

Bit Depth

Memory

Page 16: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Image Filtering

• Filters can be applied to images in order to improve the results of image segmentation (explained later).

• It’s considered good practice to make a copy of the background image before applying filters, so that you always have a copy of the original for comparison.

• Hold Ctrl+Shift+D, select ‘Duplicate Stack’, followed by OK to duplicate the stack.

• Go to Process Filters Median 3D

Page 17: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Median Filter• The main idea of the median filter is to run through

each pixel of an image, and replaces the intensity of each pixel with the median intensity value of neighbouring pixels (below).

• Ideal for preserving image edges, while removing ‘speckle’ (i.e. salt & pepper) noise (right).

• Ideal if the noise-to-image ratio is “low”. The Median filtering of high-noise images can lead to edge erosion.

Page 18: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Median Filter Example

• Be sure to first duplicate a copy of the original unfiltered stack.

• Set Median filter to a pixel radius of 1 in the the X, Y and Z directions.

• Duplicate another copy of the original unfiltered stack.

• Repeat the Median filter operation, but with a pixel radius of 2 or 3.

• Observe how regions become ‘smoother’, while retaining edges.

• Moral of the Story: Trail and error is your friend!

Page 19: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Image Segmentation• The process of partitioning a digital

image into multiple segments (i.e. groups of pixels or ‘masks’).

• Used to simplify and/or change the representation of an image into something that is more meaningful for analysis.

• It’s typically used to locate objects and boundaries in images.

• A label is assigned to every pixel in an image such that pixels with the same label share certain characteristics.

Page 20: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Image Thresholding

• The simplest segmentation method available.

• This separation is based on the variation of intensity between the object pixels and the background pixels.

• Process involves performing a comparison of each pixel intensity value with respect to a threshold intensity value (determined by the user).

• Once decided, pixels with an intensity above or below the threshold can be assigned specific intensity values.

Source

Image

Thresholded

Image

Page 21: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Threshold

Settings

Post-

Threshold

Segmentation Example

• From the top tool bar, select Image Adjust Threshold

• Adjust the intensity sliders and observe the changes. Select a threshold intensity and click ‘Apply’.

– Note: Auto threshold value is reasonable for this example.

• On converting the stack to binary, accept the default settings and click OK.

• Your Alumina foam image stack will now consist of binary (i.e., black and white) images.

Page 22: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

3D Viewer

• The 3D Viewer uses Java 3D to provide hardware-accelerated 3D visualization of image stacks.

• Image stacks can be viewed as volumes, surfaces and orthoslices.

• Surfaces can be exported as STL files for mesh editing, 3D printing and CAD/CAE applications.

• Access the 3D viewer from the top toolbar by selecting Plugins 3D Viewer.

Page 23: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

3D Viewer• To view the foam surface, switch ‘Display

as’ to ‘surface’.

• Adjust the resampling factor to 1 (for a high quality surface mesh) and select OK.

• STL File can be exported by going to File Export surfaces STL (ASCII or Binary).

• For the Alumina foam demo, you will need to ‘invert’ the image stack before running 3D viewer.

• You can do this by going to the top tool bar and selecting Edit Invert.

Page 24: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Foam Surface from 3D Viewer

Disconnected

Regions!

Page 25: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Disconnected Regions

• Most image processing techniques have their limitations. Depending on the application, they won’t always be able to perform all desired tasks by the user.

• This will sometimes result in spurious features in your model (e.g., disconnected foam regions in a pore space).

• Techniques exist to remove them, with the ‘last resort’ being the user manually removing them (can be VERY time consuming).

• In this example, we’ll show how to remove these features easily with Meshmixer.

Page 26: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Removing Disconnected Regions

• Open Meshmixer and go to File Import. Choose your STL file created in Fiji and select ‘Open’.

• Select Analysis Inspector. Notice all the magenta regions. These highlight the disconnected regions in the model.

• Disconnected regions can be removed by clicking on the individual magenta spheres or by selecting ‘Auto Repair All’.

• Your model is ready for 3D printing! Go to File Export to save you STL file.

Page 27: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Meshmixer is fun! Have fun playing!

Page 28: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Workshop Time!

Use ImageJ and Meshmixer to post-process the head, hip, pelvis and/or shoulder datasets provided.

Page 29: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

Useful Resources!

• ImageJ Documentation

– https://imagej.nih.gov/ij/docs/

• Mishmixer Documentation:

– http://www.mmmanual.com/

• 3D datasets:

– http://www.osirix-viewer.com/datasets/

– https://mri.radiology.uiowa.edu/visible_human_datasets.html

• 3DSlicer (Open source image processing software):

– Tutorial: https://goo.gl/jLuHMX

Page 30: A (very brief) Introduction to Image Processing and 3D Printing with ImageJ

This document is published under Creative Commons License:

Attribution 4.0 International (CC BY)

If you have any questions, please contact me via twitter at @PJMignone