simple processing
TRANSCRIPT
-
8/14/2019 Simple Processing
1/19
1 Ellen L. Walker
ImageJ
s Java image processing tool from NIH
q http://rsbweb.nih.gov/ij/
s Reads / writes a large variety of images
s Many image processing operations are implementedq Good rapid prototyping / testing tool
s Includes the ability to write your own plugins
q Convenient way to implement your own algorithms, usingtheir image class and i/o methods
http://rsbweb.nih.gov/ij/http://rsbweb.nih.gov/ij/ -
8/14/2019 Simple Processing
2/19
2 Ellen L. Walker
Point Processes
s Pixel by pixel transformation
s Output pixel depends only on corresponding input pixel
s Examples:
q Out(r,c) = In(r,c) * 1.25
q Out(r,c) = In(r,c) + 25
q Out(r,c) = (In(r,c))2
-
8/14/2019 Simple Processing
3/19
3 Ellen L. Walker
Linear Transformations
s Out(r,c) = In(r,c) * gain+ bias
q Gaincontrols contrast
q Biascontrols brightness
s Location dependent:
q Out(r,c) = In(r,c) * gain(r,c) + bias(r,c)
q E.g. sky darkening filter
s Linear Blend
q Out(r,c) = (lambda) * In1(r,c) + (1-lambda) * In2(r,c)
q If In1 and In2 are images, a sequence of these from lambda = 0 tolambda=1 is an image dissolve
-
8/14/2019 Simple Processing
4/19
4 Ellen L. Walker
Histogram
s An image histogram counts the number of pixels at each brightness.
s Color images have 3 histograms (red, green, blue)
0
1
2
3
4
5
6
7
0 1 2 3
Series2
-
8/14/2019 Simple Processing
5/19
5 Ellen L. Walker
Information in Histogram
s Contrast (variation in brightness)
q Are bars spread over the whole range?
s Foreground vs. background color
q Are there two separate peaks with a valley between?
-
8/14/2019 Simple Processing
6/19
6 Ellen L. Walker
Applications of Histogram
s Thresholding
q Find a value that separates foreground / backgroundvalues
q Look for a valley between two peaks (may or may not bewhat you need)
s Contrast enhancement
q Histogram equalization spread the data as evenlythrough the histogram as possible
q Goal: wide, flat histogram
-
8/14/2019 Simple Processing
7/197 Ellen L. Walker
Example: Histogram Equalization
s Original
s Modified
-
8/14/2019 Simple Processing
8/198 Ellen L. Walker
Algorithm: Histogram Equalization
s Find cumulative distribution
q For each intensity I, c(I) = # pixels
-
8/14/2019 Simple Processing
9/199 Ellen L. Walker
Algorithm: Histogram Equalization
s Use C(I) as a lookup table to determine the final value of
each pixel.
s Since C(I) ranges from 0 to 1 (why?), multiply C(I) by themax pixel value to get the output value
s Code:
For(r=0;r
-
8/14/2019 Simple Processing
10/1910 Ellen L. Walker
Locally Adaptive Histogram Equalization
s Instead of doing histogram equalization using the whole
image, compute the distribution for a moving windowaround the given pixel.
s Avoids effect of bright light at one corner washing outeverything in the image.
-
8/14/2019 Simple Processing
11/1911 Ellen L. Walker
Image Neighborhoods
s Neighborhoods can be defined for each pixel
s The two most common neighborhoods
q 4-neighborhood
q 8-neighborhood
NW E
S
-
8/14/2019 Simple Processing
12/1912 Ellen L. Walker
Applying a Mask
s Mask is a set of relative pixel positions. One is
designated the origin (0,0) - usually at center
s Each mask element is weighted
s To apply the mask, put the origin pixel over the imagepixel and multiply weights by the pixels under them, thenadd up all the values.
s Usually this is repeated for every pixel in the image .
Assumptions must be made for pixels near the edge ofthe image.
-
8/14/2019 Simple Processing
13/1913 Ellen L. Walker
Mask application example
s Mask = 1 1 1
s Apply to every pixelin image:
0 0 0 0 1
0 0 0 1 1
0 0 1 1 1
0 1 1 1 1
1 1 1 1 1
s Result is
0 0 0 1 1
0 0 1 2 2
0 1 2 3 2
1 2 3 3 2
2 3 3 3 2
Boundary pixels are gray
-
8/14/2019 Simple Processing
14/1914 Ellen L. Walker
Mathematical Representation of Mask Operations
s Equation from Chapter 3
q g is the output image
q f is the input image
q h is the mask (also called kernel)
s Short form (convolution operator)
g(i, j) = f(i + k, j + l)h(k, l)k,l
g = f h
-
8/14/2019 Simple Processing
15/1915 Ellen L. Walker
Masks that "blur"
s "Box mask" - every pixel gets the average of its
neighborhood1 1 1 After computing, divide by 9 (mask
sum)
1 1 1 to keep image from getting too bright
1 1 1
s "Weighted average" - divide by 16 after application
1 2 1
2 4 2
1 2 1
-
8/14/2019 Simple Processing
16/1916 Ellen L. Walker
Why blur?
s Avoid effects of small random noise (salt and pepper)
s Remove small features to emphasize larger ones
q Bigger masks blur more / remove larger features
q Sequence of masks generates sequence of increasingly
blurred images (useful for some matching algorithms)
s First step in sharpening the image (!)
Sharp(x,y) =
orig(x,y) + gamma (orig(x,y) (blur * orig(x,y)))
-
8/14/2019 Simple Processing
17/1917 Ellen L. Walker
Boundary Effects (padding)
Figure 3.12
-
8/14/2019 Simple Processing
18/1918 Ellen L. Walker
Common Masks
Figure 3.13
-
8/14/2019 Simple Processing
19/19
Median Filtering
s Example of a non-linear filter
s Replace the central pixel of a window with the medianpixel of the window
s Compare to box filter, which replaces with averagevaluein the window
s Tends to preserve edges (why?)