フィルターのクリア

Which image is not like the others?

1 回表示 (過去 30 日間)
Ron Volkovinsky
Ron Volkovinsky 2020 年 7 月 19 日
コメント済み: Image Analyst 2020 年 7 月 19 日
I have four RGB images I1, I2, I3, and I4. 3 of them are exactly the same, and one is different. Is there an elegant solution to find which image is different? Currently, I'm using something like the following.
if ~isequal(I1, I2) & ~isequal(I1, I3) & ~isequal(I1, I4)
dif = I1
elseif ~isequal(I2, I1) & ~isequal(I2, I3) & ~isequal(I2, I4)
dif = I2
%etc.
end

採用された回答

Abhishek Gangwar
Abhishek Gangwar 2020 年 7 月 19 日
Compute difference of two images using "imabsdiff()" function, output of this function would be a matrix if both images are same, resulting matrix would have all zeros, you can use this logic.
for example:-
diff1 = imabsdiff(I1, I2);
diff2 = imabsdiff(I2, I3);
diff3 = imabsdiff(I3, I4);
diff4 = imabsdiff(I4, I1);
if sum(sum(diff1)) == 0 && sum(sum(diff2)) == 0 && sum(sum(diff3)) ~= 0 && sum(sum(diff4)) ~= 0
diff = I4;
elseif sum(sum(diff1)) == 0 && sum(sum(diff2)) ~= 0 && sum(sum(diff3)) ~= 0 && sum(sum(diff4)) == 0
diff = I3;
elseif sum(sum(diff1)) ~= 0 && sum(sum(diff2)) ~= 0 && sum(sum(diff3)) == 0 && sum(sum(diff4)) == 0
diff = I2;
elseif sum(sum(diff1)) ~= 0 && sum(sum(diff2)) == 0 && sum(sum(diff3)) == 0 && sum(sum(diff4)) ~= 0
diff = I1;
end
  1 件のコメント
Image Analyst
Image Analyst 2020 年 7 月 19 日
diff is a built in function so you should use a different name for your output variable.

サインインしてコメントする。

その他の回答 (1 件)

KSSV
KSSV 2020 年 7 月 19 日
編集済み: KSSV 2020 年 7 月 19 日
n = numel(I1) ;
if nnz(I1==I2==I3) == n
dif = I4 ;
elseif nnz(I2==I3==I4) == n
dif = I1 ;
elseif nnz(I3==I4==I1) == n
dif = I2 ;
else
dif = I3 ;
end

カテゴリ

Help Center および File ExchangeImages についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by