Do you know any algorithm to create HDR images, like photomatix or photoshop "merge hdr" function?
Are you referring to Pseudo HDR (HDR look from 1 image) or HDR from few different images (Each with different Exposure)?
Usually HDR starts with Edge Preserving Smoothing operator. This allows to differentiate between the details, where we want to keep data, to flat areas, where we can compress the data.
The next step would be applying a compressing function to the data we want to compress.
The last step would be to blend the compressed data.
I would start by reading about Tone Mapping: http://en.wikipedia.org/wiki/Tone_mapping