June 14, 99 - PowerPoint PPT Presentation

1 / 37
About This Presentation
Title:

June 14, 99

Description:

Formation of colors on video monitors is through an ... SUBTRACTIVE COLOR MODEL. Color formation in printing industry is through the subtractive CMY model ... – PowerPoint PPT presentation

Number of Views:56
Avg rating:3.0/5.0
Slides: 38
Provided by: BijanMo3
Category:
Tags: june | subtractive

less

Transcript and Presenter's Notes

Title: June 14, 99


1
June 14, 99
  • COLORS
  • IN
  • MATLAB

2
UNDERSTANDING COLOR
  • To understand color we must first understand
    color spaces
  • We come in contact with color through
  • Video(computers,TVs)
  • Printed matter(magazines, brochures)
  • Real World

3
ADDITIVE COLOR MODEL
  • Formation of colors on video monitors is through
    an additive process of 3 color components
  • Red
  • Green
  • Blue
  • Concern is white balance, meaning how white is
    the white displayed on the monitor

Colorw1redw2greenw3blue
4
RGB COLOR CUBE
Cyan
Green
White
1
Yellow
Color is represented by a point in the RGB cube
Blue
1
1
Red
Magenta
5
RGB CUBE
6
SUBTRACTIVE COLOR MODEL
  • Color formation in printing industry is through
    the subtractive CMY model
  • Cyan
  • Magenta
  • Yellow
  • Challenge is black balanceto get real black
  • Often black is added as the 4th color, CMYK

7
HUMAN COLOR MODEL
  • The most accurate model here is hue, saturation
    and value(brightness) HSV

white
brightness
saturation
green
red
blue
hue
black
8
NET REFERENCE ON COLOR
  • There is a comprehensive FAQ on color. You can
    reach it at
  • http//www.inforamp.net/poynton/Poynton-colour.ht
    ml

9
UNDERSTANDING COLORMAPS
  • At the heart of color control in MATLAB is the
    concept of colormap
  • Colormap is a 3-column matrix with entries
    between 0 and 1. Each row defines a particular
    combination of (R,G,B) to define a color.

black
0
0
0
1
0
1
magenta
10
FEW MATLABs COLORMAPS
Image intensity maps to color
11
Try it!
  • MATLAB comes with few images. To load one of them
    type
  • load clown
  • Now check your workspace. You will see image data
    stored in X and colormap stored in map
  • To display the image type
  • image(X)
  • Whats wrong?

12
Digital image
  • Before going on, lets define a digital image.
  • A digital image is simply a 2D matrix. Each
    element of the matrix, pixel, is an integer. For
    a black and white image pixels are between 0
    (black) and 255(white)
  • MATLABs matrix oriented structure makes minced
    meat out of images and image processing

13
Role of colormap
  • Type out a few values of X. You will see
    integers. But what is the relationship between
    these numbers and their actual color?
  • Enter colormap. Colormap is lookup table. It
    takes an intensity value, say 25, and connects it
    with some color.
  • To display true colors, you must set monitors
    colormap to the map used at the time the image
    was created

14
WORKING WITH COLORMAPS
  • Command colormap(map) sets the colormap to one of
    preset or user defined values
  • For clown image ,type colormap(map) and watch the
    result.
  • Now try these
  • colormap(hot)
  • colormap(hsv)
  • colormap(gray)

15
RECALLING AND SETTING COLORMAPS
  • Current colormap in effect can be found by
  • mapcolormap
  • Any (3x1) matrix can be defined by the user and
    defined as the current colormap by
  • colormap(usermap)

16
COLOR ASSIGNMENT
  • How is intensity connected to color?

last row
highest
Colormap
Data Values
maps to
lowest
first row
17
COLOR MAPPING RULE
  • Let data range between Zmin and Zmax. Let the
    colormap rows k run from 1 to m.
  • Then
  • Zmin k1, row 1
  • Zmax km, row m
  • The middle Zs follow a linear mapping rule.

18
Defining your first colormap
  • Plot the peaks function using
  • surf(peaks)
  • Define a colormap, mymap, so that the first row
    is blue, the second row is green, third row is
    white and fourth row red.
  • Then set MATLABs colormap to mymap. See code next

19
Try it!
  • Interpret colors you see

