Skip to content
This repository has been archived by the owner on Jul 20, 2020. It is now read-only.

Commit

Permalink
Fixed steepest_neighbor (return type was wrong).
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianKniephoff committed Jan 15, 2011
1 parent 5143748 commit 4f36130
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ seamless
image.jpg
*~
*.swp
*.o
30 changes: 28 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,28 @@
seamless: main.c energy_functions.c pixel_access.c array_image.c
gcc -Wall -Werror -pedantic-errors -std=c99 `sdl-config --cflags --libs` -lSDL_image energy_functions.c pixel_access.c array_image.c main.c -o seamless -O3
OBJS = main.o array_image.o energy_functions.o pixel_access.o

CFLAGS = -c -Wall -Werror -pedantic-errors -std=c99 -O3
ifeq ($(DEBUG),1)
CFLAGS += -g
endif

CFLAGS += `sdl-config --cflags`
LIBS = `sdl-config --libs` -lSDL_image

seamless: $(OBJS)
gcc $(LIBS) $(OBJS) -o seamless

main.o: main.c array_image.h util.h
gcc $(CFLAGS) main.c

array_image.o: array_image.c array_image.h pixel_access.h
gcc $(CFLAGS) array_image.c

energy_functions.o: energy_functions.c util.h array_image.h
gcc $(CFLAGS) energy_functions.c

pixel_access.o: pixel_access.c pixel_access.h
gcc $(CFLAGS) pixel_access.c

clean:
rm -f $(OBJS)
rm seamless
14 changes: 6 additions & 8 deletions energy_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ gradient_magnitude (Uint8 * image, int w, int h, int x, int y)
return sqrt (ddx * ddx + ddy * ddy);
}

Uint8
float
steepest_neighbor (Uint8 * image, int w, int h, int x, int y)
{
Uint8 l, l1, l2, l3, l4, l5, l6, l7, l8;
Expand Down Expand Up @@ -92,29 +92,27 @@ steepest_neighbor (Uint8 * image, int w, int h, int x, int y)
if (y > 0)
{
pixel = array_p (image, w, x, y - 1);
l1 = abs (l - value_from_rgb (pixel[0], pixel[1], pixel[2]));
l4 = abs (l - value_from_rgb (pixel[0], pixel[1], pixel[2]));
}
pixel = array_p (image, w, x, y);
l2 = abs (l - value_from_rgb (pixel[0], pixel[1], pixel[2]));
if (y < h - 1)
{
pixel = array_p (image, w, x, y + 1);
l3 = abs (l - value_from_rgb (pixel[0], pixel[1], pixel[2]));
l5 = abs (l - value_from_rgb (pixel[0], pixel[1], pixel[2]));
}

if (x < w - 1)
{
if (y > 0)
{
pixel = array_p (image, w, x + 1, y - 1);
l1 = abs (l - value_from_rgb (pixel[0], pixel[1], pixel[2]));
l6 = abs (l - value_from_rgb (pixel[0], pixel[1], pixel[2]));
}
pixel = array_p (image, w, x + 1, y);
l2 = abs (l - value_from_rgb (pixel[0], pixel[1], pixel[2]));
l7 = abs (l - value_from_rgb (pixel[0], pixel[1], pixel[2]));
if (y < h - 1)
{
pixel = array_p (image, w, x + 1, y + 1);
l3 = abs (l - value_from_rgb (pixel[0], pixel[1], pixel[2]));
l8 = abs (l - value_from_rgb (pixel[0], pixel[1], pixel[2]));
}
}

Expand Down
3 changes: 1 addition & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <SDL_image.h>

#include "util.h"
#include "pixel_access.h"
#include "array_image.h"


Expand Down Expand Up @@ -109,7 +108,7 @@ main (int argc, char *argv[])
int running = 1;
Uint32 black = SDL_MapRGB (screen->format, 0, 0, 0);
SDL_Event event;
energy_function f = gradient_magnitude;
energy_function f = steepest_neighbor;
SDL_Surface *energy = energize (image, f);
while (running)
{
Expand Down

0 comments on commit 4f36130

Please sign in to comment.