Main Content

bwselect3

Select objects in binary volume

Description

J = bwselect3(V,c,r,p) returns the binary volume J containing the objects that overlap the voxel (r,c,p). Objects are connected sets of voxels with the value 1.

example

J = bwselect3(V,c,r,p,n) also specifies the connectivity, n, used to define objects.

[J,idx] = bwselect3(___) returns in idx the linear indices of voxels belonging to the selected objects.

[x,y,z,J,idx,xi,yi,zi] = bwselect3(___) also returns the x, y, and z extents of the binary volume and the (xi,yi,zi) coordinates of selected voxels. By default, bwselect3 uses the intrinsic coordinate system so that x,y, and z are the volume XData, YData, and ZData.

[___] = bwselect3(x,y,z,V,xi,yi,zi) establishes a nondefault world coordinate system for V from the vectors x, y, and z. The arguments xi, yi, and zi specify voxel coordinates in the world coordinate system.

Examples

collapse all

Load a volume and change its name to V.

load mristack;
V = mristack;

Define a set of points in the volume.

C = [126 87 11];
R = [34 120 20];
P = [20 2 12];

Return a volume that contains objects that intersect with the points specified.

J = bwselect3(V,C,R,P);

Input Arguments

collapse all

Binary volume, specified as a 3-D numeric array or 3-D logical array.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Row index of voxels in objects of interest, specified as a numeric scalar or numeric vector. If you specify a vector, then r must be the same length as c and p. The output binary volume J contains the sets of objects overlapping with any of the voxels (r(k), c(k), p(k)), where k is an index into the vector.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Column index of voxels in objects of interest, specified as a numeric scalar or numeric vector. If you specify a vector, then c must be the same length as r and p. The output binary volume J contains the sets of objects overlapping with any of the voxels (r(k), c(k), p(k)), where k is an index into the vector.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Plane index of voxels in objects of interest, specified as a numeric scalar or numeric vector. If you specify a vector, then p must be the same length as r and c. The output binary volume J contains the sets of objects overlapping with any of the voxels (r(k), c(k), p(k)), where k is an index into the vector.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Connectivity, specified as one of these values.

Connectivities

ValueConnectivity
66-connected objects (Face-Face)
1818-connected objects (Face-Face and Edge-Edge)
2626-connected objects (Face-Face, Edge-Edge, and Vertex-Vertex)

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

World x-axis coordinates, specified as a numeric scalar or numeric vector of the same length as y and z. Use x, y, and z to establish a nondefault spatial coordinate system. If you do not specify a coordinate system, then by default bwselect3 uses the intrinsic coordinate system in which x is [1, size(J,2)].

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

World y-axis coordinates, specified as a numeric scalar or numeric vector of the same length as x and z. Use x, y, and z to establish a nondefault spatial coordinate system. If you do not specify a coordinate system, then by default bwselect3 uses the intrinsic coordinate system in which y is [1, size(J,1)].

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

World z-axis coordinates, specified as a numeric scalar or numeric vector of the same length as x and y. Use x, y, and z to establish a nondefault spatial coordinate system. If you do not specify a coordinate system, then by default bwselect3 uses the intrinsic coordinate system in which z is [1, size(J,3)].

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

x-coordinates of voxels in the world coordinate system, specified as a numeric scalar or numeric vector.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

y-coordinates of voxels in the world coordinate system, specified as a numeric scalar or numeric vector.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

z-coordinates of voxels in the world coordinate system, specified as a numeric scalar or numeric vector.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Output Arguments

collapse all

Binary volume containing objects that overlap specified voxels, returned as a 3-D logical array. J contains the set of objects overlapping with any of the voxels specified by r,c, and p, or xi,yi, and zi.

Linear indices of the voxels belonging to the selected objects, returned as a numeric vector.

Version History

Introduced in R2017b