# bwselect3

Select objects in binary image

## Syntax

``J = bwselect3(V,C,R,P)``
``J = bwselect3(X,Y,Z,V,Xi,Yi,Zi)``
``[J] = bwselect3(___,N)``
``[J,idx] = bwselect3(___)``
``[X,Y,Z,J,Xi,Yi,Zi] = bwselect3(___)``
``[X,Y,Z,J,idx,Xi,Yi,Zi] = bwselect3(___)``

## Description

example

````J = bwselect3(V,C,R,P)` returns the binary volume `J` containing the objects that overlap the pixel location (`R`,`C`,`P`). `R`,`C`, and `P` are scalars or equal-length vectors that specify the row, column, and plane index of the pixel location. Objects are connected sets of pixels with the value `1`.If you specify `R`,`C`, and `P` as vectors, `J` contains the set of objects overlapping with any of the pixels (R(k),C(k),P(k)), where k is an index into the vector. ```
````J = bwselect3(X,Y,Z,V,Xi,Yi,Zi)` uses the vectors `X`, `Y`, and `Z` to establish a nondefault spatial coordinate system for `V`. `Xi`, `Yi`, and `Zi` are scalars or equal-length vectors that specify pixel locations in this coordinate system.```
````[J] = bwselect3(___,N)` returns a binary volume where `N` specifies the connectivity used to define objects.```
````[J,idx] = bwselect3(___)` returns `idx`, a column vector of linear indices specifying the pixels belonging to the selected objects.```
````[X,Y,Z,J,Xi,Yi,Zi] = bwselect3(___)` returns the binary volume `J`, along with the `XData`, `YData`, and `ZData` of the output volume in `X`,`Y`, and `Z`. `Xi`,`Yi`, and `Zi` contain the specified spatial coordinates.```
````[X,Y,Z,J,idx,Xi,Yi,Zi] = bwselect3(___)`returns the binary volume `J`, along with `idx`, a column vector of linear indices specifying the pixels belonging to the selected objects.```

## 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

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

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

Row index of object, specified as a numeric scalar or vector. If you specify a vector, `R` must be the same length as `C` and `P`.

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

Column index of object, specified as a scalar or vector. If you specify a vector, `C` must be the same length as `R` and `P`.

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

Plane index of object, specified as a scalar or vector. If you specify a vector, `P` must be the same length as `R` and `C`.

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

Connectivity, specified as `6`, `18`, or `26`. Objects are connected sets of pixels with the value `1`.

Connectivities

ValueConnectivity
`6`6-connected objects (Face-Face)
`18`18-connected objects (Face-Face and Edge-Edge)
`26`26-connected objects (Face-Face, Edge-Edge, and Vertex-Vertex)

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

Limits of nondefault coordinate system in X direction, specified as a vector.

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

Limits of nondefault coordinate system in Y direction, specified as a vector.

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

Limits of nondefault coordinate system in Z direction, specified as a vector.

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

X-coordinate of location in nondefault coordinate system, specified as a scalar or vector.

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

Y-coordinate of location in nondefault coordinate system, specified as a scalar or vector.

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

Z-coordinate of location in nondefault coordinate system, specified as a scalar or vector.

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

## Output Arguments

collapse all

Output volume, returned as an N-D logical array. `J` contains the set of objects overlapping with any of the pixels specified by `R`,`C`, and `P`, or `Xi`,`Yi`, and `Zi`.

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

Volume `Xdata` property, returned as a vector.

Volume `Ydata` property, returned as a vector.

Volume `Zdata` property, returned as a vector.

X-coordinate of location in nondefault coordinate system, returned as a scalar or vector.

Y-coordinate of location in nondefault coordinate system, returned as a scalar or vector.

Z-coordinate of location in nondefault coordinate system, returned as a scalar or vector.