# makefile
# Functions to demonstrate midpoint and gridpoint edginess.
#
#      For the article
#      "A Simple Nonlinear Filter for Edge Detection in Images"
#      by Mladen Victor Wickerhauser and Wojciech Czaja.
#      SPIE Proceedings 5439(April, 2004), pp.24--31
#      http://www.math.wustl.edu/~victor/papers/mpedge.pdf
#
#      Preparer: M.V.Wickerhauser <victor@math.wustl.edu>
#      Date: 13 May 2004
#

CC =	gcc
CFLAGS =  -O -g -Wall
LIBS = -lm

SRC =	edgemp.c edgegp.c makefile \
	figure.c finger7.c cmp00007.raw readme.txt

IMGS =	cone.pgm house.pgm lena.pgm truck.pgm

EDGY =	econe.pgm  efigure.pgm  efinger7.pgm ehouse.pgm elena.pgm  etruck.pgm
GPED =	gcone.pgm  gfigure.pgm  gfinger7.pgm ghouse.pgm glena.pgm  gtruck.pgm
PICS =  cone.pgm figure.pgm finger7.pgm house.pgm lena.pgm truck.pgm

EXECS = edgemp edgegp figure finger7


default: all

execs: $(EXECS)

all: $(EXECS) $(EDGY)


# Main conversion program dependencies:

edgemp: edgemp.c
	$(CC) $(CFLAGS)  -o edgemp edgemp.c $(LIBS)

edgegp: edgegp.c
	$(CC) $(CFLAGS)  -o edgegp edgegp.c $(LIBS)

figure: figure.c
	$(CC) $(CFLAGS)  -o figure figure.c $(LIBS)

finger7: finger7.c
	$(CC) $(CFLAGS)  -o finger7 finger7.c $(LIBS)


# Images and edginess:

econe.pgm: cone.pgm edgemp edgegp
	edgemp < cone.pgm > econe.pgm
	edgegp < cone.pgm > gcone.pgm


efigure.pgm:  figure.pgm  edgemp edgegp
	edgemp < figure.pgm > efigure.pgm
	edgegp < figure.pgm > gfigure.pgm


figure.pgm: figure
	figure > figure.pgm


efinger7.pgm: finger7.pgm edgemp edgegp
	edgemp < finger7.pgm > efinger7.pgm
	edgegp < finger7.pgm > gfinger7.pgm

finger7.pgm: cmp00007.raw finger7
	finger7 < cmp00007.raw > finger7.pgm


ehouse.pgm: house.pgm edgemp edgegp
	edgemp < house.pgm > ehouse.pgm
	edgegp < house.pgm > ghouse.pgm

lena elena.pgm: lena.pgm edgemp edgegp
	edgemp < lena.pgm > elena.pgm
	edgegp < lena.pgm > glena.pgm


truck etruck.pgm: truck.pgm edgemp edgegp
	edgemp < truck.pgm > etruck.pgm
	edgegp < truck.pgm > gtruck.pgm


# System-dependent display commands

drawall: edraw gdraw draw

draw: $(pics)
	xv cone.pgm &
	xv figure.pgm &
	xv finger7.pgm &
	xv house.pgm &
	xv lena.pgm &
	xv truck.pgm &

edraw: $(EDGY)
	xv econe.pgm &
	xv efigure.pgm &
	xv efinger7.pgm &
	xv ehouse.pgm &
	xv elena.pgm &
	xv etruck.pgm &

gdraw: $(GPED)
	xv gcone.pgm &
	xv gfigure.pgm &
	xv gfinger7.pgm &
	xv ghouse.pgm &
	xv glena.pgm &
	xv gtruck.pgm &

# Cleanup and packaging:

zip mpedge.zip: $(SRC) $(IMGS)
	zip -ur mpedge.zip $(SRC) $(IMGS)

tar edginess.tar: $(SRC) $(IMGS)
	tar cvf edginess.tar $(SRC) $(IMGS)

clean:
	-rm -f *~ test*.pgm

spotless: clean
	-rm -f $(EXECS)  $(EDGY)  $(OBJ)
	-rm -f finger7.pgm figure.pgm
