MATLAB: How to reduce unwanted pixels

Image Processing Toolboximage segmentation

From a grayscale image I already segmented the main region into a binary image. What I want right now is to reduce the unwanted pixels between each part of the main region as much as possible. It's a little bit difficult because as you can see in the original image, there's no change in the intensity. I'm thinking about finding the centroid of the circle and directions of each parts and the angles between them. So that I can set the pixels in the defined region black. It's just an idea and I dont know how to make it work. If you guys have any ideas to solve this problem, please help.
Pictures provided for understanding. Thank you all

Best Answer

Your image looks like a shadowgraph or schlieren image of some spray and it looks like you've got some very strong density gradients in your background. Can your test conditions be better controlled to avoid these density gradient? It may be easier than trying to fix the image processing problem.
Otherwise, finding the centroid of the nozzle is fairly simple. An opening of your binary image should isolate the central part from the sprays.
imgopened = imopen(yourbinaryimage, strel('disk', 8));
imshow(imgopened)
props = regionprops(imgopened, {'Centroid', 'Orientation'});
centroids = vertcat(props.Centroid); %location of centroids of all the blobs
[height, width] = size(imgopened);
[~, row] = min(hypot(centroids(:, 1) - width/2, centroids(:, 2) - height/2)); %find nearest centroid to image centre
nozzlecentroid = centroids(row, :)
hold on; plot(nozzlecentroid(1), nozzlecentroid(2), 'r*');
You could use the orientation property returned by regionprops to help find the axis of the sprays , then find the edge. Sorry I haven't got the time to write that for you.