Subtracting velues in cell

3 次查看(过去 30 天)
kash
kash 2012-10-3
I have a code
for xx = 1:length(dirlist(1))
x = imread([pathname, dirlist(xx).name]);
x=rgb2gray(x);
x=imresize(x,[256 256]);
C = mat2cell(x,[128 128],[128 128]);
end
for xx = 1:length(dirlist)
x = imread([pathname, dirlist(xx).name]);
x=rgb2gray(x);
x=imresize(x,[256 256]);
C1 = mat2cell(x,[128 128],[128 128]);
,,,,,,,,,,
,,,,,,,,,,
,,,,,,,,,,
end
I want to subtract values in C and C1,in dirlist I have 50 Images..I have taken reference frame and subtracted with other frames ..after C1 ,i want to subtract C with C1,please help

采纳的回答

Matt J
Matt J 2012-10-3
The best thing would be to subtract first and do MAT2CELL second:
for xx = 1:length(dirlist(1))
x = imread([pathname, dirlist(xx).name]);
x=rgb2gray(x);
C=imresize(x,[256 256]);
end
for xx = 1:length(dirlist)
x = imread([pathname, dirlist(xx).name]);
x=rgb2gray(x);
C1=imresize(x,[256 256]);
end
D=mat2cell(C-C1,[128,128],[128,128]);
Alternatively, you can use CELLFUN:
D=cellfun(@(a,b) a-b, C1, C2, 'uni',0);
  2 个评论
kash
kash 2012-10-3
MAth ur first results gives error ,secong works i.e cell fun,as i sais i have 50 images ,so i have to get 50 such values but i get only one,
please help
Matt J
Matt J 2012-10-3
If it works for 1 image, then why not just repeat the procedure in a loop to do all 50.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by