28
Lecture 5: Point Processing of Images Harvey Rhody Chester F. Carlson Center for Imaging Science Rochester Institute of Technology [email protected] September 20, 2005 Abstract Point processing uses only the information in individual pixels to produce new images. A transform may be computed on the basis of regional or global information and then applied to the individual points. Such transforms are scalar functions. The discrete version of such functions can be implemented in IDL as function arrays for fast and efficient processing. Applications to image enhancement are given for monochrome and color images. DIP Lecture 5

Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Lecture 5: Point Processing of Images

Harvey RhodyChester F. Carlson Center for Imaging Science

Rochester Institute of [email protected]

September 20, 2005

AbstractPoint processing uses only the information in individual pixels to

produce new images. A transform may be computed on the basisof regional or global information and then applied to the individualpoints. Such transforms are scalar functions. The discrete versionof such functions can be implemented in IDL as function arrays forfast and efficient processing. Applications to image enhancement aregiven for monochrome and color images.

DIP Lecture 5

Page 2: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Basic Point Processing

Point processing is used to transform an image by operating on individualpixels. If array A represents an input image then an output array B isproduced by a transformation

B[x, y] = T[A[x, y]

]

DIP Lecture 5 1

Page 3: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Common Point Transforms

Some basic gray-leveltransformation functions used forimage enhancement. (G&WFigure 3.3)

DIP Lecture 5 2

Page 4: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Example: Negative Image

→ →

The negative transform exchanges dark values for light values and viceversa.

DIP Lecture 5 3

Page 5: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Gamma Correction s = rγ

DIP Lecture 5 4

Page 6: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Use of Gamma Correction

fname=‘loggingcamp.jpg’A=Read Image(fname)sa=Size(A,/dimensions)Window,/Free,Xsize=sa[0],Ysize=sa[1]gamma=1.0 ;Change this for different correctionsT=BYTE(256*(FINDGEN(256)/256)^gamma)TV,T[A]

We’ll run this program for several values of γ.

DIP Lecture 5 5

Page 7: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Histogram Processing

An image will have low contrastif its brightness values are tooconcentrated.

This image has low contrast,making it difficult to see some ofthe items in the shadows.

DIP Lecture 5 6

Page 8: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Gamma Correction

Original γ = 0.3 γ = 0.5 γ = 0.7

DIP Lecture 5 7

Page 9: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Evaluation

In some cases it is difficult to choose a good value of γ. The image is eithertoo washed out or too dark.

Let’s look further by examining the image histogram.

The goal is to use all brightness values with approximately the samefrequency.

DIP Lecture 5 8

Page 10: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Effect of Gamma Correction on Histogram

DIP Lecture 5 9

Page 11: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Histogram Equalization

Find a point transformation B = T [A] such that B has a uniform histogram.

The gray value of a pixel can be represented by an integer v, 0 ≤ v ≤ 255.Let HI be a vector that represents the histogram count.

H[k] = Number of pixels with brightness level k

Let C[m] be the number of pixels whose brightness is in the range 0 ≤ v ≤m. Then

C[m] =m∑

k=0

H[k]

is a monotonically increasing function of m defined for 0 ≤ m ≤ 255 withC[0] = H[0] and C[255] = MN .

What does the vector C represent? What should it be for an image with auniform histogram?

DIP Lecture 5 10

Page 12: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Uniform Histogram Image

Suppose that an image has a uniform histogram, Hu. Then Hu[k] = b forsome number b.

If the image is of size N ×M then 256b = MN because every pixel musthave exactly one brightness. From this we find

b =MN

256

The cumulative sum for a uniform image must be

Cu[m] = (m + 1)b = (m + 1)MN

256

The slope of this function is the count b of pixels at each brightness. Thelast value is

Cu[255] = MN

DIP Lecture 5 11

Page 13: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Equalization Curve

Suppose that we have an image of size N ×M that we want to equalize.Let s = T [r] be the equalization curve.

Let the original image have a histogram vector Ho. For correspondingpoints r and s = T [r] we can equate the cumulative sums

r∑i=0

Ho[i] =s∑

j=0

Hu[j] =MN

256(s + 1) =

MN

256(T [r] + 1)

We can solve for

T [r] =256MN

r∑i=0

Ho[i]− 1 =256MN

Co[r]− 1

DIP Lecture 5 12

Page 14: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Equalization Program

The following IDL program will construct a transform s = T [r] that will dohistogram equalization on an image A.

A=Read Image(fname) ;Assume a byte array in file fname.ha=Histogram(A,MIN=0,MAX=255)ca=Total(ha,/cumulative) ;Do the cumulative sumT=BytScl(ca) ;Make into bytes in the range [0,255]B=T[A]; This is the equalized image.hb=Histogram(B,MIN=0,MAX=255); Check the histogramcb=Total(hb,/cumulative) ;Check the cumulative sum.

DIP Lecture 5 13

Page 15: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Histogram Equalization vs γ-Correction

Original Equalized γ = 0.5 γ = 0.7

DIP Lecture 5 14

Page 16: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Comparison of Transfer Functions

Comparison of transferFunction Curves

Original (solid) & Final(dashed) CumulativeHistograms

DIP Lecture 5 15

Page 17: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Example

Neither image is very useful. How can they be enhanced?

DIP Lecture 5 16

Page 18: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Example

The equalizer brings both images to a nearly identical brightness.

DIP Lecture 5 17

Page 19: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Image Subtraction

Image subtraction can be used to suppress background information andhighlight other information.

Procedure:

1. Capture a background image.

2. Capture a new image with some changed values.

3. Display the difference image (rescaled).

Applications: Medical imaging, motion detection, change detection

DIP Lecture 5 18

Page 20: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Image Subtraction

Image subtraction can be used to suppress background information andhighlight other information. The background image is taken first. Thena radiological contrast agent is injected into the bloodstream to form thesecond image. The difference image is on the right.

DIP Lecture 5 19

Page 21: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Enhancement of Color Images

How should a color image such as the one shown below be equalized?

Source: http://www.ee.siue.edu/~sumbaug/CVIPbook_PPLec/chapter%208b.ppt

DIP Lecture 5 20

Page 22: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Enhancement of Color Images

One technique would be to equalize each of the color planes independently.What artifacts could this create?

Red Channel Green Channel Blue Channel

DIP Lecture 5 21

Page 23: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Effect of Equalization of Color Planes

The effect produced by enhancing the color planes independently is shownbelow.

DIP Lecture 5 22

Page 24: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Equalization with one color plane

The image above has artifacts such as color shifts because the color mixturesare changed for almost all pixels.

The color mixtures can be maintained by an algorithm that:

• Does gray scale histogram on one of the bands

• Changes the other bands to maintain the mixture ratio in each pixel

The effect will depend upon the band that is chosen for equalization. It isreasonable to choose the band whose colors are the most important for theimage.

Results are shown on the next page.

DIP Lecture 5 23

Page 25: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Equalization with one color plane

The images below were created by equalizing different bands and maintainingthe color mixture by ratios with the other bands.

The results are variable. The band to be chosen would depend upon thedesired result.

Red Channel Green Channel Blue Channel

DIP Lecture 5 24

Page 26: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Equalization of Luminance

Equalization can be done in another color space such as HSV. The idea isto equalize the luminance while maintaining the hue and saturation valuesthe same.

Luminance (value) Luminance Equalized

DIP Lecture 5 25

Page 27: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Equalization of Luminance

DIP Lecture 5 26

Page 28: Lecture 5: Point Processing of Images · Basic Point Processing Point processing is used to transform an image by operating on individual pixels. If array A represents an input image

Color Equalization Comparison

Original RGB Equalized Independently Luminance Equalization

Single Band (R) Single Band (G) Single Band (B)

DIP Lecture 5 27