Homework - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

Homework

Description:

We want an object-oriented implementation. Thus, we will define a new type (a class) ... the class interface (image.h) from the class implementation (image.cpp) ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 7
Provided by: Laya9
Category:
Tags: cpp | homework

less

Transcript and Presenter's Notes

Title: Homework


1
Homework1-Part1
  • Write a code that reads, records, and outputs
    images encoded in PGM file format.
  • We want an object-oriented implementation.
  • Thus, we will define a new type (a class) called
    image by specifying its private (or protected)
    and public parts.
  • We may proceed by separating the class interface
    (image.h) from the class implementation
    (image.cpp).
  • The interface represents the class design and
    tells us what can be done to the new type.

2
Homework1-Part1
  • The implementation represents the internals of
    how this is accomplished.
  • It is useful to imagine the raw data as a
    rectangle with r rows and c columns.
  • A pixel has screen coordinates (x, y), where x
    is in the range 0,c-1 and y is in the range
    0,r-1.
  • The rows are numbered from top to bottom and the
    column from left to right.
  • However, we generally store the raw data as a
    one-dimensional array with index values from 0 to
    rc -1.

3
Homework1-Part1
  • If the data is stored row by row in array Data,
    then the index of pixel with coordinates (x, y)
    is yc x.
  • The pixel is accessed in the array at position
    Data yc x

4
Prototype (image.h)
  • class image
  • private
  • char fileType //Magic Identifier
  • char comment
  • int column
  • int row
  • int greyLevel //Max greyLevel
  • float matrix

5
Prototype (image.h)
  • public
  • image() //Default constructor
  • image(int, int) //Constructor
  • image() //Destructor
  • int read()
  • int save()
  • int getwidth()
  • int getheight()
  • float getvalue(int)
  • float getvalue(int,int)
  • int getmaxgrey()
  • int getmingrey()
  • void setvalue(float,int)
  • void setvalue(float,int,int)

6
Function to implement
1- Write a function that generates a binary image
Out by thresholding a grey level image In with a
threshold th. Prototype void Imthresh(image
In, image Out, float th)
  • To test your functions you can use the images in
    the data folder.
Write a Comment
User Comments (0)
About PowerShow.com