Here's an example code to plot the bounding box detected by regionprops in MATLAB:
main.m552 chars22 lines
This code will read an example image, convert it to grayscale, binarize it using Otsu's thresholding method, and perform connected component analysis using bwconncomp. regionprops is used to detect bounding boxes for each connected component, which are then plotted on the original image using rectangle.
gistlibby LogSnag