I'm confused. What is the "main matrix" part of the image? And what are pores and what is background? The images look the same, just cropped. I don't see any inverting nor do I see why it's needed.
I'll assume you want the white blobs but not the white circular surround. So simply use a circular template mask to get rid of it:
binaryImage(circularMask) = false;
or call imclearborder() to get rid of the circular surround
binaryImage = imclearborder(binaryImage);
imclearborder will also remove and partial blobs crossing the circular border, which is not a bad thing - just depends if you want area fraction and partial blobs are okay, or if you need complete blobs for your computations.
Then call imrect() or rbbox() to define the cropping rectangle, call imcrop() or use indexing to actually make the crop, and you're done.
Best Answer