ismember with regionprops returning all zeros?

조회 수: 4(최근 30일)
Nicholas Mauro
Nicholas Mauro 2023년 3월 19일
답변: Image Analyst 2023년 3월 19일
I am trying to find the closest objects in a new frame with the same area as objects in a previous frame and then remove all extra objects from the new frame. I have generated a set of indicies for the area and centroid values I want to keep within the arrays created by the regionprops function. I attempted to use ismember to remove all other objects but the output is an all zero array. Based on the page for regionprops talking about using it with ismember, I expected giving ismember an image and indicies would return an image with the regions corresponding to the provided indicies, and as far as I can tell that is what I am inputting. I've attached the variable and an example of my use of ismember. Can anyone let me know what I am missing?
%Loading in files and converting type
currentFrame = load('New_Frame_Image.mat');
currentFrame = logical(cell2mat(struct2cell(currentFrame)));
matching_indicies = load('Indicies_of_Closest_Matching_Area_New_Frame.mat');
matching_indicies = cell2mat(struct2cell(matching_indicies));
%Using ismember
newImage = ismember(currentFrame,matching_indicies);
zero_entries = numel(newImage==0) %512x512 image
zero_entries = 262144


Image Analyst
Image Analyst 2023년 3월 19일
You're missing a call to pdist2 (in the Stats toolbox I believe).
If you still need help, attach the two segmented (binary) images (one for each frame) and I'll show you how to do it.

Community Treasure Hunt

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

Start Hunting!

Translated by