MATLAB: How to crop aportion of an image from in bounding box.

bounding boxComputer Vision Toolboximage proccessing toolboxImage Processing Toolboximcrop

i use open source code in the link https://www.mathworks.com/help/vision/examples/automatically-detect-and-recognize-text-in-natural-images.html to detect text and finally i get an image like below with more than one bounding box and i need to crop each of the bounding box.i know imcrop with for loop can do this.plaese help me?
textBBoxes = [xmin ymin xmax-xmin+1 ymax-ymin+1];
textBBoxes = [xmin ymin xmax-xmin+1 ymax-ymin+1];
numRegionsInGroup = histcounts(componentIndices);
textBBoxes(numRegionsInGroup == 1, 🙂 = [];
ITextRegion = insertShape(colorImage, 'Rectangle', textBBoxes,'LineWidth',3);
figure imshow(ITextRegion) title('Detected Text')
end

Best Answer

Loop over all boxes, calling imcrop() while passing it the rectangle (xLeft, yTop, width, height] for the box.