CSE 803 Using images in C - PowerPoint PPT Presentation

About This Presentation
Title:

CSE 803 Using images in C

Description:

CSE 803 Using images in C – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 11
Provided by: stoc1
Learn more at: http://www.cse.msu.edu
Category:
Tags: cse | double | images | using

less

Transcript and Presenter's Notes

Title: CSE 803 Using images in C


1
CSE 803 Using images in C
  • Computing with images
  • Applications Methods
  • 2D arrays in C
  • Programming project 4

2
Memory organizations
  • Raster storage of 2D array
  • 2D array using pointers to rows
  • PGM image file format

3
1D array via a pointer
  • P is base address of array in memory
  • Array has N cells
  • Cells 0, 1, , N-1
  • double P
  • P new doubleN
  • Pk located at
  • P k size of cell

4
2D array via pointers
  • int P
  • Need to acquire dynamic memory for row pointers
    and for rows of integers

5
Point to array of row pointers
  • typedef int integerPointer
  • integerPointer P
  • P new integerPointer 5
  • // allocate 3 columns in each row
  • for ( int k0 klt5 k )
  • Pk new int 3
  • // now have 5 rows of 3 integers each

6
Referencing 5 rows of 3 ints
  • // put i j in Pij
  • for ( int i0 ilt5 i)
  • for ( int j0 jlt3 j)
  • (Pi)j ij // dont need ()
  • // P points to a 1D array of pointers to int
  • // Pi is the pointer offset i from P
  • // (Pi)j is the int offset j from PI

7
raster storage of 2D array
  • One continguous block of memory for double
    A34
  • 3 rows of 4 columns
  • 8 bytes for each cell
  • Row 0 first, then row 1, then row 2
  • Easy formula locates any cell in same time

8
Issues with 2D arrays
  • Images can be different sizes R x C
  • Size unknown until image file opened
  • Image history usually needed
  • Program must keep collection of data items R,
    C, comments, Irc
  • Object class is a good solution

9
PGM is simple image file form
  • See Fig. 2.12 of Shapiro and Stockman
  • P2 is magic number for gray image
  • indicates comment line
  • Width, height, max gray value next
  • ASCII values for width x height pixels in row
    major order

10
PGM image with ASCII info.
  • P2 means ASCII gray
  • Comments
  • W16 H8
  • 192 is max intensity
  • Can be made with editor
Write a Comment
User Comments (0)
About PowerShow.com