interpmask - interpolate (tween) logical masks

Version 1.0.0.0 (3,66 KB) von Sven
interpmask interpolates (or tweens) masks to transition smoothly between shapes in masks
532 Downloads
Aktualisiert 1. Mai 2014

Lizenz anzeigen

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.

Zitieren als

Sven (2024). interpmask - interpolate (tween) logical masks (https://www.mathworks.com/matlabcentral/fileexchange/46429-interpmask-interpolate-tween-logical-masks), MATLAB Central File Exchange. Abgerufen .

Kompatibilität der MATLAB-Version
Erstellt mit R2014a
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux
Kategorien
Mehr zu 3-D Volumetric Image Processing finden Sie in Help Center und MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Veröffentlicht Versionshinweise
1.0.0.0