MATLAB: How to get the 1st and the 3rd boundary objects in the binary image

Image Processing Toolboximage segmentation

i segmented an image and got a binary image bw
when i do the below line, i get only 1 numberOfblobs
[labeledImage, numberOfblobs] = bwlabel(bw, 8);
but when i do
structBoundaries = bwboundaries(bw);
i get 5 boundaries, and i need only the 1st and the 3rd boundary objects in the binary image. How to get it in a new binary image with only the first and the third region?

Best Answer

Isn't it
structBoundaries([1 3])
?
By the way structBoundaries is a very misleading name, implying the variable is a structure when it is actually a cell array.