jvconnected.ui.models.waveform

Functions used by jvconnected.ui.models.devicepreview.CameraPreview to generate waveform display.

Note

This module is experimental and the math involved is most assuredly incorrect. It should not be used where correctness is required.

Waveform Functions

jvconnected.ui.models.waveform.get_waveform_arr(rgb_arr: RGBArrayF) WFMArray[source]

Calculate a waveform array as a set of xy points

The values for 'xpos' and 'ypos' in the result represent the waveform’s points for each line of the input image where 'ypos' is the luma component. The 'yprime' field is the original \(Y'\) value and 'ypos' has the “footroom” of \(16/255\) subtracted from it. All fields are normalized (ranging from 0 to 1).

Parameters

rgb_arr (RGBArrayF) – The input image array

Returns

WFMArray

Array with the same shape as the input along the first two axes (height, width)

jvconnected.ui.models.waveform.get_waveform_qimage(qimg: PySide2.QtGui.QImage) WFMArray[source]

Calculate a waveform array from a QtGui.QImage using get_waveform_arr()

jvconnected.ui.models.waveform.get_yprime_rgb(rgb: RGBArrayF) numpy.ndarray[Any, numpy.dtype[float]][source]

Calculate the \(Y'\) (luma) value for the given RGB values according to ITU-R BT.709

\[Y' = 0.2126\cdot R' + 0.7152\cdot G' + 0.0722\cdot B'\]
Parameters

rgb (RGBArrayF) – The N-D input with last axis containing RGB float values

Returns

An array of float with same shape as the input along all but the last axis

Image I/O Functions

jvconnected.ui.models.waveform.qimg_to_rgb_arr(qimg: PySide2.QtGui.QImage) RGBArrayF[source]

Convert a QtGui.QImage to an RGBArrayF

jvconnected.ui.models.waveform.img_arr_to_qimg(img_arr: RGBArray, output_rect: Optional[PySide2.QtCore.QRect] = None) PySide2.QtGui.QImage[source]

Convert the given RGBArray to a QtGui.QImage

Parameters
  • img_arr (RGBArray) – The array to convert

  • (class (output_rect) – QtCore.QRect, optional): If given, the result will be scaled to this size

jvconnected.ui.models.waveform.rasterize_wfm_arr(wfm_arr: WFMArray) RGBArray[source]

Convert a waveform array into a rasterized image array

Parameters

wfm_arr (WFMArray) – The input waveform array

Returns

RGBArray

Image array with same shape as the input along the first two axes (height, width)

Graticule Functions

jvconnected.ui.models.waveform.get_graticules(rect: PySide2.QtCore.QRect) Tuple[Dict[float, float], Dict[float, PySide2.QtCore.QLineF]][source]

Get a set of graticules scaled to fit within the given QtCore.QRect

The scale ranges from -20 to 120 (ire) in increments of 10. An extra value of 7.5 ire is included (NTSC setup level)

Parameters

rect (QtCore.QRect) – The bounding box as a QtCore.QRect

Returns

  • ire_vals (dict) – A mapping of ire values to their normalized positions

  • lines (dict) – A mapping of QtCore.QLineF objects with their ire values as keys

jvconnected.ui.models.waveform.paint_graticules(painter: PySide2.QtGui.QPainter, rect: PySide2.QtCore.QRect) Tuple[Dict[float, float], Dict[float, PySide2.QtCore.QLineF]][source]

Draw graticules and text markers using the QPainter api

Graticules are calculated using get_graticules() then drawn on the given QtGui.QPainter. IRE value labels are then drawn alternating on the left and right sides

Parameters
  • painter (QtGui.QPainter) – The QPainter to draw with

  • rect (QtGui.QRect) – The bounding box to use for drawing

Returns

  • ire_vals (dict) – A mapping of ire values to their normalized positions

  • lines (dict) – A mapping of QtCore.QLineF objects with their ire values as keys

Types

jvconnected.ui.models.waveform.RGBArray

3d array of np.uint8 with shape (height, width, color) (sorted as RGBA)

The values are 8-bit (ranging from 0 to 255)

alias of numpy.ndarray

jvconnected.ui.models.waveform.RGBArrayF

3d array of floats with shape (height, width, color) (sorted as RGB)

The values are normalized (ranging from 0 to 1)

alias of numpy.ndarray

jvconnected.ui.models.waveform.WFMArray

2d array using the WFM_dtype with shape (height, width)

alias of numpy.ndarray

jvconnected.ui.models.waveform.WFM_dtype = dtype([('yprime', '<f8'), ('xpos', '<f8'), ('ypos', '<f8')])

A structured data type for waveform data

Parameters
  • yprimenp.float64 containing the result of get_yprime_rgb()

  • xposnp.float64 containing the element’s x-axis position normalized to the range of 0 to 1

  • yposnp.float64 containing the element’s y-axis position normalized to the range of 0 to 1. This is calculated as \(Ypos = Yprime - (16/255)\)