- Notifications
You must be signed in to change notification settings - Fork4
HDR is a library that handles RAW image format written with Golang
License
mdouchement/hdr
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
HDR is a library that handles RAW image format written with Golang.Here some rendering examples.
It aims to provide tools to readHDR files and convert it to a LDR (Low Dynamic Range, aka PNG/JPEG/etc.) in animage.Image
object.
Documentations:
- Radiance RGBE/XYZE
- PFM, Portable FloatMap file format
- TIFF usingmdouchement/tiff
- CRAD, homemade HDR file format
Read thisdocumentation to find what TMO use.
Read thisdocumentation to understand what is a TMO.
- Linear
- Logarithmic
- Drago '03 - Adaptive logarithmic mapping for displaying high contrast scenes
- Durand - Fast bilateral filtering for the display of high-dynamic-range images
- Reinhard '05 - Photographic tone reproduction for digital images
- Playing with parameters could provide better rendering
- Custom Reinhard '05
- Rendering looks like a JPEG photo taken with a smartphone
- iCAM06 - A refined image appearance model for HDR image rendering
go get github.com/mdouchement/hdr
package mainimport ("fmt""image""image/png""os""runtime""time""github.com/mdouchement/hdr"_"github.com/mdouchement/hdr/codec/rgbe""github.com/mdouchement/hdr/tmo")// Samples://// http://www.anyhere.com/gward/hdrenc/pages/originals.html// http://resources.mpi-inf.mpg.de/tmo/logmap/ (High Contrast Scenes)var (// input = "/Users/mdouchement/tmp/hdr/memorial_o876.hdr"// input = "/Users/mdouchement/tmp/hdr/MtTamWest_o281.hdr"// input = "/Users/mdouchement/tmp/hdr/rend02_oC95.hdr"// input = "/Users/mdouchement/tmp/hdr/Tree_oAC1.hdr"input="/Users/mdouchement/tmp/hdr/Apartment_float_o15C.hdr"output="/Users/mdouchement/tmp/hdr/output.png")funcmain() {fmt.Printf("Using %d CPUs\n",runtime.NumCPU())fi,err:=os.Open(input)check(err)deferfi.Close()start:=time.Now()m,fname,err:=image.Decode(fi)check(err)fmt.Printf("Read image (%s) took %v\n",fname,time.Since(start))ifhdrm,ok:=m.(hdr.Image);ok {startTMO:=time.Now()// t := tmo.NewLinear(hdrm)// t := tmo.NewLogarithmic(hdrm)// t := tmo.NewDefaultDrago03(hdrm)// t := tmo.NewDefaultDurand(hdrm)// t := tmo.NewDefaultCustomReinhard05(hdrm)t:=tmo.NewDefaultReinhard05(hdrm)// t := tmo.NewDefaultICam06(hdrm)m=t.Perform()fmt.Println("Apply TMO took",time.Since(startTMO))}fo,err:=os.Create(output)check(err)png.Encode(fo,m)fmt.Println("Total",time.Since(start))}funccheck(errerror) {iferr!=nil {panic(err)}}
https://github.com/mdouchement/hdrtool
MIT
A TMO must implementtmo.ToneMappingOperator
:
typeToneMappingOperatorinterface {// Perform runs the TMO mapping.Perform() image.Image}
- Reader
// DecodeConfig returns the color model and dimensions of a PFM image without// decoding the entire image.funcDecodeConfig(r io.Reader) (image.Config,error) {// ...returnm,err}// Decode reads a HDR image from r and returns an image.Image.funcDecode(r io.Reader) (img image.Image,errerror) {// ...return}funcinit() {// Register the format in the official lib.// https://golang.org/pkg/image/#RegisterFormatimage.RegisterFormat("format-name","magic-code",Decode,DecodeConfig)}
- Writer
// Encode writes the Image m to w in PFM format.funcEncode(w io.Writer,m hdr.Image)error {returnnil}
All PRs are welcome. If you implement a TMO or an image codec in a dedicated repository, please tell me in order to link it in this readme.
- Fork it
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create new Pull Request
As possible, run the following commands to format and lint the code:
# Formatfind. -name'*.go' -not -path'./vendor*' -exec gofmt -s -w {}\;# Lintgolangci-lint run -c .golangci.yml
About
HDR is a library that handles RAW image format written with Golang
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.