OBJECTIVES 1. Define histogram matching (histogram specification) 2. Sample application
Transcription
OBJECTIVES 1. Define histogram matching (histogram specification) 2. Sample application
Histogram Matching (Specification) OBJECTIVES 1. Define histogram matching (histogram specification) 2. Sample application 3. Derive formula in continuous domain 4. Convert to digital domain + example 1 Definition of Histogram Matching (Specification) A(x, y) - Input C(x, y) - Output Hc(DC) HA(DA) 0 2 255 DA 0 255 DC Histogram Matching (Specification) 3 PRIMARY USES • Improve display (contrast & brightness) • Preprocessing step for comparison of images COMPARISON TO EQUALIZATION • More general than histogram equalization since histogram of output image need not be flat only • Interactive enhancement technique user can draw desired histogram Example - Application We wish to check if a circuit board (image 1) matches the template (image 2) from which it was manufactured. Any defects? 1 - Manufactured 4 2 - Template Compute difference image (defined later), threshold by setting pixels with non-zero absolute difference to 1 and all other pixels to 0: Example - Application What if the overall brightness of image 1 is different from that of image 2? 1 - Manufactured 5 2 - Template Difference image is white everywhere because there is a difference in the brightness of all pixels. One solution would be to match the histograms of the two images and then do the subtraction. 255 DA 0 HB(DB) B(x, y) 255 DB 0 HC(DC) DB=f 2(DC) C(x, y) 255 DC (see match.doc) 0 HA(DA) A(x, y) DB=f1 (DA) DC=f (DA) Histogram Matching (Specification) 6 DERIVATION - CONTINUOUS Example – Continuous-tone Suppose you are given two X-ray films taken immediately before and after injection of a contrast medium (dye) into the arteries of a patient’s heart. Radiologists are studying the films to determine whether coronary bypass surgery or heart valve replacement is required. Normally they use digital image subtraction to visualize the dye as it fills the arterial passageways. In this case, however, problems in exposure and development of the two films make a direct comparison inconclusive. The patient is too weak to undergo the angiography procedure again. Only digital subtraction (Chapter 7) of the two images will reveal the extent of coronary disease. To a good approximation, the histograms of the two images are given by the Rayleigh distribution where Dm = 63, α = 16 for the first image, and α = 24 for the second image. What GST would: (a) flatten the histogram of the preinjection image? (b) flatten the histogram of the postinjection image? (c) make the histogram of the postinjection image match that of the preinjection image? You can assume continuous variables. [Question 8, Chapter 6 of textbook.] H ( D) = DDm α2 D2 exp − 2 2α 7 Example (cont’d) 8 Example (cont’d) 9 Example – Digital 10 Given a 3-bit gray-level image A(i, j) with the following histogram: DA 0 1 2 3 4 5 6 7 HA(DA) 1028 3544 5023 3201 1867 734 604 383 Design point operation to match it to the following histogram: DC 0 1 2 3 4 5 6 7 HC(DC) 0 0 1638 4096 4916 4096 1638 0 Example - Digital 11 1. Equalize the input image to get the intermediate image B(i, j): DA 0 1 2 3 4 5 6 7 HA(DA) 1028 3544 5023 3201 1867 734 604 383 DB 0 2 4 5 6 7 7 7 Can now find B(i, j) from A(i, j). 2. Find GST that would equalize the desired image C(i, j) if it were known: DC 0 1 2 3 4 5 6 7 HC(DC) 0 0 1638 4096 4916 4096 1638 0 DB 0 0 1 2 5 6 7 7 Example - Digital 12 Therefore, the GST DB = f(DC) that maps gray levels DC into DB is: DC 0 1 2 3 4 5 6 7 D B = f2 (D C ) 3. Calculate the inverse function DC = f -1(DB) that maps gray levels DB into DC: DB DC = f 2−1 ( DB ) 0 1 2 3 4 5 6 7 4. Examine image B(i, j) pixel-by-pixel, replacing each gray level DB by DC using the table in 3 above. Rules for Calculating Inverse • For unique pairs (DB, DC), it is easy to fill in a row of the table • If a DB value has more than one potential DC value associated with it, use the lower DC value • If a DB value does not appear in the table, use the closest DC value; if two or more DC values are equally close, use the smaller DC value 13 Example 14 >> D = 0:255; >> h = exp(-(D-50).^2/(2*16^2)) + exp(-(D-200).^2/(2*16^2)); >> im2 = histeq(im, h); original Desired histogram After Summary • Definition of histogram matching (specification) • Describe applications • Derivation and application of formula in continuous domain • Conversion to digital domain Should be able to do Homework 2. 15