フィルターのクリア

finding maximum abs value of four images

3 ビュー (過去 30 日間)
Mahua Nandy(Pal)
Mahua Nandy(Pal) 2013 年 3 月 16 日
I have four 16x16 images.I want to form another image by taking the maximum abs value of all four values of a particular pixel e.g. by comparing I1(3,3),I2(3,3),I3(3,3) and I4(3,3),I will be getting I5(3,3).
my piece of code is:
for k:4
.......
figure,imshow(B);
s=size(B)
eval(sprintf('im_%d=B;',k));
end
  1 件のコメント
Jan
Jan 2013 年 3 月 16 日
Avoid using EVAL to hide an index in the name of a variable. It is much easier, nicer and more efficient to use an index as index:
im = cell(1, 4);
for k = 1:4
...
im{k} = B;
end

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

採用された回答

Matt Kindig
Matt Kindig 2013 年 3 月 16 日
No loops necessary:
CombinedImages = cat(3, I1, I2, I3, I4)
I5 = max(abs(CombinedImages),[],3)
  1 件のコメント
Mahua Nandy(Pal)
Mahua Nandy(Pal) 2013 年 3 月 17 日
thanks a lot

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

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 16 日
[n,m]=size(im1);
for k=1:n
for p=1:m
v=[im1(k,p) im2(k,p) im3(k,p) im4(k,p)];
[~,idx]=max(abs(v));
im(k,p)=v(idx);
end
end

Community Treasure Hunt

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

Start Hunting!

Translated by