detect MSER output - reduce output

1 view (last 30 days)
I'm trying to get a reasonable count of the number of busses in a satellite image, using `detectMSER` looks great as a starting point - except for the fact that each region has numerous almost identical ellipsoids that overlap. This is the best I can get it, and I've played around with all the input variables. For example, in the image below I expect to have about a 100 regions but there are over 2200. Each bus has 7 or 8 ellipsoids.
I can use regionprops to, for the most part, remove artifacts, but not sure how to just keep just one region for each bus.
Ive tried rounding together centroid location significant digits, using bounding box overlap, filtering based on orientation, etc, but everything I do seems to remove good values.
This has to scale (I have 20k images to cycle through, so need to automate this). Thanks in advance.
[regions, mserConnComp] = detectMSERFeatures(img_bw, ...
'RegionAreaRange',[300 900], ...
'ThresholdDelta', 3,...
'MaxAreaVariation', 0.2);

Accepted Answer

Aishwarya
Aishwarya on 3 Nov 2023
Hello,
I understand that you are facing difficulty when implementing "detectMSERFeatures" function to count the number of buses in the satellite image.
I would like to suggest an alternative method to count the number of buses in the image.
The approach is to use morphological operations on a binary image to extract the buses as blobs. Then, the "regionprops" function can be utilized to count the number of blobs using the "Area" property as a threshold.
Here is an example implementation of this technique on a sample image:
% Read the image
img = imread('top_view.jpg');
% Convert the image to grayscale
gray_img = rgb2gray(img);
% Threshold the image to create a binary image (adjust the threshold as required)
binary_img = gray_img > 150;
% Perform morphological operations to remove noise and fill gaps (adjust structuring element as required)
se = strel('disk', 7);
binary_img = imopen(binary_img, se);
binary_img = imclose(binary_img, se);
% Perform blob analysis to count the number of buses
blob_analysis = regionprops(binary_img, 'Area');
num_buses = length(find([blob_analysis.Area] > 1000));
% Display the result
disp(['Number of buses: ', num2str(num_buses)]);
Number of buses: 24
Please refer to the below MathWorks documentations for more information about the functions used:
I hope this helps!
  1 Comment
Adam Campos
Adam Campos on 3 Nov 2023
Thank you for the response Aishwarya
The issue is more of the mass replication of almost identical layers from MSER as opposed to bad results - the results from MSER themselves work great for my purposes, and this is the first step of about 15 operations, so I don't want to remove noise, fill in gaps with morphology, or set thresholds at this stage because I've got 11k images of various complexity and some have completely different characteristics. I found a work around of aggregating the centroids of similar regions, and I'm talking to someone at MATLAB about perhaps updating the algorithm.

Sign in to comment.

More Answers (0)

Products


Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!