interpmask - interpolate (tween) logical masks
INTERPMASK performs mask interpolation (tweening) via distance maps. Inbetweening or tweening is the process of generating intermediate frames between two images to give the appearance that the first image evolves smoothly into the second image
  BWq = INTERPMASK(X,BW,Xq) interpolates masks in the logical matrix BW
  at query points Xq. The elements of X corresponds to the successive
  masks along the last dimension of BW. The output BWq is a logical
  matrix of equal size to BW except for the last dimension which is equal
  to the number of query points in Xq.
  BWq = INTERPMASK(...,'interpDim',D) specifies D as the dimension of BW
  to interpolate along. By default, D is simply the last dimension of BW.
BWq = INTERPMASK(BW,Xq) assumes X = 1:N, where N is SIZE(BW,INTERPDIM).
  Interpolation between masks is done via the distance matrix of each
  mask in BW (calculated by BWDIST from the IP toolbox) using INTERP1.
  Extra arguments ('linear', 'pchip', 'extrapval', etc) will be passed to
  INTERP1 and can be used to control the interpolation method. To provide
  an 'extrapval' to the output BWq mask, pass an 'extrapval' of 1 (TRUE)
  or -1 (FALSE) to INTERPMASK as follows:
BWq = INTERPMASK(...,'pchip','extrapval',-1) % Extrap pixels set FALSE
  For example, to interpolate smoothly from a small circle to a large
  square to a large circle, consider the following:
    % Make two circles and a rectangle
    [x,y] = meshgrid(-51:51,-51:51);
    circMat = sqrt(x.^2 + y.^2);
    smallCirc = circMat<10;
    largeCirc = circMat<30;
    largeRect = false(size(x));
    largeRect(2:100,2:100) = true;
    % Stack them as masks 1, 2, and 3
    BW = cat(3,smallCirc,largeRect,largeCirc);
    % Interpolate smoothly between masks
    BWout1 = interpmask(1:3, BW, linspace(1,3,200),'linear');
    BWout2 = interpmask(1:3, BW, linspace(1,3,200),'pchip');
    figure, subplot(1,2,1)
    patch(isosurface(BWout1,0.5),'FaceColor','g','EdgeColor','none')
    camlight, view(3), camlight, axis image
    subplot(1,2,2)
    patch(isosurface(BWout2,0.5),'FaceColor','g','EdgeColor','none')
    camlight, view(3), camlight, axis image
See also INTERP1.
Cita come
Sven (2025). interpmask - interpolate (tween) logical masks (https://it.mathworks.com/matlabcentral/fileexchange/46429-interpmask-interpolate-tween-logical-masks), MATLAB Central File Exchange. Recuperato .
Compatibilità della release di MATLAB
Compatibilità della piattaforma
Windows macOS LinuxCategorie
Tag
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Scopri Live Editor
Crea script con codice, output e testo formattato in un unico documento eseguibile.
| Versione | Pubblicato | Note della release | |
|---|---|---|---|
| 1.0.0.0 | 
