% ./dwt -l 0
would give a 1-level decomposition, while
% ./dwt -l 9
would give a full-level \(log_2(512)\) decomposition of a
\(512 \times 512\) original.
float
) values to range
\([0, 1]\)
prior to output is what is required.
main()
funcrtion can look something like this
(with level hardcoded in this case):
int main(int argc,char **argv)
{
int levels=0;
PGM *gimg=NULL, *nimg=NULL;
PPM *cimg=NULL;
// allocte image of given size
cimg = ppm_read("mandrill.ppm");
// convert to grey
gimg = ppm_togrey(cimg);
// perform the DWT transform to given levels, 0 will do 1 level,
// ilog2(img->rows)-1 should do the full DWT, assuming img is square and POT
//levels = pgm_levels(gimg);
pgm_dwt2D(gimg,levels);
pgm_write(gimg,"dgrey.pgm");
// copy DWT image and normalize, for visualization purposes
nimg = pgm_copy(gimg);
pgm_normalize(nimg);
pgm_write(nimg,"ngrey.pgm");
// perform the inverse DWT, should get original image
pgm_idwt2D(gimg,levels);
// output to file
pgm_write(gimg,"grey.pgm");
// free image by sending pointer to pointer to ppm_free function
ppm_free(&cimg);
pgm_free(&gimg);
pgm_free(&nimg);
return 0;
}
% ./dwt -l 0
% ./dwt -l 1
main.c
here is a
Makefile
that you can use to try to compile the project:
CC = gcc
INCLUDE = -I.
CFLAGS = -g
LDFLAGS = -L. -L/usr/lib
LDLIBS = -lc -lm
.c.o:
$(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $<
OBJECTS = \
pgm.o \
ppm.o \
misc.o \
trig.o \
arrays.o \
wavelets.o \
wtfilter.o \
wt2d.o
all: main
main: main.o main.c
$(CC) $(CFLAGS) $(INCLUDE) -o $@ $@.o $(OBJECTS) $(LDFLAGS) $(LDLIBS)
main.o: main.c
clean:
rm -f *.o
rm -rf hotel
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