38
Point Operations – Chapter 5

Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Embed Size (px)

Citation preview

Page 1: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Point Operations – Chapter 5

Page 2: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Definition

• Some of the things we do to an image involve performing the same operation on each and every pixel (point)– We apply some function f to all pixels

for all pixels

• If the function is independent of (u,v), the pixel coordinates, it is called homogeneous

)),((),(' vuIfvuI

Page 3: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Usage

• Image enhancement– Contrast, brightness

• Applying a look-up table (LUT)

• Changing the color space

• others

Page 4: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

The alternative

• If the function involves not only the current pixel value but also it’s location it is a nonhomogeneous operation

• These are good for local, adaptive processes

),),,((),(' vuvuIgvuI

Page 5: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Histogram

• All of these operations will modify the histogram!

Page 6: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Contrast enhancement

• This is basically a stretch (or compress – but not typically) of the histogram

• It’s nothing more than a multiplication

• but…remember you have to clamp to the intensity range

• a > 1 stretches the histogram,a < 1 compresses the histogram

),(),(' vuIavuI

Page 7: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Contrast enhancement

Page 8: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Contrast enhancement

Page 9: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Contrast enhancement

• Note the introduction of gaps (multiply) and spikes (divide) in the histogram– Bins are either vacated or combined

• Process is reversible except when pixels become saturated (dark or light)

Page 10: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Brightness enhancement

• This is basically a shift (left or right) of the histogram

• It’s nothing more than an addition

• but…remember you have to clamp to the intensity range

• a > 0 shifts the histogram right, a < 0 shifts the histogram left

),(),(' vuIavuI

Page 11: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Brightness enhancement

Page 12: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Brightness enhancement

Page 13: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Brightness enhancement

• Histogram will retain it’s original shape (no gaps or spikes) except when pixels become saturated (dark or light)

• Process is reversible except when pixels become saturated (dark or light)

• Operation is linear until clamping comes into play

Page 14: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Auto-contrast enhance

• The operations are typically combined into a single operation called “auto-contrast enhancement”

• Recall the definition of contrast is the “effective used of histogram bins”

• To utilize bins to the left of the original distribution a subtraction is performed

• To utilized bins to the right of the original distribution a multiplication is performed

IIIIIIlowhigh

lowvuIvuI

minmaxmin

)),((),('

Page 15: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Auto-contrast enhance

• Imin is typically 0

• Imax is the maximum range (e.g. 255 for an 8-bit image)

• Ilow is the lowest value of the actual distribution

• Ihigh is the largest value of the actual distribution

IIIIIIlowhigh

lowvuIvuI

minmaxmin

)),((),('

Page 16: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Contrast/Brightness enhance

Page 17: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Auto-contrast enhance

• In a typical image (e.g. the snake) there may be only a few pixels at Ilow and Ihigh so the enhancement is not “dramatic” (or even noticeable)

IIIIIIlowhigh

lowvuIvuI

minmaxmin

)),((),('

Page 18: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Auto-contrast enhance

• The solution is to not use the actual min and max values but to specify them instead

• This is typically done by specifying some percentage of pixels to saturate at the dark (low) and light (high) ends of the histogram

Page 19: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Contrast/Brightness enhance

Page 20: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Contrast and brightness• Note that in all the previous point

operations histogram bins may be combined but a single bin is never split

Page 21: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

ImageJ

• Process->Math->Add or Subtract – Brightness• Process->Math->Multiply or Divide – Contrast• Process->Enhance Contrast

– Set the % of saturated pixels – the system will try to evenly distribute the percentage to the dark and light ends of the histogram

– Check Normalize to actually modify the pixel values (otherwise only the display is modified)

• If you don’t check Normalize the histogram will not change

Page 22: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Histogram Equalization

• Recall the smooth gradient image that I showed previously

Page 23: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Histogram Equalization

• Aside from the good contrast, dynamic range, exposure, etc. another interesting point is the shape of the histogram and cumulative histogram

• The histogram is uniform (intensities form a uniform distribution)

• The cumulative histogram is a linear ramp

Page 24: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Histogram Equalization

• One theory is that converting the histogram of any image to an approximately uniform histogram will create a good picture

• “approximately” because we can’t always get “perfectly” uniform

• Why?– Because we can only merge bins, we cannot

split them

Page 25: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Histogram Equalization

• Without going through the derivation (which is about 3 pages in another classic image processing book), the point operation to achieve the desired distribution is

• └ ┘is the floor operation (integer truncation)• MxN is the size of the image• K-1 is the largest possible intensity value

NM

KvuIHvuI

1)),((),('

Page 26: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Histogram Equalization

• Unfortunately, theory is not always correct

Page 27: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Histogram Equalization

• Note that the gaps in the histogram are not uniformly spaced• Note that the cumulative histogram is nearly perfectly uniform• Note that the resultant image looked really bad

Page 28: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Histogram specification• An alternative approach…

• Rather than go for the [arbitrarily chosen] uniform histogram, try to match the histogram to an given histogram

• But first, some definitions…

Page 29: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Normalized histogram

• Also known as the probability density function (probability distribution)

NM

ihip

)()(

Page 30: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Normalized cumulative histogram• Also known as the discrete distribution

function (cumulative distribution function)

i

j

jpNM

iHiP

0

)()(

)(

Page 31: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Histogram specification• The goal is to apply a point operation to

the image causing it’s cumulative distribution function (PA) to match a given cdf PR

• Again, without going through a long derivation

),(),('1

vuIvuI PP AR

Page 32: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Histogram specification

),(),('1

vuIvuI PP AR

PA(i)PR(i)

I(u,v)I’(u,v)

Page 33: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Histogram specification

Page 34: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Histogram specification

Page 35: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Histogram specification• The resulting cdf’s are of comparable shape

Page 36: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Histogram specification• The resulting images have a similar “look”

Page 37: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Histogram specification• And yet again, the resultant image looks

awful

• That’s because I matched two arbitrarily selected images– Normally you would use this on sets of

images of which you want to give the impression that the exposures were similar or were taken in similar lighting conditions

Page 38: Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We

Histogram specification• You have to watch the implementation

in the event that the reference histogram has bins with no pixels in them

• The book gives those details if you’re interested