CZ1102 Computing & Problem Solving Lecture 11

Embed Size (px)

Citation preview

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    1/28

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    2/28

    Imageand

    pictures

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    3/28

    Digitalimage

    processing

    Imageprocessingistochangethenatureof

    imagefor

    Type1:improvingitspictorialinformationfor

    humaninterpretation

    Type2:renderingitmoresuitableforautonomous

    machineperception.

    Digital

    image

    processing involvesusingacomputertochangethenatureof

    adigitalimage

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    4/28

    Type1:

    Image

    sharpen

    Enhancingtheedgesofanimagetomakeit

    appearsharper

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    5/28

    Type1:

    Image

    de

    noising

    Removingnoisefromanimage

    Noise:random

    errors

    in

    the

    image

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    6/28

    Type1:

    Image

    de

    blurring

    Removingblurringfromanimage

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    7/28

    Type2:

    Edge

    detection

    Formeasurementofobjects,suchastheir

    spread,and

    the

    area

    contained

    within

    them

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    8/28

    Type2:

    Image

    segmentation

    Partitioning imageintointerestingregions

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    9/28

    Imagetypes

    and

    matrices

    Binary

    Eachpixel

    is

    just

    black

    or

    white

    Greyscale Eachpixelisashadeofgrey,normally0(black)to255

    (white)

    Color Hereeachpixelhasaparticularcolour (~sixmillon

    colours)

    Indexed haveasmallsubsetof~sixteenmillionpossible

    colours

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    10/28

    Binaryimage

    Thereareonlytwopossiblevalues0or1for

    eachpixel,

    we

    only

    need

    one

    bit

    per

    pixel.

    text(printedorhandwriting),fingerprints,or

    imageedgemap

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    11/28

    Greyscale image

    Valueofeachpixelrangingfrom0to255,can

    berepresented

    by

    eight

    bits

    (one

    byte)

    Datatype:mbynmatricesofuint8number

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    12/28

    Colorimages

    (RGB

    images)

    eachpixelhasaparticularcolour;thatcolour

    beingdescribed

    by

    the

    amount

    of

    red,

    green

    andblueinit.

    Bitsrequiredforeachpixelis24

    Numberofcolours:

    Datatype:mbynby3matricesofuint8

    number

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    13/28

    (cont)

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    14/28

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    15/28

    (cont)

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    16/28

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    17/28

    (cont)>> im = imread('peppers.png');

    >> whos im

    Name Size Bytes Class Attributes

    im 384x512x3 589824 uint8 imshow(im);

    >>imshow(im)

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    18/28

    Writingimages

    imwrite(im,filename) writeanimagedefinedby

    im with

    name

    filename,

    image

    type

    is

    inferredfromitsfileextension

    >> imwrite(im,'mypeppers.jpg');

    >> dir *.jpg

    mypeppers.jpg

    >>

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    19/28

    Dataconversion

    Datareaded fromimageisuint8,convertitto

    doublebefore

    applying

    some

    operations

    Beforewritingdatatoimagefilesorfor

    display,convertittouint8.

    >> moon=imread('moon.tif');

    moon=double(moon);

    >>moon=moon/2;

    imshow(uint8(moon));

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    20/28

    Creatingimages

    in

    Matlab

    >> black =80*ones(100,100);

    >> imshow (uint8(im))

    >> I=127*eye(100,100);

    >> imshow (uint8(I))

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    21/28

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    22/28

    (cont)

    384x512x3 96x128x3

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    23/28

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    24/28

    Croppingimage

    Onlytakingaregionofimage

    >> im = imread('peppers.png'); imshow(im);

    >> figure; imshow((im(201:end-100,201:end-200,:));

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    25/28

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    26/28

    Colorimage

    to

    greyscale image

    Brightness=0.2989*R+0.5870*G+0.1140

    *B

    >> im = imread('peppers.png');

    greyim = 0.2989*im(:,:,1) + 0.5870*im(:,:,2)+ 0.1140im(:,:,3);

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    27/28

    Imageaddition

    >> I=imread('rice.png');

    J

    =

    imread('cameraman.tif');

    K=(double(I)+double(J)));

    imshow(uint8(K))

    >> I=imread('rice.png');

    J

    =

    imread('cameraman.tif');

    K=1/2*(double(I)+1/2*double(J)));

    imshow(uint8(K))

  • 8/8/2019 CZ1102 Computing & Problem Solving Lecture 11

    28/28

    >> bw =imread('text.png');bw2=1bw;

    subplot(1,2,1),imshow(bw);subplot(1,2,2),imshow(bw2);

    Imagecomplemention