diff --git a/Makefile b/Makefile index cb89d31..fa03808 100644 --- a/Makefile +++ b/Makefile @@ -21,11 +21,11 @@ SOURCES += $(wildcard $(IMGUI_DIR)/*.cpp) SOURCES += $(wildcard $(IMGUI_DIR)/backends/*.cpp) OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) UNAME_S := $(shell uname -s) -LINUX_GL_LIBS = -lGL +LINUX_GL_LIBS = -lGL CXXFLAGS = -std=c++20 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -CXXFLAGS += -g -DIMGUI_DEFINE_MATH_OPERATORS -Ofast -LIBS = +CXXFLAGS += -g -DIMGUI_DEFINE_MATH_OPERATORS -Ofast -Xpreprocessor -fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -DMAGICKCORE_CHANNEL_MASK_DEPTH=32 -I/opt/homebrew/Cellar/imagemagick/7.1.1-32/include/ImageMagick-7 +LIBS = -L/opt/homebrew/Cellar/imagemagick/7.1.1-32/lib -lMagick++-7.Q16HDRI -lMagickWand-7.Q16HDRI -lMagickCore-7.Q16HDRI ##--------------------------------------------------------------------- ## OPENGL ES diff --git a/lib/nodes/load_image.h b/lib/nodes/load_image.h index a526227..3f3c2b9 100644 --- a/lib/nodes/load_image.h +++ b/lib/nodes/load_image.h @@ -27,6 +27,11 @@ #include #include +#include + +#include +using namespace std::chrono; + #ifdef __EMSCRIPTEN__ #include "../emscripten_browser_file.h" #endif @@ -234,16 +239,34 @@ private: return static_cast(ret_val); } + void adjustContrast(uint8_t *pixels, uint8_t *out, int width, int height, + double contrastValue) { + // Initialize Magick library + Magick::InitializeMagick(nullptr); + + // Create a Magick::Image object from the uint8_t* data + Magick::Image image(width, height, "RGBA", Magick::CharPixel, pixels); + + // Apply contrast adjustment + auto start = high_resolution_clock::now(); + image.sigmoidalContrast(true, contrastValue); // Increase contrast + auto stop = high_resolution_clock::now(); + auto duration = duration_cast(stop - start); + std::cout << duration.count() << std::endl; + + start = high_resolution_clock::now(); + Magick::Blob blob; + image.write(&blob); + memcpy(out, blob.data(), width * height * 4); + stop = high_resolution_clock::now(); + duration = duration_cast(stop - start); + std::cout << duration.count() << std::endl; + } + void compute(uint8_t *input, uint8_t *output, int size, int channels) { int nBval = brightnessVal + 256; - for (int i = 0; i < size; i += channels) { - uint8_t r = std::clamp(formula(input[i], brightnessVal), 0, 255); - uint8_t g = std::clamp(formula(input[i + 1], brightnessVal), 0, 255); - uint8_t b = std::clamp(formula(input[i + 2], brightnessVal), 0, 255); - output[i] = r; - output[i + 1] = g; - output[i + 2] = b; - } + adjustContrast(input, output, returnBundle.width, returnBundle.height, + nBval); } int brightnessVal = 0; @@ -467,8 +490,8 @@ public: } #else if (bundle.fname == "") { - handle_upload_file_local( - "/Users/tanishqdubey/Downloads/Odd-eyed_cat_by_ihasb33r.jpg", this); + handle_upload_file_local("/Users/tanishqdubey/Pictures/DSC06956.JPG", + this); } #endif if (bundle.fname != "") { diff --git a/main.cpp b/main.cpp index 1a38415..c2a5d4b 100644 --- a/main.cpp +++ b/main.cpp @@ -44,11 +44,12 @@ #endif #include "lib/ImNodeFlow.h" +#include static bool init = true; // Main code -int main(int, char **) { +int main(int, char **argv) { // Setup SDL if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0) { @@ -56,6 +57,8 @@ int main(int, char **) { return -1; } + Magick::InitializeMagick(*argv); + // Decide GL+GLSL versions #if defined(IMGUI_IMPL_OPENGL_ES2) // GL ES 2.0 + GLSL 100 diff --git a/ppdnode b/ppdnode index 777afe7..9b265e8 100755 Binary files a/ppdnode and b/ppdnode differ