Lecture 9 Grey Level & Colour Enhancement TK3813 Dr. Masri Ayob.

Slides:



Advertisements
Similar presentations
Types of Image Enhancements in spatial domain
Advertisements

Point Processing Histograms. Histogram Equalization Histogram equalization is a powerful point processing enhancement technique that seeks to optimize.
Digital Images in Java Java’s imaging classes. Java imaging library  Java has good support for image processing  Must master a handful of classes and.
Continuing to very Powerful Rendering Model Java2D.
Digital Image Processing
Image Data Representations and Standards
Grey Level Enhancement Contrast stretching Linear mapping Non-linear mapping Efficient implementation of mapping algorithms Design of classes to support.
Image Processing Lecture 4
Chapter - 2 IMAGE ENHANCEMENT
Digital Imaging and Image Analysis
Topic 4 - Image Mapping - I DIGITAL IMAGING Course 3624 Department of Physics and Astronomy Professor Bob Warwick.
EE4H, M.Sc Computer Vision Dr. Mike Spann
EE663 Image Processing Histogram Equalization Dr. Samir H. Abdul-Jauwad Electrical Engineering Department King Fahd University of Petroleum & Minerals.
6. Gray level enhancement Some of the simplest, yet most useful, image processing operations involve the adjustment of brightness, contrast or colour in.
Image (and Video) Coding and Processing Lecture 5: Point Operations Wade Trappe.
Intensity Transformations
Image Processing IB Paper 8 – Part A Ognjen Arandjelović Ognjen Arandjelović
Chapter 4: Image Enhancement
BYST Eh-1 DIP - WS2002: Enhancement in the Spatial Domain Digital Image Processing Bundit Thipakorn, Ph.D. Computer Engineering Department Image Enhancement.
Image Enhancement by Modifying Gray Scale of Individual Pixels
Multimedia Data Introduction to Image Processing Dr Mike Spann Electronic, Electrical and Computer.
DREAM PLAN IDEA IMPLEMENTATION Introduction to Image Processing Dr. Kourosh Kiani
Image Enhancement To process an image so that the result is more suitable than the original image for a specific application. Spatial domain methods and.
CS443: Digital Imaging and Multimedia Point Operations on Digital Images Spring 2008 Ahmed Elgammal Dept. of Computer Science Rutgers University Spring.
Multimedia Data Introduction to Image Processing Dr Mike Spann Electronic, Electrical and Computer.
Image Enhancement in the Spatial Domain (chapter 3) Math 5467, Spring 2008 Most slides stolen from Gonzalez & Woods, Steve Seitz and Alexei Efros.
Image Enhancement.
Digital Image Processing
Computer Vision Lecture 3: Digital Images
Digital Image Characteristic
Spectral contrast enhancement
Point Processing Point by Point by Point. Taxonomy  Images can be represented in two domains  Spatial Domain: Represents light intensity at locations.
University of Ioannina - Department of Computer Science Intensity Transformations (Point Processing) Christophoros Nikou Digital Image.
The Digital Image Dr. John Ryan.
Remote Sensing and Image Processing: 2 Dr. Hassan J. Eghbali.
Seeram Chapter #3: Digital Imaging
CS6825: Point Processing Contents – not complete What is point processing? What is point processing? Altering/TRANSFORMING the image at a pixel only.
Multimedia Data Introduction to Image Processing Dr Sandra I. Woolley Electronic, Electrical.
September 5, 2013Computer Vision Lecture 2: Digital Images 1 Computer Vision A simple two-stage model of computer vision: Image processing Scene analysis.
EE663 Image Processing Dr. Samir H. Abdul-Jauwad Electrical Engineering Department King Fahd University of Petroleum & Minerals.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Chapter 2: Color Basics. 2 What is light?  EM wave, radiation  Visible light has a spectrum wavelength from 400 – 780 nm.  Light can be composed.
Intensity Transformations or Translation in Spatial Domain.
Digital Image Processing Lecture9: Intensity (Gray-level) Transformation Functions using MATLAB.
Lecture 7: Intro to Computer Graphics. Remember…… DIGITAL - Digital means discrete. DIGITAL - Digital means discrete. Digital representation is comprised.
The Reason Tone Curves Are The Way They Are. Tone Curves in a common imaging chain.
Digital Image Processing EEE415 Lecture 3
More digital reading explaining LUT RT 244 Perry Sprawls, Ph.D. Professor Emeritus Department of Radiology Emory University School of.
Digital Image Processing CSC331 Image Enhancement 1.
Lecture Reading  3.1 Background  3.2 Some Basic Gray Level Transformations Some Basic Gray Level Transformations  Image Negatives  Log.
More digital 244 wk 12 Perry Sprawls, Ph.D. Professor Emeritus Department of Radiology Emory University School of Medicine Atlanta, GA,
Digital Image Processing Image Enhancement in Spatial Domain
Image: Susanne Rafelski, Marshall lab Introduction to Digital Image Analysis Part I: Digital Images Kurt Thorn NIC UCSF.
Introduction to Digital Image Analysis Kurt Thorn NIC.
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
Point Processing When doing so you actually perform a special type of image processing known as point processing.
Chapter 10 Digital Signal and Image Processing
Digital Image Processing
Video System TTFs Part (I): Basic Design Strategy.
Image Enhancement.
Intensity Transformations and Spatial Filtering
Computer Vision Lecture 3: Digital Images
Image Enhancement in the Spatial Domain
Introduction to Digital Image Analysis Part I: Digital Images
Digital Image Processing
Grey Level Enhancement
IT523 Digital Image Processing
IT523 Digital Image Processing
Histogram The histogram of an image is a plot of the gray _levels values versus the number of pixels at that value. A histogram appears as a graph with.
Presentation transcript:

