i hav 384 images.using a for loop i read an img& apply transform on it & store the result in variable named res1 & next i read 2nd img & apply transform on it & store result in variable res2 &so on for rest images.how do i implement this in for loop
2 次查看(过去 30 天)
显示 更早的评论
for i=1:384 %read 1st img. apply transform on it and store result in variable named result1. %during next iteration,read 2nd img,apply transform on it and store result in variable named result2. %similarly for rest images store result in variables names result3,result4,... and so on. % how do i implement this end
0 个评论
回答(2 个)
Image Analyst
2013-12-6
See the FAQ for code examples: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
0 个评论
Alex Taylor
2013-12-6
编辑:Alex Taylor
2013-12-6
This concept of storing each result in a separate named variable is not very "MATLAB-like". It would be more in model to represent this operation as an MxNx384 matrix as input, with an PxQx384 matrix as output.
If by "transform" you mean a geometric transformation, then the good news is you don't need to write a loop to do this, provided you can have all 384 images represented in memory as an MxNx384 matrix.
Take the following example:
I = imread('peppers.png');
tform = affine2d([1 0 0; .5 1 0; 0 0 1]);
J = imwarp(I,tform);
figure, imshow(I), figure, imshow(J)
The Image I is an MxNx3 RGB image. The reason that J is an RGB sheared version of I is that when a 2-D geometric transformation is applied to an N-D matrix, imwarp applies the 2-D transformation to I one plane at a time.
This plane at a time behavior is featured in several other Image Processing Toolbox functions including imfilter, imerode, imdilate, etc. You should not need to write a loop to accomplish this task.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 3-D Volumetric Image Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!