bwselect() - Image Processing
BW2 = bwselect(BW,c,r,n) returns
a binary image containing the objects that overlap the pixel (r,c),
where n specifies the connectivity. Objects are
connected sets of on pixels, that is, pixels having
a value of 1. By default, bwselect looks
for 4-connected objects.BW2 = bwselect(BW,n) displays
the image BW on the screen and lets you select
the (r,c) coordinates using the mouse. If you omit BW, bwselect operates
on the image in the current axes. Use normal button clicks to add
points. Press Backspace or Delete to
remove the previously selected point. A shift-click, right-click,
or double-click selects the final point; press Return to
finish the selection without adding a point.[BW2, idx]
= bwselect(___) returns the linear indices
of the pixels belonging to the selected objects.BW2 = bwselect(x,y,BW,xi,yi,n) uses
the vectors x and y to establish
a nondefault spatial coordinate system for BW.
The arguments xi and yi are
scalars or equal-length vectors that specify locations in this coordinate
system.[x,y,BW2,idx,xi,yi]
= bwselect(___) returns the XData and YData in x and y,
the output image in BW2, linear indices of all
the pixels belonging to the selected objects in idx,
and the specified spatial coordinates in xi and yi.Code Generation support:
Yes.MATLAB Function Block support:
Yes.
Syntax
BW2 = bwselect(BW,c,r,n) exampleBW2 = bwselect(BW,n)[BW2, idx]
= bwselect(___)BW2 = bwselect(x,y,BW,xi,yi,n)[x,y,BW2,idx,xi,yi]
= bwselect(___)
Example
Select Objects in Binary ImageOpen This Example
Select objects in a binary image and create a new image containing only those objects.
Read binary image into the workspace.BW = imread('text.png');
Specify the locations of objects in the image using row and column indices.c = [43 185 212];
r = [38 68 181];
Create a new binary image containing only the selected objects. This example specifies 4-connected objects.BW2 = bwselect(BW,c,r,4);
Display the original image and the new image side-by-side.imshowpair(BW,BW2,'montage');
Output / Return Value
Limitations
Alternatives / See Also
Reference