I have searched the forums and have not found a work around for my issue.
I am using regionprops that is analyzing a series of pictures in a for loop. The output from regionprops is a structure containing the relevant region properties I want. As I am analyzing many pictures (in a for loop) I would like to update a finalResults structure with each iteration of region prop data.
After all images have been analyzed, I do some data analysis that removes certain objects (i.e. is EquivDiam is smaller than 0.5). Here is my pseudo code:
for ii = 1:10
currentResults = regionprops(currentImage,'Area', 'EquivDiameter');
It appears as though MATLAB won't let me concatenate the currentResults structure, with another structure, i.e.
finalResults = (finalResults,currentResults);
as I could do with a simple array. My work around this is to convert the currentResults structure into individual arrays, concatenate the results, and then convert back into a structure, as shown below:
Area = [currentResults(:).Area];
resultsArea = [resultsArea,Area];
EquivDiameter = [currentResults(:).EquivDiameter];
resultsEquivDiameter = [resultsEquivDiameter,EquivDiameter];
finalResults = struct('Area', resultsArea, 'EquivDiameter', resultsEquivDiameter);
This works but is not a very elegant solution. It seems to me very straight forward to want to update a structure within a for loop. Any ideas?
For data analysis as well, I can index the values of Area that are less than a certain threshold, but again, have to to call each individual array inside the structure to delete, i.e.:
Instead of just calling the row number of the structure and deleting the indexed rows from each field of the finalResults structure:
finalResults(index) = ;
Matrix index is out of range for deletion.
There has to be an easier way to work with structures in Matlab.
Any help would be greatly appreciated.