Save ROI and background in two images

I'm using MATLAB Training Image Labeler app for labeling images and exporting the regions of interest (ROIs) which I save in .jpeg files.The ROIs are exported as a structure $1\times 430$ with two fields (name and objectBoundingBoxes, containining the ROI $[x, y, \textrm{width}, \textrm{height}]$ information). I would do the same job but for the area out of the ROI (background). Is it possible to save the background, using a similar method?

My purpose is obtaining the rectangles around the ROIs so I can label them as background. In the dataset I can have multiple ROIs for single image, so the best solution would be obtaining upper, left, right and lower rectangles of the proposed ROI.

• Welcome to DSP.SE. Although it is about MATLAB specifically, I like the question - very interesting topic. Can you please provide more details about your problem? – jojek Jun 15 '16 at 19:34
• Some additional questions that come to mind: What should be saved of the non-ROI image? The whole image, but with the ROI blanked out? What sort of blanking? Or do you want upper, left, right, and lower rectangles of the remainder of the image? Can you have multiple ROIs in a single image? If so, is it OK to blank all of them out? Or do you have a different definition for the background? It is just a rectangular region, like an ROI, tha you use for a different purpose? – Peter K. Jun 15 '16 at 20:25
• You are right, I'll explain in a better way. My purpose is obtaining the rectangles around the ROIs so I can label them as background. In the dataset I can have multiple ROIs for single image, so the best solution would be obtaining upper, left, right and lower rectangles of the proposed ROI. Thanks in advance. – Ruggero Jun 16 '16 at 6:08