MATLAB Answers

Kim Yu Jo

Using 'ismember' against multiple sets of parameters

Asked by Kim Yu Jo
on 4 Jan 2013

Hi there,

I'm trying to find two sets of parameters (Keeper_Indexes 1 & 2), and locate them on an image (Labeled_Image):

Keeper_Indexes1=find( 0.7 < para1 & para1 < 0.72);
Keeper_Indexes2=find( 0.9 < para1 & para1 < 0.905);
PossibleCracks1 = ismember(Labeled_Image, Keeper_Indexes1);
PossibleCracks2 = ismember(Labeled_Image, Keeper_Indexes2);
figure, imshow(PossibleCracks1,'DisplayRange', []),title('Possible Cracks1');
figure, imshow(PossibleCracks2,'DisplayRange', []),title('Possible Cracks2');

This is the current code i'm using, however, is there a way to integrate Keeper_Indexes 1 & 2 together, or to integrate two ismember functions into one? Meaning, figuratively,

Keeper_Indexes = find( 0.9 < para1 & para1 < 0.905) & find( 0.7 < para1 & para1 < 0.72);
TotalPossibleCracks = PossibleCracks1 + PossibleCracks2

Thank you for your help!

  1 Comment

My guess is you can bypass both find() and ismember() with simple logical indexing.

Please post small example matrices (or explain how we can create sample matrixes) so that we can reproduce it.


No products are associated with this question.

1 Answer

Answer by Image Analyst
on 4 Jan 2013
 Accepted answer

Yes, you can combine the lines. Just do

Keeper_Indexes = [Keeper_Indexes1, Keeper_Indexes2];
PossibleCracks = ismember(Labeled_Image, Keeper_Indexes);
imshow(PossibleCracks>0); % Binarize and display.

  1 Comment

Thank you very much!! =)

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!