what is the function of... ?please explain the statement ' roi'. and ' isempty'

1 visualización (últimos 30 días)
for m=1:size(leftI,1)
% Set min/max row bounds for image block.
minr = max(1,m-halfBlockSize);
maxr = min(size(leftI,1),m+halfBlockSize);
% Scan over all columns.
for n=1:size(leftI,2)
minc = max(1,n-halfBlockSize);
maxc = min(size(leftI,2),n+halfBlockSize);
% Compute disparity bounds.
mind = max( -disparityRange, 1-minc );
maxd = min( disparityRange, size(leftI,2)-maxc );
% Construct template and region of interest.
template = rightI(minr:maxr,minc:maxc);
templateCenter = floor((size(template)+1)/2);
roi = [minr+templateCenter(1)-2 ...
minc+templateCenter(2)+mind-2 ...
1 maxd-mind+1];
% Lookup proper TemplateMatcher object; create if empty.
if isempty(tmats{size(template,1),size(template,2)})
tmats{size(template,1),size(template,2)} = ...
video.TemplateMatcher('ROIInputPort',true);
end
thisTemplateMatcher = tmats{size(template,1),size(template,2)};
% Run TemplateMatcher object.
loc = step(thisTemplateMatcher, leftI, template, roi);
Dbasic(m,n) = loc(2) - roi(2) + mind;
end
end

Respuesta aceptada

Wayne King
Wayne King el 1 de Oct. de 2011
tmats is created as an empty cell array 7x7
The code:
if isempty(tmats{size(template,1),size(template,2)})
tmats{size(template,1),size(template,2)} = ...
vision.TemplateMatcher('ROIInputPort',true);
end
says "if the element of the cell array tmats{4,4} (the size of the template in the row and column dimension the first time through the for loop) is empty, place the System object handle vision.TemplateMatcher('ROIInputPort',true) in that element of the cell array"
The next time through the loop the column location changes as explained in the demo.
  2 comentarios
Wayne King
Wayne King el 1 de Oct. de 2011
that's just an ellipsis to move the line of code to the next line without generating an error
x = randn(100,1);
mu = ...
mean(x);
% this will error
x = randn(100,1);
mu =
mean(x);

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 1 de Oct. de 2011
isempty() basically checks to see if the variable has been assigned and has a value or not. roi means "region of interest" and is the portion of the array to operate on.
  3 comentarios
Wayne King
Wayne King el 1 de Oct. de 2011
Hi Neenu, that is just the definition of the region of interest as ImageAnalyst has said. I suggest you place a breakpoint in that for loop and then use F10 to step through it, you will see how the region of interest changes and how the location of where the System object handle placement changes as well.

Iniciar sesión para comentar.

Categorías

Más información sobre Computer Vision with Simulink en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by