Two-week ISTE workshop on Effective teaching/learning of computer programming - PowerPoint PPT Presentation

1 / 37
About This Presentation
Title:

Two-week ISTE workshop on Effective teaching/learning of computer programming

Description:

Two-week ISTE workshop on Effective teaching/learning of computer programming Dr Deepak B Phatak Subrao Nilekani Chair Professor Department of CSE, Kanwal Rekhi Building – PowerPoint PPT presentation

Number of Views:66
Avg rating:3.0/5.0
Slides: 38
Provided by: Dr23950
Category:

less

Transcript and Presenter's Notes

Title: Two-week ISTE workshop on Effective teaching/learning of computer programming


1
Two-week ISTE workshop onEffective
teaching/learning of computer programming
  • Dr Deepak B Phatak
  • Subrao Nilekani Chair Professor
  • Department of CSE, Kanwal Rekhi Building
  • IIT Bombay
  • Lectures 11, Matrices -examples
  • Saturday 3 July 2010
  • Several slides courtesy Anirudha Jathar and
    Wikipedia

2
Overview
  • A quiz
  • Handling images
  • Representation of digital images
  • Histogram
  • Contrast enhancement
  • Example program to calculate histogram of a small
    digital image

3
A quiz
  • Q. Currently, what activity do you propose to
    carry out within two weeks of the workshop
    conclusion, for the mandatory submission
  • A. Design questions and answers for examinations
  • B. Design quiz questions and answers
  • C. Add lecture slides with examples
  • D. Something different

4
Digital images
  • Digital images are a collection of pixel values
  • These are arranged in an array (W x H)
  • Each pixel value can be represented by
  • 1 bit (m mono colour, e.g. black and white)
  • 8 bits (g gray scale 0 black to 255 white)
  • 24 bits (c Red, Blue, Green, each one byte)
  • One can have 16 million colours!
  • Capacity of a human eye is limited to a
  • small range from 200 to 2000 colours

5
Digital images ...
  • While storing information about an image in a
    file, we mainly need values of Width, Height, the
    type of colours present, and values for each
    pixel
  • Images such as black and white fingerprints have
    small size (500 x 300)
  • For large images, compression is mandatory to
    keep the file size within limits
  • 12 M pixel camera can produce 36 M bytes image
  • Compression can be either lossy or lossless
  • Several file formats have evolved
  • raw, png, bmp, tiff, giff, jpeg, xmp
  • Refer to wikipedia (Image_file_formats)

6
Images and histograms
  • Pixel values of digital images can be read in a
    matrix for further processing
  • Each picture point (pixel) has an associated
    tonal value
  • For grayscale images, the value range is 0-255
  • 0 Black, 255 White
  • Thus each element of such an image matrix would
    contain a value which can be of the type/size
    short int or char (1 byte)
  • Histogram indicates how many pixels in an image
    have the same value

7
A sample image 8 pixel x 8 pixel
8
Pixel values in the sample image
9
Histogram values
  • Val n Val n Val n Val n
    Val n
  • 52 1 64 2 72 1 85 2
    113 1
  • 55 3 65 3 73 2 87 1
    122 1
  • 58 2 66 2 75 1 88 1
    126 1
  • 59 3 67 1 76 1 90 1
    144 1
  • 60 1 68 5 77 1 94 1
    154 1
  • 61 4 69 3 78 1 104 2
  • 62 1 70 4 79 2 106 1
  • 63 2 71 2 83 1 109 1

10
Cumulative Distribution Function (cdf)
  • V c V c V c V c V c
  • 52 1 64 19 72 40 85 51 113 60
  • 55 4 65 22 73 42 87 52 122 61
  • 58 6 66 24 75 43 88 53 126 62
  • 59 9 67 25 76 44 90 54 144 63
  • 60 10 68 30 77 45 94 55 154 64
  • 61 14 69 33 78 46 104 57
  • 62 15 70 37 79 48 106 58
  • 63 17 71 39 83 49 109 59

11
Histogram equalization
  • The histogram equalization formula
  • Equalization formula for example image

12
Histogram equalization
  • For example, the cdf of 78 is 46

13
Pixel values after histogram equalization
14
Enhancement of Contrast
15
Original Picture for comparison
16
Another grayscale picture
17
Histogram and cdf
18
Equalized histogram and cdf
19
Picture with enhanced contrast
20
Original picture for comparison
21
Program to calculate histogram
  • includeltiostreamgt
  • using namespace std
  • int main()
  • int i, j, npix
  • int image500500, histogram256
  • / we assume that the image data is contained
    in a text file "image.txt in a suitable format
  • Also, we will use command line redirection to
    read data from this file
  • /

22
Histogram
  • cin gtgt npix // number of pixels
  • //read image pixel values in the matrix
  • for(i0 ilt npix i)
  • for(j0 j lt npix j)
  • cin gtgt imageij
  • cout ltlt imageij ltlt " "
  • cout ltlt "\n"

23
Histogram
  • // set histogram counts to zero
  • //
  • for(i0 ilt 256 i) histogrami 0
  • // Calculate histogram values
  • for(i0 ilt npix i)
  • for (j 0 j lt npix j)
  • // based on the value of the pixel
  • // increment the corresponding count
  • // in the histogram array
  • histogramimageij

24
Histogram
  • // print the histogram at non zero values
  • cout ltlt "Histogram at non zero values is
  • cout ltlt "\n"
  • for (i0 ilt256 i)
  • if (histogrami !0)
  • cout ltlt i ltlt " " ltlt histogrami ltlt
    "\n"

25
Histogram
  • // find the maximum value in the histogram
  • int imax, max 0
  • for (i0 ilt256 i)
  • if (histogrami gt max) max histogrami
  • cout ltlt "Maximum histogram value " ltlt max
  • cout ltlt occurs at ltlt "\n"
  • // Print the grey levels at which max value
    occurs
  • for(i0 ilt256 i)
  • if (histogrami max) cout ltlt i ltlt " "
  • return 0

26
Image of a finger print
27
  • THANK YOU

28
  • Question, From GEC Thrisur
  • Can we return structure from the function ?

29
  • Question, From PSG Coimbatore
  • Does C support function overloading ?

30
  • Question, From PSG Coimbatore
  • Why is C, C generally use to design and develop
  • an operating system ?

31
  • Question, From NIT, Kurukshetra
  • What is the application of bit wise operators ?

32
  • Question, From GEC Thrisur
  • What is the maximum dimension possible for a
    multi dimension array ?

33
  • Question, From GEC Thrisur
  • Earlier Pascal was use to discuss programming
  • methodology, later why its turn to C ?

34
  • Question, From PSG Coimbatore
  • If C is not supporting function overloading mean
    how it is possible to use different number of
    scanf with different argument ?

35
  • Question, From NIT Kurukshetra
  • When we declare float instruct and why scanning
  • value, It will display floating point abnormal
  • termination error ?

36
  • Question, From NIT Kurukshetra
  • Is cin and cout return any value?

37
  • Question, From NIT Jalandhar
  • What are macros and why they are taking lesser
    time during compilation?
Write a Comment
User Comments (0)
About PowerShow.com