20
ARBITRARY COLOR ASSIGNMENT
  • Color mapping rule is simple
  • take the minimum of the function and assign it
    the color of the first row of colormap
  • take the maximum of the function and assign it
    the color of last row of colormap
  • in-between values take shades of color obtained
    by a linear mapping of the above two colors
  • Next slide shows you more

21
ASSIGNING COLORS TO RANGES OF DATA
  • This is what we want to do
  • assign blue to zlta
  • assign red to zgtb
  • assign a continuous color tone(blue to red) for
    altzltb

b
Z
a
22
How to do it? clim property
  • clim is a two element vector cmin,cmax. It can
    be set as follows
  • set(gca, clim,cmin cmax)
  • Colormapping is done as follows
  • zltcmin ----gtfirst row of colormap
  • zgtcmax ----gtlast row of colormap

23
Try it!
  • Plot the peaks function and display it with
    view(90,0)
  • Set cmin and cmax to -2 2,-3 3 and -4 4 and
    see if you can explain the results?

24
MATLABS DEFAULT COLORMAP
  • MATLABs default colormap is HSV and can be set
    via
  • colormap(default) or colormap(hsv)
  • Unless specified otherwise, colormaps are 64x3,
    i.e. 64 colors
  • Other sizes can be specified, e.g.
  • colormap(hot(128))

25
Try it!
  • Plot the peaks function in the range(-40.24)
    and v90,0. Go through hsv, hot, flag, copper
    etc. colormaps. Check maps sizes

?
26
DEFINING YOUR OWN COLORMAP
  • Want to display the peaks profile in only two
    colors. Negative values in red and positive
    values blue. Define a colormap for this purpose.

27
Pseudorandom color pcolor
  • Command pcolor(z) draws a rectangular grid of
    cells with colors determined by z function
    height above each cell. Mapping from z to color
    is determined by colormap

28
OVERLAYING CONTOURS
  • Do the following
  • get rid of the grid lines(try shading command)
  • Superimpose black colored gridlines(lookup help
    on contour)

29
pcolor and colormap
  • The following will display 32 bins of current
    colormap
  • z132132
  • pcolor(z)

30
WORKING WITH IMAGES
  • A two dimensional image can be modeled by
    zf(x,y) where (x,y) is the pixel position and z
    the corresponding height
  • The height is then mapped to either a grayscale
    or color range

31
LOADING IMAGES
  • Images are loaded like sound file. For example
  • load clown
  • Now check your workspace to see which variable is
    clown loaded in.
  • Check the size of the image array and its min and
    max

32
DISPLAYING IMAGES
  • There are a number of ways to display an image.
    For the start use
  • image(z)
  • z is the array your image is loaded in. Check
  • Each element of z specifies the color of a
    rectangular patch in the image
  • Elements of z are used as indices into the
    current colormap to determine the color

33
INDEXED IMAGES
  • MATLAB supports a number of image formats one of
    which is indexed
  • intensities in indexed images are not really
    intensities they are simply entries into the
    colormap
  • If image value at (x,y)32, this simply means
    that pixel color at (x,y) comes from the row 32
    of the colormap

34
Example of indexed image clown
  • When you loaded clown you got two arrays
  • X image data
  • mapcolormap
  • Now check image value at position (100,100). I
    get 4. What color is this pixel?. MATLAB goes to
    the 4th row of map
  • This row has 3 columns, red0.29, green0 and
    blue0

35
How to display the color of a single pixel?
  • In the previous slide we found out that
    X(100,100) has no green or blue component and is
    29red. But what color is it?
  • Here is a way to do get it. Type
  • image(X(100,100))
  • Is it what you expect?. Is it reddish?

36
PLAYING WITH COLORMAPS
  • Unless a digital image is accompanied by a
    colormap, it is impossible to determine pixel
    colors
  • Check the colormap that accompanies the loaded
    image its size and its contents.
  • Change the colormaps to hot, hsv, cool, gray and
    see the results

37
HOMEWORK
  • Plot zsin(sqrt(x2y2)) in the range(-pi to
    pi)in increments of 0.2
  • Make the function appear red for zlt-0.5, white
    for -0.5ltzlt0.5 and blue for zgt0.5
  • Do the same except for making the colors between
    red and white follow 32 gradations of colormap hot
Write a Comment
User Comments (0)
About PowerShow.com