findbounds
Find output bounds for spatial transformation
Description
estimates the output bounds corresponding to a given spatial transformation and a
set of input bounds. outbounds = findbounds(tform,inbounds)tform is a spatial transformation
structure. inbounds is a 2-by-num_dims
matrix that specifies the lower and upper bounds of the output image.
outbounds is an estimate of the smallest rectangular region
completely containing the transformed rectangle represented by the input bounds, and
has the same form as inbounds. Because
outbounds is only an estimate, it might not completely
contain the transformed input rectangle.
Examples
Input Arguments
Output Arguments
Algorithms
findboundsfirst creates a grid of input-space points. These points are at the center, corners, and middle of each edge in the image.I = imread("rice.png"); h = imshow(I); set(h,"AlphaData",0.3); axis on, grid on in_points = [ ... 0.5000 0.5000 0.5000 256.5000 256.5000 0.5000 256.5000 256.5000 0.5000 128.5000 128.5000 0.5000 128.5000 128.5000 128.5000 256.5000 256.5000 128.5000]; hold on plot(in_points(:,1),in_points(:,2),".","MarkerSize",18) hold offGrid of Input-Space Points

Next,
findboundstransforms the grid of input-space points to output space. Iftformcontains a forward transformation (a nonemptyforward_fcnfield), thenfindboundstransforms the input-space points usingtformfwd. For example:tform = maketform("affine", ... [1.1067 -0.2341 0; 0.5872 1.1769 0; 1000 -300 1]); out_points = tformfwd(tform, in_points)
out_points = 1.0e+03 * 1.0008 -0.2995 1.1512 0.0018 1.2842 -0.3595 1.4345 -0.0582 1.0760 -0.1489 1.1425 -0.3295 1.2177 -0.1789 1.2928 -0.0282If
tformdoes not contain a forward transformation, thenfindboundsestimates the output bounds using the Nelder-Mead optimization functionfminsearch.Finally,
findboundscomputes the bounding box of the transformed grid of points.

