How do I combine regions of regionprops?

A
Andreas · Feb 15, 2024 · 1.9K views
Question
Hello, I use regionprops to get different regions within an image.   Obj = regionprops(~bw,{'Area','Extrema','Boundingbox','MajorAxisLength','MinorAxisLength','ConvexHull','Centroid'}); According to some assumptions I would like to recombine some Objs of the struct   For example I would like to combine 2 objects where the y-coordinate of the centroid is quite similar. This means, that the some values, Area, Centroid, Bounding Box have to be recalculated. What would be the correct way to do that?
Expert Answer
Profile picture of John Michell
John Michell PhD Expert
Answered Aug 19, 2026

I believe you can set the label to be the same. For example, make blob 3 have a label of 2 and then blob 2 will now be the old blob 2 and the old blob 3

 

labeledImage(labeledImage == 3) = 2;  % Merge blob 3 into blob 2.

Now call regionprops

props = regionprops(labeledImage, .........

 

100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!