Going with what the glass was talking about, and what would you like to do, I will personally convert your image to binary, where false represents the background and true represents the foreground. When you are done, you then destroy this image using a good structuring element that preserves the roundness of the contours of your objects ( disk in your example).
The result will be the interior of the large object that is in the image. What you can do is use this mask and set these places in the image to black to maintain the outer range. Essentially try to do something like this:
%// Read in image (directly from StackOverflow) and pseudo-colour the image [im,map] = imread('http://i.stack.imgur.com/OxFwB.png'); out = ind2rgb(im, map); %// Threshold the grayscale version im_b = im > 10; %// Create structuring element that removes border se = strel('disk',7); %// Erode thresholded image to get final mask erode_b = imerode(im_b, se); %// Duplicate mask in 3D mask_3D = cat(3, erode_b, erode_b, erode_b); %// Find indices that are true and black out result final = out; final(mask_3D) = 0; figure; imshow(final);
Skip the code slowly. The first two lines take your PNG image, which contains a grayscale image and a color map, and we read both of them in MATLAB. Then we use ind2rgb to convert the image to its false color version. When we do this, we use the grayscale image and the image threshold so that we capture all the pixels of the objects. I have a threshold image with a value of 10 to avoid some of the quantization noises that are visible in the image. This binary image is what we will work on to determine the pixels that we want to set to 0 to get the outer border.
Then we declare a structuring element, which is a disk of radius 7, and then blur the mask. As soon as I finish, I duplicate this mask in 3D so that it has the same number of channels as the pseudocolor image, and then use the mask location to set the values ββthat are internal to the object to 0. The result will be the original image, but the remains of the external contours of all objects remain.
The result is:

source share