Lecture 9 Grey Level & Colour Enhancement TK3813 Dr. Masri Ayob

2 Point Processing Operations Point processing involves the transformation of individual pixels independently of other pixels in the image. These simple operations are typically used to correct for defects in image acquisition hardware. For example, to compensate for under/over exposed images. The process of modifying pixel grey level and colour are sometimes referred to as ‘point processing operation’.

3 The common operations involve the adjustment of brightness, contrast or colour in an image. A common reason for manipulating these attribute is the need to compensate for difficulties in image acquisition. E.g. Image where an object of interest is backlit (illuminated from behind). Without the aid of image processing, we might need to reacquire the image several time. With image processing, we can reveal enough detail to allow proper interpretation. Point Processing Operations

4 We can adjust the overall brightness of a grayscale simply by adding a constant bias, b, to pixel values: g(x,y) = f(x,y) + b If b > 0 the image is made brighter else the image is darkened. b is known as “bias” Linear Mapping (6.1)

5 Linear Mapping We can adjust contrast in a greyscale image through multiplication of pixel values by a constant gain, a: g(x,y) = a * f(x,y) If a > 1 the image is made brighter else the image is darkened. a is known as “gain” (6.2)

6 Examples

7 Examples

8 Examples gain = +1.5gain = -2.0

9 Linear Mapping These mappings can be combined to yield a linear mapping of f to g given as: g(x,y) = a*f(x,y) + b Typically don’t want to specify gain and bias but think in terms of mapping a range of values [f1..f2] onto a different range of values [g1, g2]. The following equation shows how to represent the linear mapping using range information only: General expression for brightness and contrast (6.3) (6.4)

10 Linear Mapping

11 Examples Linear Mapping G1 = 0, G2 = 255, F1 = 75, F2 = 185 Gain = 2.3, Bias =

12 Examples Inverse mapping G1 = 255, G2 = 0, F1 = 0, F2 = 255 Gain = -1, Bias = 255

13 Examples Bilevel Threshold Mapping G1 = 0, G2 = 255, F1 = 127, F2 = 128 Gain = 255, Bias =

14 Linear Contrast Stretching A linear mapping that enhances the contrast of an image without removing any detail. Spreads the visual information available across a greater range of gray scale intensities

15 Linear Contrast Stretching Example Notice that the left image appears washed-out (most of the intensities are in a narrow band due to poor contrast). The right image maps those values to the full available dynamic range.

16 Linear Contrast Stretching Implement equation 6.3 Implement equation 6.4

17 Java Code Interface BufferedImageOp All Known Implementing Classes: AffineTransformOp, ColorConvertOp, ConvolveOp, LookupOp, RescaleOp public interface BufferedImageOp This interface describes single-input/single-output operations performed on BufferedImage objects. It is implemented by AffineTransformOp, ConvolveOp, ColorConvertOp, RescaleOp, and LookupOp. These objects can be passed into a BufferedImageFilter to operate on a BufferedImage in the ImageProducer-ImageFilter-ImageConsumer paradigm. Classes that implement this interface must specify whether or not they allow in-place filtering- filter operations where the source object is equal to the destination object. This interface cannot be used to describe more sophisticated operations such as those that take multiple sources. Note that this restriction also means that the values of the destination pixels prior to the operation are not used as input to the filter operation. BufferedImageOpWithWritableVirtualR asterSamplesType_USHORT_RGBA??

18 Java Code public static BufferedImage rescale(BufferedImage image, float gain, float bias) { RescaleOp rescaleOp = new RescaleOp(gain, bias, null); return rescaleOp.filter(image, null); } Constructor Summary RescaleOp(float[] scaleFactors, float[] offsets, RenderingHints hints) Constructs a new RescaleOp with the desired scale factors and offsets. Assumes a color image with differing gain and bias values for each band. RescaleOp(float scaleFactor, float offset, RenderingHints hints) Constructs a new RescaleOp with the desired scale factor and offset.

19 Java Code public static BufferedImage rescale(BufferedImage image, float gain, float bias) { RescaleOp rescaleOp = new RescaleOp(gain, bias, null); return rescaleOp.filter(image, null); } public final BufferedImage filter(BufferedImage src, BufferedImage dst) Rescales the source BufferedImage. If the color model in the source image is not the same as that in the destination image, the pixels will be converted in the destination. If the destination image is null, a BufferedImage will be created with the source ColorModel. An IllegalArgumentException may be thrown if the number of scaling factors/offsets in this object does not meet the restrictions stated in the class comments above, or if the source image has an IndexColorModel. Specified by: filter in interface BufferedImageOp Parameters: src - the BufferedImage to be filtered dst - the destination for the filtering operation or null. If src = dst then the algorithm performs in- place. Returns: the filtered BufferedImage.

20 Non-Linear Mapping A grayscale image f(x,y) can be transformed into image g(x,y) using various non-linear mappings. Require any mapping to be true a function. For any pixel f(x,y), T(x,y) results in a unique deterministic value. Common non-linear gray-scale mappings include log compression: enhances the contrast of darker areas exponential mapping: enhances the contrast of brighter areas

21 Log Compression Log compression takes a range of values and “boosts” the lower end. Notice that the higher end is “compressed” into a small range of output values. Logarithmic mapping is useful if we wish to enhance detail in the darker regions of the image, at the expense of detail in the brighter regions.

22 Log Compression Example Notice how the darker areas appear brighter and contain more easily viewed details. The brighter areas loose some detail but remain largely unchanged.

23 Log Compression Example

24 Exponential Mapping Exponential Mapping takes a range of values and “boosts” the upper end. Notice that the lower range is “compressed” into a small range of output values. Exponential mapping is useful if we wish to enhance detail in the brighter regions of the image.

25 Exponential Mapping Example Notice how the brighter areas contain more detail in the filtered image. The darker areas loose some detail (are compressed) in this example.

26 Gamma Correction Computer monitors and TVs aren’t linear in the way they process signals A “doubling” of the control voltage on a CRT doesn’t usually result in a “doubling” of the intensity of the output color Monitors function according to a “power-law” function Uncorrected monitors may display images that don’t correspond to the original

27 Gamma Correction System Gamma

28 Gamma Correction Each CRT has its own  value that the manafacturer provides with CRT. Typically   [2,3]

29 Gamma correction Cathode ray tube (CRT) devices have an intensity- to-voltage response that is a power function, with  varying from 1.8 to 2.5 The picture will become darker. Gamma correction is done by preprocessing the image before inputting it to the monitor.

30 Gamma Correction

31 Gamma Correction

32 Gamma Example (TV Broadcast) Broadcast System

