1
votes

I am using the detectMSERFeatures function in the computer vision toolbox of MATLAB and have been running into a few errors. I have a black and white image that I am reading in to detect the features of, however I want to invert the image before running the feature detection or I am filtering for the red in an image. Therefore, either way I have a binary image that I am trying to use in detectMSERFeatures. I know that does not work, but I have tried several conversions to a usable format and none of them have seemed to work. detectMSERFeatures will pick up features if I use rgb2gray on the original image, but not if I try to convert it. Here is everything I have tried so far:

Target1=imread('Decal0.JPG');
Target1bw=~im2bw(Target1);
Target=uint8(Target1bw); 

[m,n]=size(Target);
regionsTarget = detectMSERFeatures(Target, 'MaxAreaVariation',0.15,...
'ThresholdDelta',15, 'RegionAreaRange',[10000 (m*n)/2]);  

Target1=imread('Decal0.JPG');
Target1bw=~im2bw(Target1);
Target=im2double(Target1bw);  

regionsTarget = detectMSERFeatures(Target, 'MaxAreaVariation',0.15,...
'ThresholdDelta',15, 'RegionAreaRange',[10000 (m*n)/2]); 

Target1=imread('Decal0.JPG');
Target1bw=~im2bw(Target1);
Target2=255*Target1bw;
[m,n]=size(Target2);
Target3=zeros(m,n,3);
Target3(:,:,1)=Target2;
Target3(:,:,2)=Target2;
Target3(:,:,3)=Target2;
Target3=uint8(Target3);
Target=rgb2gray(Target3);

regionsTarget = detectMSERFeatures(Target, 'MaxAreaVariation',0.15,...
'ThresholdDelta',15, 'RegionAreaRange',[10000 (m*n)/2]); 

What have I done incorrectly?

1
Post your original images so we can test your code and get your results - Ander Biguri
Post your edit as an aswer, it may be helofull! - Ander Biguri

1 Answers

1
votes

I brought the question up to Mathworks and it was a bug in MATLAB. Here is their response:

"We have detected a bug in detectMSERFeatures when it handles binary images. A workaround would be is to use regionprops to detect the regions for binary images. Then, MSERRegions can be constructed as follows:

props = regionprops(im2bw(newGrayTarget),'PixelList');

pixlist = {}

for i = 1:numel(props)
  pixlist = [pixlist; int32(props(i).PixelList)]; end

r = MSERRegions(pixlist);

Thanks for the help!