QTTorch Package Reference Manual

Package qttorch declares two functions that convert torch.Tensor to QImage and vice-versa.

Loading this package automatically loads packages torch and qt.

qt.QImage.fromTensor(tensor)

qt.QImage.fromTensor(tensor)

Return a new QImage filled with data from a torch Tensor.

Tensor tensor must have 2 or 3 dimensions.

  • The first dimension defines the image width.
  • The second dimension defines the image height.
  • The third dimension size must be 1, 3, or 4

for monochrome, rgb, and rgba images respectively. Each component is a floating point number in range 0 to 1.

qimage:toTensor(arg)

qimage.toTensor(tensor)

Fill the Tensor tensor with data from QImage qimage. Tensor tensor must have 2 or 3 dimensions. The first two dimensions must be equal to the image width and height respectively. The third dimension must be 1, 3, or 4 for monochromatic, rgb or rgba images. The qimage data will be converted to the desired format and stored into the tensor, each component being represented by a floating point number in range 0 to 1. This function returns the filled tensor.

qimage.toTensor(depth)

Create a tensor with data from image qimage. Argument depth must be 1, 3, or 4 for extracting monochromatic, rgb or rgba data. When depth is one, this function returns a two-dimensional tensor. Otherwise it returns a three-dimensional tensor with the third dimension equal to depth. The first two dimensions are always the image width and height.

manual/qttorch/index.txt · Last modified: 2013/02/05 12:23 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:Public Domain
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki