If you ask a COP for its geometry via the hou.CopNode.layer, you’ll cook the COP and get a read-only hou.ImageLayer. Unlike with SOPs and Geometry objects, the result is no longer tied to the COP Node so it stays the same if the COP node recooks or is deleted.
Call hou.ImageLayer.freeze to edit an ImageLayer. This returns another ImageLayer object that’s an independent writeable copy. Writing to the frozen layer doesn’t affect the earlier read-only versions.
Methods ¶
close()
Resets this object to be an empty object. This stops it holding a reference to the underlying ImageLayer data. This will also happen when the object goes out of scope and is garbage collected, but the close() provides exact control over the timing.
ImageLayers also support contexts so the with statement can be used to auto-close the nanovdb at the with-block end.
storageType()
→ hou.imageLayerStorageType enum value
Returns the layer’s storage type, which consists of its precision and float vs integer type.
border()
→ hou.imageLayerBorder enum value
Returns the layer’s border type.
typeInfo()
→ hou.imageLayerTypeInfo enum value
Returns the semantic type of the layer. This is used for things like automatic visualizations.
setStorageType(storagetype)
Changes the storage type of the layer. Existing data will be lost.
Requires a writable layer.
setBorder(storagetype)
Changes the border of the layer.
Requires a writable layer.
setTypeInfo(storagetype)
Changes the semantic type of the layer.
Requires a writable layer.
channelCount()
→ int
Returns the number of channels in the layer.
setChannelCount(chan)
Changes the number of channels in the layer. Existing data will be lost. Must be within 1 and 4.
Requires a writable layer.
bufferResolution()
→ tuple of int
Returns the underlying buffer size. This is the number of data elements in the X and Y directions. When PixelScale is 1, this corresponds to the number of pixels.
onCPU()
→ bool
An ImageLayer may be stored on the CPU or GPU. This is true if it is stored on the CPU.
onGPU()
→ bool
An ImageLayer may be stored on the CPU or GPU. This is true if it is stored on the GPU.
isConstant()
→ bool
True if the layer is compressed as a single constant value. Note that a layer that has all the same values will not necessarily return True, as this only detects if it has been collapsed to a single constant value.
makeConstant(val)
Collapse the layer into a single constant value of the value provided. Value should be a tuple which will be extended to the required number of channels.
Requires a writable layer.
expandConstant()
Expands constant layers into dense layers.
Requires a writable layer.
storesIntegers()
→ bool
True if the layer holds integer data.
dataWindow()
→ hou.BoundingRect
Return the data window. This is the area, in pixels, that the buffer elements cover.
displayWindow()
→ hou.BoundingRect
Return the display window. This is the area, in pixels, that is framed to Image space.
pixelAspectRatio()
→ float
The ratio Image space coordinates and pixel coordinates.
pixelScale()
→ tuple of float
The scaling factor between the pixel values and the underlying
buffer elements. This is the number of pixels in each dimension
that fit in a buffer element. Thus (2,2)
would create one buffer
element for every 2×2 block of pixels.
setDataWindow(x, y, w, h)
Set the buffer to cover the provided pixels. The actual size of the buffer will vary according to pixel scale. If pixel scale is 1, w and h will be the resolution. Existing data will be lost.
This requires a writable layer.
setDisplayWindow(x, y, w, h)
Set the area in pixels that're framed by the Image space conversion.
This requires a writable layer.
setPixelAspectRatio(aspect)
Set the ratio between pixel space and image space.
This requires a writable layer.
setPixelScale(scale)
Set the scaling between buffer space and pixel space.
This requires a writable layer.
projection()
→ hou.imageLayerProjection
Returns the style of projection performed by the layer’s implicit camera.
aperture()
→ float
Returns the width of the camera aperture, nominally in mm
, but
most importantly in the same units as focalLength
.
focalLength()
→ float
Returns the focal length of the camera, nominally in mm
, but
most importantly in the same units as aperture
.
cameraPosition()
→ tuple of float
The location of the projection point of the camera as measured from the center of image space.
fStop()
→ float
The camera’s FStop.
clippingRange()
→ tuple of float
The clipping range of the layer’s camera.
focusDistance()
→ float
The location of the focus plane of the camera.
shutter()
→ tuple of float
The duration of the camera’s shutter. This is measured relative to a nominal zero point.
setProjection(projection)
Change the projection type of the camera.
setAperture(aperture)
Set the camera’s aperture.
setFocalLength(focal)
Set the camera’s focal length.
setCameraPosition(pos)
Adjust the position of the focus point of the camera, as measured in the image space of the layer.
setFStop(fstop)
Set the camera’s FStop.
setClippingRange(range)
Set the camera’s near/far clipping range.
setFocusDistance(focus)
Set the camera’s focus distance.
setShutter(shutter)
Set the camera’s shutter.
projectionTransform()
→ hou.Matrix4
Compute the transform from world space to image space, including the camera’s projection.
imageToWorldTransform()
→ hou.Matrix4
Compute the non-projective transform from image space to world space.
imageToPixelScale()
→ tuple of float
Return the scale factor from image space to pixel space.
imageToPixelTranslate()
→ tuple of float
Return the offset from image space to pixel space.
imageToBufferScale()
→ tuple of float
Return the scale factor from image space to buffer space.
imageToBufferTranslate()
→ tuple of float
Return the offset from image space to buffer space.
bufferToPixelScale()
→ tuple of float
Return the scale factor from buffer space to pixel space.
bufferToPixelTranslate()
→ tuple of float
Return the offset from buffer space to pixel space.
textureToBufferScale()
→ tuple of float
Return the scale factor from texture space to buffer space.
imageToPixel(p)
→ tuple of float
Convert a 2-tuple from image space to pixel space.
imageToBuffer(p)
→ tuple of float
Convert a 2-tuple from image space to buffer space.
imageToTexture(p)
→ tuple of float
Convert a 2-tuple from image space to texture space.
pixelToImage(p)
→ tuple of float
Convert a 2-tuple from pixel space to image space.
pixelToBuffer(p)
→ tuple of float
Convert a 2-tuple from pixel space to buffer space.
pixelToTexture(p)
→ tuple of float
Convert a 2-tuple from pixel space to texture space.
bufferToPixel(p)
→ tuple of float
Convert a 2-tuple from buffer space to pixel space.
bufferToImage(p)
→ tuple of float
Convert a 2-tuple from buffer space to image space.
bufferToTexture(p)
→ tuple of float
Convert a 2-tuple from buffer space to texture space.
textureToPixel(p)
→ tuple of float
Convert a 2-tuple from texture space to pixel space.
textureToImage(p)
→ tuple of float
Convert a 2-tuple from texture space to image space.
textureToBuffer(p)
→ tuple of float
Convert a 2-tuple from texture space to buffer space.
worldToBuffer(p)
→ tuple of float
Convert a 3-tuple from world space to buffer space.
bufferIndexV4(int x, int y)
→ tuple of float
Returns a layer’s RGBA value at the buffer coordinate (x, y).
bufferIndexI(int x, int y)
→ int
Returns an integer layer’s value at the buffer coordinate (x, y).
bufferIndex(int x, int y)
→ tuple of float
| float
| int
Returns a layer’s value at the buffer coordinate (x, y). The return type corresponds to the layer type, for example a mono layer returns a single float value.
bufferIndexRaw(int x, int y)
→ bytes
Returns a layer’s raw bytes at the buffer coordinate (x, y).
freeze()
→ hou.ImageLayer
Create a writable copy of this and return it.
Note
The actual buffer duplication won’t be done until a write is performed.
isFrozen()
→ bool
Returns if this is frozen, and hence writable.
attributes()
→ dict
Returns the layer attributes present on this layer.
setAttributes(p)
Replaces the layer attributes with the provided dictionary.
updateAttributes(p)
Updates the layer attributes with the provided dictionary, replacing any matching keys.
allBufferElements()
→ hou.BinaryString
Return all the buffer elements as a binary string. This can then
be effeciently re-interpreted and handled by numpy or tensor
packages. The number of elements is the same as the
bufferResolution
. The bit depth and channels are the current
values of the layer.
allBufferElements(storagetype, channels)
→ hou.BinaryString
Return all the buffer elements as a binary string. This can then
be effeciently re-interpreted and handled by numpy or tensor
packages. The number of elements is the same as the
bufferResolution
. The bit depth and channels returned will
match those provided, a conversion will be performed just-in-time
if they differ from the internal layout.
setAllBufferElements(values, length, storagetype, channels)
Take a binary string in values
and replace all of the buffer
elements of this layer with them. The binary string must have a
number of elements matching the bufferResolution
and be of the
provided storagetype and channels.
Requires a writable layer.
setAllBufferElements(values, length)
Take a binary string in values
and replace all of the buffer
elements of this layer with them. The binary string must have a
number of elements matching the bufferResolution
and be of the
same storagetype and channels as this layer.