Basic Effects Programming - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Basic Effects Programming

Description:

Raw monochrome image. Grey levels. Introduction. In C: unsigned char image[IM_HEIGHT][IM_WIDTH] ... by changing amplitude (brightness / colour) or position of ... – PowerPoint PPT presentation

Number of Views:25
Avg rating:3.0/5.0
Slides: 19
Provided by: claudecch
Category:

less

Transcript and Presenter's Notes

Title: Basic Effects Programming


1
Imaging and Special Effects CE00376-2
Fac. of Comp., Eng. Tech. Staffordshire
University
Basic Effects Programming
Dr. Claude C. Chibelushi
2
Outline
  • Introduction
  • Basic concepts
  • Grey-level transformations
  • Brightness shift, scaling
  • Geometric transformations
  • Image translation, cropping, scaling
  • Summary

3
Introduction
Other examples brightness adjustment, contrast
enhancement, noise removal, morphing
4
Introduction
Pixel (attributes position, amplitude)
5
Basic Concepts
  • Image transformation
  • Special effects involve transformation of whole,
    or part of, image
  • by changing amplitude (brightness / colour) or
    position of relevant pixels
  • amplitude transformation changes pixel amplitude
    (e.g. grey-level)
  • no change of pixel position e.g. image fading
  • geometric transformation moves pixel to another
    position
  • no change of pixel amplitude e.g. image rotation
  • Transformations of pixel amplitude and position
    can be combined
  • e.g. image morphing warping and fading

6
Basic Concepts
7
Basic Concepts
  • Spatial extent of operations
  • Point operations
  • each pixel is transformed in isolation
  • Neighbourhood operations
  • each pixel is transformed based on pixels in its
    immediate neighbourhood (often 3 x 3 region)
  • Global operations
  • each pixel is transformed based on overall
    characteristics of image

8
Basic Concepts
  • Spatial extent of operations
  • Examples
  • Point operations
  • grey-level negation
  • grey-level increase / decrease
  • Neighbourhood operations
  • filtering (e.g. for noise removal)
  • Global operations
  • thresholding (e.g. if threshold selection is
    based on histogram of whole image)
  • contrast enhancement (if based on whole image)

9
Basic Concepts
  • Raster scanning
  • Sequential traversal of image pixels arranged on
    2D grid
  • Example code raster scanning for copying image
  • note declarations and initialisations required
  • for (row 0 row lt IM_HEIGHT row)
  • for (col 0 col lt IM_WIDTH col)
  • trgtImagerowcol srcImagerowcol

10
Grey-Level Transformations
  • Grey-level shift
  • Pixel grey-level increase / decrease
  • changes amplitude of pixels to make image
    brighter or darker
  • Problem shift might introduce amplitude overflow
    / underflow
  • checks are needed

11
Grey-Level Transformations
  • Grey-level shift (increase or decrease)
  • for (row 0 row lt IM_HEIGHT row)
  • for (col 0 col lt IM_WIDTH col)
  • if (imagerowcol lt 255 - SHIFT)
  • if (imagerowcol gt - SHIFT)
  • imagerowcol SHIFT
  • else
  • imagerowcol 0 // underflow
  • else
  • imagerowcol 255 // overflow

Inefficient unnecessary repetition of calculation
12
Grey-Level Transformations
  • Grey-level scaling
  • Pixel grey-level scaling
  • changes amplitude of pixels to cover wider range
  • Problems scaling might introduce
  • amplitude overflow
  • checks are needed
  • side effect possible grey-level shift
  • lecture on contrast enhancement will give
    solution to this problem

13
Grey-Level Transformations
  • Grey-level scaling
  • for (row 0 row lt IM_HEIGHT row)
  • for (col 0 col lt IM_WIDTH col)
  • if (imagerowcol lt 255 / SCALE)
  • imagerowcol SCALE
  • else
  • imagerowcol 255

Inefficient
assumed to be positive
14
Geometric Transformations
  • Pixel position is specified by its row and column
    in image array
  • column corresponds to x axis
  • row corresponds to y axis
  • Typical transformations
  • translation, scaling, rotation
  • transformation matrices can be used

15
Geometric Transformations
  • Problems
  • Calculated pixel position might
  • be outside image bounds
  • solution array bounds checking
  • have non-integer coordinates
  • solution
  • coordinate rounding
  • or interpolation (averaging) of amplitude of
    nearest pixels

16
Geometric Transformations
  • Problems (ctd.)
  • Image magnification may introduce gaps in target
    image
  • solution
  • scan pixel position in target image
  • compute corresponding position in source image
  • apply inverse of desired transformation

17
Geometric Transformations
Image translation (positive or negative
offset) for (row 0 row lt IM_HEIGHT
row) for (col 0 col lt IM_WIDTH col)
srcRow row rowOffset // inverse
translation srcCol col colOffset if (
(srcRow gt 0 srcRow lt SRCIM_HEIGHT)
(srcCol gt 0 srcCol lt SRCIM_WIDTH)
) trgtImagerowcol srcImagesrcRowsrcCol
else trgtImagerowcol 255 //
arbitrary default
18
Geometric Transformations
  • Image cropping
  • for (row 0 row lt rectHeight row)
  • for (col 0 col lt rectWidth col)
  • trgtImagerowcol
  • srcImagerectTopRow rowrectLCol col

height of crop rectangle
left column of crop rectangle in source image
top row of crop rectangle in source image
Assumption crop rectangle fully within source
image
19
Geometric Transformations
Image scaling for (row 0 row lt IM_HEIGHT
row) for (col 0 col lt IM_WIDTH col)
srcRow row / rowScale // inverse
scaling srcCol col / colScale if (
(srcRow gt 0 srcRow lt SRCIM_HEIGHT)
(srcCol gt 0 srcCol lt SRCIM_WIDTH)
) trgtImagerowcol srcImagesrcRowsrcCol
else trgtImagerowcol 255 //
arbitrary default
Assumption positive scaling factors
20
Summary
  • Special effects based on transformations
  • point, neighbourhood, or global operations
  • transformation can change pixel amplitude or
    position
  • Variety of image transformations
  • examples of grey-level transformations
  • brightness shift, negation, scaling,
    quantisation, thresholding
  • examples of geometric transformations
  • image translation, cropping, scaling, rotation
Write a Comment
User Comments (0)
About PowerShow.com