Coder Social home page Coder Social logo

imageutilities's Introduction

ImageUtilities - Bridge the gap between CPU and GPU

Installation

  • Set up environment variable COMPUTE_CAPABILITY with the CC of your CUDA-enabled GPU

  • Set up environment variable CUDA_SDK_ROOT_DIR to point to the NVidia CUDA examples

  • Set up environment vaiable IMAGEUTILITIES_ROOT to point to the path of this directory

  • To use the matlab wrapper, set up environment vaiable MATLAB_ROOT to point to matlab root directory

To build simply perform the following steps:

$ cd build
$ cmake ..
$ make
$ make install

Documentation

A pre-built documentation is available here. To build the documentation on your own (requires doxygen), additionally do

$ make apidoc

Usage

In your cmake-based project include the following lines

set(ImageUtilities_DIR $ENV{IMAGEUTILITIES_ROOT})
find_package(ImageUtilities REQUIRED COMPONENTS iucore)
include_directories(${IMAGEUTILITIES_INCLUDE_DIR})

and link your application with

target_link_libraries(your_application
  your_libraries
  ${IMAGEUTILITIES_LIBRARIES}
)

Example

Image Utilities take away the hassle of memory management when dealing with CUDA code. The follwing code snippet shows a simple example of image manipulation using CUDA:

// read two images from files
iu::ImageGpu_32f_C1 *I1 = iu::imread_cu32f_C1(DATA_PATH("army_1.png"));
iu::ImageGpu_32f_C1 *I2 = iu::imread_cu32f_C1(DATA_PATH("army_2.png"));
// allocate memory for the output
iu::ImageGpu_32f_C1 result(I1->size());

// Add 0.5 to the first image and save the result
iu::math::addC(*I1,0.5,result);
iu::imsave(&result,RESULTS_PATH("army_1_bright.png"));

// Subtract one image from the other and save the result
iu::math::addWeighted(*I1,1,*I2,-1,result);
iu::imsave(&result,RESULTS_PATH("army_1_minus_2.png"));

They also make it easy to use images in CUDA kernels by providing additional information about the image that can be easily passed to kernels. Host code:

iu::ImageGpu_32f_C1 img(320,240);

dim3 dimBlock(16, 16);
dim3 dimGrid(iu::divUp(img.width(), dimBlock.x), img.height(), dimBlock.y);

test_kernel <<< dimGrid, dimBlock >>> (img);

and the device code:

__global__ void test_kernel(iu::ImageGpu_32f_C1::KernelData img)
{
    int x = blockIdx.x*blockDim.x + threadIdx.x;
    int y = blockIdx.y*blockDim.y + threadIdx.y;

    if (x < img.width_ && y < img.height_)
    {
        img(x,y) = x+y;
    }
}

imageutilities's People

Contributors

pknoebelreiter avatar reini1305 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.