float
in range [0,1].
ppm.cpp
and pgm.cpp
,
each implementation file with its own header, defining
two classes, ppm_t
and pgm_t
, respectively.
ppm_t
is a subclass of and derived from
pgm_t
, since it extends the latter.
pgm
class should take care of converting
the color image to a greyscale image.
main.cpp
code driver tests the modules by:
ppm_t(...)
constructor to read in the PPM image
pgm_t(...)
copy constructor to convert the PPM image
std::ofstream <<
to write out the PGM image
pgm_t
with a
const ppm_t&
as argument will require forward declaration
of the class.
rename()
member function
to rename the newly created pgm_t
image.
pgm_t
image, test it by reading and
writing (e.g., copying) a pgm_t
image class—if you
can copy an image without distorting it in any way, your I/O routines
are working. Repeat the process for the ppm_t
class
to make sure you can copy a PPM image without distorting it.
pgm_t
image code working, subclass it
to create a mostly empty ppm_t
class, save for two
additional data members: float *rpix;
and
float *bpix;
which hold the red and blue pixel
values, respectively (the float *gpix;
holding the
green pixel values is inherited from the pgm_t
base
class).
main.c
here is a
Makefile
that you can use to try to compile the project:
CC = g++
INCLUDE = -I.
CFLAGS = -g
LDFLAGS = -L. -L/usr/lib
LDLIBS = -lc -lm
.cpp.o:
$(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $<
OBJS = \
ppm.o \
pgm.o
all: main
main: main.o main.cpp $(OBJS)
$(CC) $(CFLAGS) -o $@ $@.o $(OBJS) $(LDFLAGS) $(LDLIBS)
main.o: main.cpp
pgm.o: pgm.cpp
ppm.o: ppm.cpp
clean:
rm -f *.o
rm -rf main
Note that each line underneath the targets is indented by a tab, not just
spaces, this is important!
tar.gz
archive of your asg##/ directory, including:
README
file containing
Makefile
.h
headers and .c
source)
make clean
before tar
)
handin
notes