1
votes

I want to create array of MSERRegions class.Basically i have one array of same type returned by function detectMSERFeatures.See code snippet below


regions = detectMSERFeatures(gray_input)
%gray_input is any image in gray scall form
for (i =2:length(regions))
       if(length(regions(i).PixelList)>100)
           % Here i want to copy all such regions in new object array say of name regions_new
           j=j+1;
       end
end

How can this be done?

2

2 Answers

0
votes

You cannot have an array of MSERRegions objects. You should use a cell array instead.

0
votes

You can declare an MSER Array in MatLab like this:

    regions = MSERRegions();

And add them into the array like this:

    regions(1,1) = mserRegions(i,1);

So:

regions_new = MSERRegions();
j = 1;
for (i = 1:length(regions))
   if(length(regions(i).PixelList)>100)
       regions_new(j,1) = regions(i,1)
       j = j + 1;
   end 
end