Computational Biology, Part 23 Biological Imaging III G. Steven Vanni Robert F. Murphy Copyright 1998, All rights reserved.
Basic Image Processing Operations Arithmetic Operations Arithmetic Operations Kernel Operations Kernel Operations Image Math Image Math
Arithmetic Operations Two cases: Two cases: Perform a single operand operation (e.g., logarithm, square root) on each pixel of an image Perform a dual operand operation (e.g., add, multiply) on each pixel of an image using a constant as the second operand In both cases, the result is usually stored in the same pixel location (“storing in place”) In both cases, the result is usually stored in the same pixel location (“storing in place”)
Arithmetic Operations
Kernel Operations Basic idea: Use a matrix (usually square and of odd dimension, e.g., 3x3) in combination with an image to generate a new image Basic idea: Use a matrix (usually square and of odd dimension, e.g., 3x3) in combination with an image to generate a new image Algorithm: Algorithm: For each pixel in the image (the current pixel) Align the matrix to center it on that pixel For each position in the matrix, multiply the corresponding pixel value in the image by the value in the matrix and sum the results Store the result in the current pixel
Kernel Operations A matrix used in this fashion is called a kernel A matrix used in this fashion is called a kernel Note that the operation is different from matrix multiplication of the kernel by the image because Note that the operation is different from matrix multiplication of the kernel by the image because the dimensions don’t match, and all elements of the matrix are combined to give one result
Common Kernel Operations used in Image Processing Smoothing Smoothing Sharpening Sharpening Edge Finding Edge Finding
Examples of Kernel Operations using NIH Image Open an example file (from Mellon: BioServer: File Service: Courses: 03310: Demos: NIH Image files) Open an example file (from Mellon: BioServer: File Service: Courses: 03310: Demos: NIH Image files)
Original image Original image
Examples of Kernel Operations using NIH Image Smooth Smooth
Results of one Smooth Results of one Smooth
Results of a second Smooth Results of a second Smooth
Examples of Kernel Operations using NIH Image Close smoothed image, reopen original image, then Sharpen Close smoothed image, reopen original image, then Sharpen
Original image Original image
Image after one Sharpen Image after one Sharpen
Image after a second Sharpen Image after a second Sharpen
Examples of Kernel Operations using NIH Image Close sharpened image, reopen original image, then Find Edges Close sharpened image, reopen original image, then Find Edges
Image after Find Edges Image after Find Edges
Example kernels Smoothing Smoothing
Example kernels Sharpen Sharpen
Example kernels Edge detection (Sobel) Edge detection (Sobel)
Image Math Basic idea: Combine two images using an dual operand operator to generate a new image Basic idea: Combine two images using an dual operand operator to generate a new image Algorithm: Algorithm: For each pixel in the first image, operate on it using the corresponding pixel in the second image and store the result in the corresponding pixel in a new (output) image
Image Math Any operator can be used Any operator can be used Most common operators: Most common operators: division: generate ratio image logical AND: mask one image with another (usually binary) image
Examples of Image Math using NIH Image Open original image and sharpen once (save as Abdomen.sharpen1), reopen original image Open original image and sharpen once (save as Abdomen.sharpen1), reopen original image
Ratio of sharp to original image (shows regions affected by sharpen) Ratio of sharp to original image (shows regions affected by sharpen)
Image Math vs. Arithmetic Operations Note difference between Image Math which does an operation on two images and Arithmetic which does an operation on a single image and a constant Note difference between Image Math which does an operation on two images and Arithmetic which does an operation on a single image and a constant
Summary: Basic Image Processing Operations Arithmetic Operations Arithmetic Operations Inputs: Image, Constant (optional) Common use: Subtract background Kernel Operations Kernel Operations Inputs: Image, Kernel Common use: Smoothing Image Math Image Math Inputs: Two images Common use: Generate ratio image