Coder Social home page Coder Social logo

ssarcandy / hdr-imaging Goto Github PK

View Code? Open in Web Editor NEW
83.0 8.0 17.0 64.83 MB

An implementation of "Paul E. Debevec, Jitendra Malik, Recovering High Dynamic Range Radiance Maps from Photographs, SIGGRAPH 1997."

Home Page: https://ssarcandy.tw/2017/04/16/High-Dynamic-Range-Imaging/

Python 2.61% Jupyter Notebook 96.84% Batchfile 0.54%
ipython-notebook image-processing hdr-image python3 opencv3

hdr-imaging's Issues

Small artifacts in HDR Image

In the resuting .hdr image are cyan or magenta colored pixels. Are there parameters wrong or is there an issue with the calculations? I tried diffrent hdr viewer and tonemapper, all witrh the same result.

artifacts

Downsampling of images in hdr_debvec( ) is not as good as sampling individual pixels from them

Greetings!

Thanks for this implementation, I find that it successfully achieved what the OpenCV version currently does not, specifically with respect to proper weighting of saturated pixels.

To support, after some research, I have found an improvement.

Basically, for the current hdr_debvec( ) function, I kept on getting nasty response functions like this:
response-curve_1

I realized that what is technically happening is downsampling of the pixel values, such that the pixels are averaged / interpolated across each other. This is very problematic in the case where the user has many, many saturated pixels: averaging these values will make them unsaturated, and create a false color in between.

I figured a more robust approach would be to instead just uniformly sample individual pixels across a grid of the image.

Here is how that changed my camera response function (3600 samples):
response_curve_3600samples

Here is the new implementation (not my best code but it works):

def hdr_debvec(img_list, exposure_times, number_of_samples_per_dimension=60):
    B = [math.log(e,2) for e in exposure_times]
    l = constant.L
    w = [z if z <= 0.5*255 else 255-z for z in range(256)]

    samples = []
    width = img_list[0].shape[0]
    height = img_list[0].shape[1]
    width_iteration = width / number_of_samples_per_dimension
    height_iteration = height / number_of_samples_per_dimension

    w_iter = 0
    h_iter = 0

    Z = np.zeros((len(img_list), number_of_samples_per_dimension*number_of_samples_per_dimension))
    for img_index, img in enumerate(img_list):
        h_iter = 0
        for i in range(number_of_samples_per_dimension):
            w_iter = 0
            for j in range(number_of_samples_per_dimension):
                if math.floor(w_iter) < width and math.floor(h_iter) < height:
                    pixel = img[math.floor(w_iter), math.floor(h_iter)]
                    Z[img_index, i*j] = pixel
                w_iter += width_iteration
            h_iter += height_iteration
    
    return response_curve_solver(Z, B, l, w)

Thanks again and great work.

Problems on Pixel Sampling

Is there a bug in Z[img_index, ij] = pixel ? Since there will be several cases where different combination of i and j leads to same position of ij.

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.