histograms- hpp. what is homogeneous? homogeneous point process treats all pixels the same....
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/1.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/2.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/3.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/4.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/5.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/6.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/7.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/8.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/9.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/10.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/11.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/12.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/13.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/14.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/15.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/16.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/17.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/18.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/19.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/20.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/21.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/22.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/23.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/24.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/25.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/26.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/27.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/28.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/29.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/30.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/31.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/32.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/33.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/34.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/35.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/36.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/37.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/38.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/39.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/40.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/41.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/42.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/43.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/44.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/45.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/46.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/47.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/48.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/49.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/50.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022070406/56649e0c5503460f94af4d97/html5/thumbnails/51.jpg)
LUT Implementation
package gui; public class TransformTable { public TransformTable(int size) public short[] getLut() public void setLut(short lut[]) public void print() }