gotch/ts/image.go
Goncalves Henriques, Andre (UG - Computer Science) 9257404edd Move the name of the module
2024-04-21 15:15:00 +01:00

43 lines
909 B
Go

package ts
import "C"
import (
// "unsafe"
lib "git.andr3h3nriqu3s.com/andr3/gotch/libtch"
)
// LoadHwc returns a tensor of shape [height, width, channels] on success.
func LoadHwc(path string) (*Tensor, error) {
ctensor := lib.AtLoadImage(path)
err := TorchErr()
if err != nil {
return nil, err
}
return newTensor(ctensor), nil
}
// SaveHwc save an image from tensor. It expects a tensor of shape [height,
// width, channels]
func SaveHwc(ts *Tensor, path string) error {
lib.AtSaveImage(ts.ctensor, path)
return TorchErr()
}
// ResizeHwc expects a tensor of shape [height, width, channels].
// On success returns a tensor of shape [height, width, channels].
func ResizeHwc(ts *Tensor, outWidth, outHeight int64) (*Tensor, error) {
ctensor := lib.AtResizeImage(ts.ctensor, outWidth, outHeight)
err := TorchErr()
if err != nil {
return nil, err
}
return newTensor(ctensor), nil
}