pixelcontrolsignals
Extract signals from pixel-streaming control signal structure
Description
Examples
If you integrate Vision HDL Toolbox designs with algorithms that use a different interface, you may need to create the structure manually, or manipulate the control signals outside of the structure.
Create a pixelcontrol
structure by passing five control signal values to the pixelcontrolstruct
function. The function arguments must be scalar values. These control signals may come from a camera or other video input source. The control signal vectors in this example describe a simple 2-by-3 pixel test image, surrounded by padding pixels.
hStart = [0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0]; vStart = [0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; hEnd = [0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0]; vEnd = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0]; valid = [0 0 0 0 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 0 0 0 0 0]; pixel = uint8([0 0 0 0 0 0 0 30 60 90 0 0 0 120 150 180 0 0 0 0 0 0 0 0]); [~,numPix] = size(pixel); ctrlIn = repmat(pixelcontrolstruct,numPix,1); for i = 1:numPix ctrlIn(i) = pixelcontrolstruct(hStart(i),vStart(i),... hEnd(i),vEnd(i),valid(i)); end
Each element of ctrlIn
is a structure containing the five control signals.
ctrlIn(8)
ans = struct with fields:
hStart: 1
hEnd: 1
vStart: 0
vEnd: 0
valid: 1
You can then pass this structure to a Vision HDL Toolbox System object™. This example uses the LookupTable object to invert each pixel.
tabledata = uint8(linspace(255,0,256)); inverter = visionhdl.LookupTable(tabledata); pixelOut = zeros(numPix,1,'uint8'); ctrlOut = repmat(pixelcontrolstruct,numPix,1); for i = 1:numPix [pixelOut(i),ctrlOut(i)] = inverter(pixel(i),ctrlIn(i)); end
If you need to use the control signals directly in downstream algorithms, you can flatten each structure into five logical
control signal values by calling the pixelcontrolsignals
function.
[hStartOut,vStartOut,hEndOut,vEndOut,validOut] = deal(false(numPix,1)); for i = 1:numPix [hStartOut(i),vStartOut(i),hEndOut(i),vEndOut(i),validOut(i)] = ... pixelcontrolsignals(ctrlOut(i)); end
Each output control signal is a vector of logical values that correspond with the pixelOut
vector.
validOut'
ans = 1×24 logical array
0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 0 0 0
Input Arguments
Pixel control signals, specified as a structure containing five logical
values.
The pixel control structure is a specific format used by Vision HDL Toolbox™ objects. See Pixel Control Structure.
Output Arguments
Control signal indicating the first pixel in a horizontal line,
specified as a logical
scalar.
Control signal indicating the last pixel in a horizontal line,
specified as a logical
scalar.
Control signal indicating the first pixel in the first (top)
line, specified as a logical
scalar.
Control signal indicating the last pixel in the last (bottom)
line, specified as a logical
scalar.
Control signal indicating the validity of the pixel, specified
as a logical
scalar.
Version History
Introduced in R2015a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)