histograms- hpp. what is homogeneous? homogeneous point process treats all pixels the same....

51
Histograms- HPP

Upload: wilfred-bailey

Post on 11-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Histograms-

HPP

Page 2: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

What is homogeneous?

• Homogeneous point process treats all pixels the same.

• p'=f(p); // homogeneous point processing does not care about pixel location.

• isomorphic pixel mapping.

Page 3: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Homogeneous Point Processing

• Every point is treated the same

• Input size of image is same as output size

• Good application of statistics!

• input image shape is the same as the output image shape.

Page 4: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Image processing• An image processing operation typically

defines a new image g in terms of an existing image f.

Page 5: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

You need a function!

• A function has a single possible output value for any unique input value.

• A relation can have two outputs for a given input.

• For example x**2+y**2=r**2 is a relation.

• y=sqrt(x*x+r*r); //take only the + part and you have a function.

Page 6: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Mapping a pixel has many applications

• Brightening an image

• Improving the contrast

• Coloring the image.

• histogram equalization

• converting to a new color space.

Page 7: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

How do we implements HPP?

• Standards for HPP base on an INTERFACE.

• The standardization of the filter into interface allows for polymorphism.

Page 8: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Point Processing

• The simplest kind of range transformations are these independent of position x,y:

• g = t(f)

Page 9: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

How do we form such an interface?

• java.awt has RGBImageFilter interface

• It requires that you implement

public int filterRGB(int x, int y, int rgb);

1. Unpack the rgb int

2. Do the HPP

3. repack the int and return the value.

Page 10: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

How do we unpack our RGB ints?

let RGB=0x7FDEAD50

int a = rgb &0xFF000000>>24;

int r = rgb &0x00FF0000 >>16;

int g = rgb &0x0000FF00 >> 8;

int b = rgb &0x000000FF;

int r1 = getRed(r,g,b);int g1=getGreen(r,g,b);

int b1 = getBlue(r,g,b);

return 0xFF000000 | (r1 << 16) | (g1<<8) | b1;

Page 11: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Adapter Pattern

• Adapter Pattern take one interface and maps to a new interface.

• public interface HppFilterInterface {

• public short getR(int r);

• public short getG(int g);

• public short getB(int b);

• }

Page 12: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

InvertFilter

• public class InvertFilter• implements HppFilterInterface {• public short getR(int r) {• return invert(r);• }

• public short getG(int g) {• return invert(g);• }

• public short getB(int b) {• return invert(b);• }

Page 13: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Invert

• private short invert(int v) {

• if (v < 0) return 0;

• if (v > 255) return 255;

• return (short) (255 - v);

• }

Page 14: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Two kinds of methods for altering an image

• The direct methods

• The indirect methods.

• The direct methods employ a mapping function,

• Mapping functions are applied to the color planes.

Page 15: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Two kinds of methods for altering an image

• First we do the direct methods….

Page 16: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

PMF

• Add the total number of pixels of a particular value

• Divide by the total number of pixelsValuePMF

0 32/64128 16/64255 16/64

Page 17: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Rules of Prob.

• Sum of all probs=1

• CMF is sum of all values up to a point.

ValuePMF CMF0 32/64 0.5

128 16/64 0.75255 16/64 1

PV(a)

Page 18: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

In Prob…Cont vs. Discrete

• PMF – discrete but PDF are Continuous

• CMF – discrete by CDF are continuous

• Example: Toss a coin – discrete

• Example: Temp. Time, space

• CMF uses a discrete summation (for-loop)

• CDF uses an integral

• discrete means quantized

Page 19: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Histogram Computations

histArray = new double[256]; for (int i=0; i<width; i++) for (int j=0; j < height; j++) histArray[plane[i][j] & 0xFF]++;// what happens if you have 24 bit color images?

Page 20: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Normalization of PMF

double max = 0.0; for(int i=0; i<256; i++) if (histArray[i] > max) max = histArray[i]; // Normalize for(int i=0; i<256; i++) histArray[i] = (histArray[i] / max);

Page 21: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

The Histogram of the Image

Page 22: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Summary of Histogram

package gui; public class Histogram extends ClosableFrame { public double[] getPMF() public double[] getCMF() public void printPMF() public void show() public Histogram(short plane[][], String title) public void paint(Graphics g) }

Page 23: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Linear Map and Sample Image

Page 24: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

LUT implementation

• In theory, lut is easy:– outputColor = f(inputColor)– F(x) is an lut.– What happens if x ranges from 0 to 2**24?

Page 25: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Negating an Image

Page 26: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Implementation

private short invert(int v) { if (v < 0) return 0; if (v > 255) return 255; return (short) (255 - v); }

Page 27: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

HppFilterInterface

• public short getR(int r);

• public short getG(int g);

• public short getB(int b);

Page 28: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

What is thresholding?

• Requanitze an image.

• for example:– given an image with 256 grays– find an image with only 2 grays

• How do I know which pixels are black and which are white?– if (v < thresh) v = 0, else v = 255;

Page 29: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Two kinds of methods for altering an image

• The direct methods

• The indirect methods.

• The direct methods employ a mapping function,

• Mapping functions are applied to the color planes.

Page 30: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Indirect Methods

• The indirect method use statistical properties

Two Kinds of Indirect Methods:

• adaptive and nonadaptive

Page 31: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Basic Point Processing

Page 32: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Computing Averages

r 1N

rii1

N

getRBar ();

g 1

Ngi

i1

N

getGBar ();

b 1

Nbi

i1

N

getBBar ();

Page 33: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Image Enhancement

Page 34: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Contrast Streching

Page 35: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Power law and image processing

f (vij ) 255vij

255

pow

Page 36: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

1.5 exponent=darkening

Page 37: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Power-law transformations

Page 38: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Gamma Correction

Page 39: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Washed out images can result

Page 40: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Changing Brightness and Contrast

vij' cv ij b

c contrast

b brightness

Page 41: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Linear eq and histogramLUT

-50

0

50

100

150

200

250

300

0

19 38 57 76 95 114

133

152

171

190

209

228

247

Page 42: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Brightening and image

Page 43: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Computing parameters automatically

D Dmax Dmin

where

Dmin minumum value that can be displayed and

Dmax maximum value that can be displayed

Page 44: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Darkening Image

Page 45: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Darkening and the Histogram

Page 46: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Implementing the power xform

public void powImage(double p) { for (int x=0; x < width; x++) for (int y=0; y < height; y++) { r[x][y] = (short) (255 * Math.pow((r[x][y]/255.0),p)); g[x][y] = (short) (255 * Math.pow((g[x][y]/255.0),p)); b[x][y] = (short) (255 * Math.pow((b[x][y]/255.0),p)); } short2Image();}

Page 47: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

UNAHE

Page 48: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

The CMF

0

50

100

150

200

2500 50

100

150

200

250

Page 49: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Adaptive Equalization

Page 50: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

Histogram an AUHE

Page 51: Histograms- HPP. What is homogeneous? Homogeneous point process treats all pixels the same. p'=f(p); // homogeneous point processing does not care about

LUT Implementation

package gui; public class TransformTable { public TransformTable(int size) public short[] getLut() public void setLut(short lut[]) public void print() }