How to perform multiple AND operations inside the loop?

I have a binary image "I", and 40 binary images "test01" to "test40"...all the images have same resolution...I want to AND the image I with the 40 test images one by one and then take the sum to find out the maximum sum to get the best matching image...how to perform ANDing using loop instead of doing it multiple times...thanks in advance

댓글 수: 3

Not clear
peyush
peyush 2015년 7월 23일
편집: peyush 2015년 7월 23일
I am doing pettern recognition, I have an image "I" which I want to compare with 40 images having different patterns...I want to AND the image "I" with all the 40 images one by one to find out the best matching pettern....hope I am clear now
am I clear now...pls I need answer

댓글을 달려면 로그인하십시오.

 채택된 답변

Jon
Jon 2015년 7월 23일
편집: Jon 2015년 7월 23일
Why not just
sum(abs(imsubtract(im1,im2)))
which will return the number of pixels that are different between im1 and im2. There are much more sophisticated ways, but this is a decent start.

댓글 수: 3

peyush
peyush 2015년 7월 24일
편집: peyush 2015년 7월 24일
thanks but this will subtract only two images, and I have to do it 40 times...but I want to write it once and apply the loop...how can I do this...I will surely accept your answer if you help me
If you can't figure that out, you might be in over your head. Just put it in a loop, e.g.
im_to_match = I; % the image for which you're looking for a best match
imsum(40) = 0; % preallocate solution
for i = 1:40
im2compare = yourimagestructure(i); % call the image you want to compare against
imsum(i) = sum(abs(imsubtract(im_to_match,im2))); % do the comparison
end
[~,best_match_i] = min(imsum); % returns the image with fewest differences (in a pixel-by-pixel sense)
thanks

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

질문:

2015년 7월 22일

댓글:

2015년 7월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by