33 Gamma Example (Computer Monitor) Digital/Synthetic Image

34 Gamma Correction output = input 1/  Most video cards have a gamma correction setting

35 Gamma Correction  If a display is gamma corrected, the nonlinear relationship between pixel value (the number assigned to a particular color tone) and displayed intensity (the way it actually looks) has been adjusted for.  Most graphics cards/monitors have gamma settings  Values typically range from [usually 2.2]  PCs typically have higher gamma settings than Macs so images typically look darker on PCs than Macs

36 Gamma Correction If  = 1.0, the result is null transform. If 0    1.0, then the  creates exponential curves that dim an image. If   1.0, then the result is logarithmic curves that brighten an image. RGB monitors have gamma values of 1.4 to 2.8.

37 Gamma Chart

38 Gamma Correction (a)Gamma correction transformation with gamma = 0.45; (b)Gamma corrected image; (c)Gamma correction transformation with gamma = 2.2; (d)Gamma corrected image

39 Gamma Correction

40 Effect of decreasing gamma When the  is reduced too much, the image begins to reduce contrast to the point where the image started to have very slight “wash-out” look, especially in the background

41 Another example (a) image has a washed-out appearance, it needs a compression of gray levels  needs  > 1 (b) result after power-law transformation with  = 3.0 (suitable) (c) transformation with  = 4.0 (suitable) (d) transformation with  = 5.0 (high contrast, the image has areas that are too dark, some detail is lost) ab cd

42 Code Efficiency for Point Processing Operations The algorithm above invokes a square-root function (a relatively expensive operation) and a multiplication for each pixel in F. The algorithm is O(NM) where the input image is NxM. Can this performance be improved? Yes…use lookup-tables! algorithm squareRootFilter(F) INPUT: Gray-scale image F using b bits per pixel OUTPUT: Filtered image Let A be the scaling factor = squareRoot(2^b – 1) Let G be an “empty” image for all pixel coordinates X and Y of the input image G(X,Y) = a * squareRoot(F(X,Y)) return G

43 Java Is Fun and Easy! Java has a built-in lookup-table class named ByteLookupTable. Lookup tables can be used in conjunction with LookupOp objects to apply simple point processing operations to images. BufferedImage image; … byte[] table = new byte[256]; double factor = Math.sqrt(255); for(int i=0; i<table.length; i++) { table[i] = (byte)clamp(Math.sqrt(i) * factor); } ByteLookupTable squareRootTable = new ByteLookupTable(0, table); LookupOp squareRootOp = new LookupOp(squareRootTable, null); BufferedImage filteredImage = squareRootOp.filter(image, null);

44 Java Is Fun and Easy! java.awt.image Class ByteLookupTable public class ByteLookupTable extends LookupTable This class defines a lookup table object. The output of a lookup operation using an object of this class is interpreted as an unsigned byte quantity. The lookup table contains byte data arrays for one or more bands (or components) of an image, and it contains an offset which will be subtracted from the input values before indexing the arrays. This allows an array smaller than the native data size to be provided for a constrained input. If there is only one array in the lookup table, it will be applied to all bands.

45 Java Is Fun and Easy! LookupOp Class Description This class implements a lookup operation from the source to the destination. The LookupTable object may contain a single array or multiple arrays, subject to the restrictions below. For Rasters, the lookup operates on bands. The number of lookup arrays may be one, in which case the same array is applied to all bands, or it must equal the number of Source Raster bands. For BufferedImages, the lookup operates on color and alpha components. The number of lookup arrays may be one, in which case the same array is applied to all color (but not alpha) components. Otherwise, the number of lookup arrays may equal the number of Source color components, in which case no lookup of the alpha component (if present) is performed. If neither of these cases apply, the number of lookup arrays must equal the number of Source color components plus alpha components, in which case lookup is performed for all color and alpha components. This allows non-uniform rescaling of multi- band BufferedImages. ByteLookupTable squareRootTable = new ByteLookupTable(0, table); LookupOp squareRootOp = new LookupOp(squareRootTable, null); BufferedImage filteredImage = squareRootOp.filter(image, null);

46 Java Is Fun and Easy

47 Thank you Q & A