Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "wavelib"]
path = wavelib
url = https://github.com/CodePurble/wavelib.git
url = https://github.com/codepurble/wavelib.git
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# adapted from https://spin.atomicobject.com/2016/08/26/makefile-c-projects/
TARGET_EXEC ?= main

BUILD_DIR ?= ./build
SRC_DIR ?= ./src
INC_DIR ?= ./include

SRCS := $(shell find $(SRC_DIR) -name *.c)
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
DEPS := $(OBJS:.o=.d)

INC_FLAGS := $(addprefix -I,$(INC_DIR))

CFLAGS ?= $(INC_FLAGS) -Wall -MMD -MP

$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
$(CC) $(OBJS) -o $@ $(LDFLAGS)

$(BUILD_DIR)/%.c.o: %.c
$(MKDIR_P) $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@

.PHONY: clean

clean:
$(RM) -r $(BUILD_DIR)/*

-include $(DEPS)

MKDIR_P ?= mkdir -p
12 changes: 8 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@

int main()
{
FILE *fptr = fopen("/home/ramprakash/rpdata/nie/study-material/sem6/miniproject/libezw/utils/raw_lichtenstein_img_processing_test_bw.bin", "rb");
// FILE *fptr = fopen("/mnt/d/libezw/utils/raw_lichtenstein_img_processing_test_bw.bin", "rb");
FILE *fptr = fopen("/mnt/d/libezw/build/ll.bin", "wb");

unsigned char *pix_arr = calloc(ROWS*COLS, 1); // array of 8 bit vals
if(!fptr) {
fprintf(stderr, "Unable to open file\n");
}
else {
read_binary_file(fptr, pix_arr, ROWS, COLS);
fclose(fptr);
// read_binary_file(fptr, pix_arr, ROWS, COLS);
// fclose(fptr);
wave_object obj;
wt2_object wt;
double *inp, *wavecoeffs, *oup, *cLL;
Expand All @@ -40,8 +42,10 @@ int main()
wavecoeffs = dwt2(wt, inp);
cLL = getWT2Coeffs(wt, wavecoeffs, 1, "A", &ir, &ic);

dispWT2Coeffs(cLL, ir, ic);
// dispWT2Coeffs(cLL, ir, ic);
printf("Hello %f\n",cLL[100]);

write_binary_file(fptr, cLL, ROWS/4, COLS/4);
wt2_summary(wt);

// clean up
Expand Down
9 changes: 7 additions & 2 deletions src/utils.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#include "utils.h"

void read_binary_file(FILE *in, unsigned char* dest, int rows, int cols)
void read_binary_file(FILE *infile, unsigned char* dest, int rows, int cols)
{
fread(dest, 1, rows*cols, in);
fread(dest, 1, rows*cols, infile);
}

void write_binary_file(FILE *outfile, unsigned char *src, int rows, int cols)
{
fwrite(src, 1, rows*cols, outfile);
}