Function handle, specified as a handle. For more information, see Create Function Handle.
Function Inputs
The function fun
must accept at least one block as
input.
Optionally, the function can accept additional inputs that are not blocks. To
perform processing with non-block inputs, you must call the apply
function and specify fun
as an anonymous function. For more
information, see Anonymous Functions.
The table shows sample function signatures for different types of input to
fun
. The table also shows sample syntax to use when calling
apply
.
Input Type | Function Signature | Example of Calling apply |
---|
Single block |
|
|
Two blocks |
| Specify the second bigimage after the handle
to the function
myfun . |
One block and one non-block |
| This example passes a scalar value 37 to the
function
myfun : |
Function Outputs
The function fun
typically returns one or more image blocks
of the same size as the input block. In this case, apply
recombines
the blocks and returns a bigimage
. If you specify the
BorderSize
argument of apply
and desire a
bigimage
output, then apply
will crop the
border from the output blocks. You can also crop the block directly within
fun
.
All of the examples in the above table demonstrate a function signature that
returns a single block. However, the function fun
can also return
structs or other non-image outputs.
The table shows sample function signatures for different types of output of
fun
. The table also shows sample syntaxes to use when calling
apply
.
Output Type | Sample Processing Function | Example of Calling apply |
---|
Block of the same size as the input block |
| bigimageOutput
is a single-resolution bigimage . In this example,
bigimageOutput has the same number of channels and data
type as the input bigimg .
|
Multiple blocks of the same size as the input block |
| bigimageOutput1
is a single-resolution bigimage . In this example, if
bigimgRGB contains a color image, then
bigimageOutput1 has a different number of channels than
the input
bigimgRGB .
bigimageOutput2
is a single-resolution bigimage that has a different
number of channels and a different data type than
bigimgRGB .
|
Non-image |
|
cellArrayOutput is a cell array whose elements
are the non-image output of each block. cellArrayOutput
has one additional column that specifies the (x,y) origin of each block as a
1-by-2 vector.
|
Struct |
| tableOutput
is a table with four variables: num ,
mean , max , and
BlockOrigin . The BlockOrigin
variable specifies the (x,y) origin of each block as a 1-by-2
vector. |
Multiple outputs |
|
c1 is a cell array because the first output of
myfun is a non-image. b2 and
b3 are bigimage s because the second
and third outputs of myfun are image blocks of the same
size as the input block. t4 is a table because the fourth
output of myfun is a struct.
The
apply function ignores the fifth output argument of
myfcn because only four output arguments are specified
in the call to apply . |