parametres input
This commit is contained in:
41
output.go
41
output.go
@@ -2,7 +2,10 @@ package imageproc
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/airbusgeo/godal"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -151,3 +154,41 @@ func (r *Registrator) BytesToRaw(mssData []byte, filePath string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Registrator) SaveRegisteredMssToRaw(raw string) error {
|
||||
f, err := os.OpenFile(raw, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0777)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var mssData [4][]byte
|
||||
for i := 0; i < MssBands; i++ {
|
||||
mssData[i] = r.registeredMssImages[i].ToBytes()
|
||||
}
|
||||
|
||||
width := r.MssWidth * PixelBytes
|
||||
height := r.MssHeight
|
||||
log.Println("Writing registered MSS to RAW file...", len(mssData[0])*4)
|
||||
log.Println("width:", width)
|
||||
log.Println("height:", height)
|
||||
w := bufio.NewWriter(f)
|
||||
for row := 0; row < height; row++ {
|
||||
w.Write(mssData[0][row*width : (row+1)*width])
|
||||
w.Write(mssData[1][row*width : (row+1)*width])
|
||||
w.Write(mssData[2][row*width : (row+1)*width])
|
||||
w.Write(mssData[3][row*width : (row+1)*width])
|
||||
}
|
||||
|
||||
hdr := EnviHdr{
|
||||
Samples: r.MssWidth,
|
||||
Lines: r.MssHeight,
|
||||
Bands: MssBands,
|
||||
}
|
||||
|
||||
hdrFile := filepath.Join(filepath.Dir(raw),
|
||||
fmt.Sprintf("%s.HDR", strings.TrimSuffix(filepath.Base(raw), filepath.Ext(raw))),
|
||||
)
|
||||
hdr.Write(hdrFile)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user