How to do multiple saves during a loop?
古いコメントを表示
I am trying to write a code into my script that will create an output .jpg for each of my .mat outputs. However it seems to only produce one .jpg because it overwrites each one. My code is listed below. Any help would be great.
Code:
%%Apply angle correction to rectified tranmittance corrected thermal images
% Calculate orientation angle for cells in dem
cd('C:\Users\anson_000\Documents\MATLAB\EMCT_Aug12\Rectified_thermal_im')
list=dir('*.mat');
% Calculate viewing distance components and angle vectdist_x = x0-Xdem; vectdist_y = y0-Ydem; vectdist_z = z0-Zdem; cosang = -(vectdist_x.*theta + vectdist_y.*phi + vectdist_z ) ./ ... ( sqrt( theta.^2+phi.^2+1 ) .* sqrt(vectdist_x.^2+vectdist_y.^2+vectdist_z.^2) );
cosang( cosang<0 ) = NaN;
for zz=1:length(list)
filename=list(zz).name;
output_name=['Temp_fullcorr_' filename(12:24)];
load(list(zz).name);
rect_rad_image = Rect_Planck_radconvers(10.25e-6,tempK_rect);
rad_rect_corrected = NaN*rect_rad_image;
temp_rect_corrected = NaN*tempK_rect;
hot_px = tempK_rect > 312; %Value in K?
rad_rect_corrected(hot_px)=rect_rad_image(hot_px)./cosang(hot_px);
temp_rect_corrected(hot_px)=tempK_rect(hot_px)./(cosang(hot_px).^(1/4));
save(output_name, 'temp_rect_corrected');
% Write an image to show the area identified as hot (white)
imwrite( uint8( cat(3, hot_px, hot_px, hot_px)*255 ), 'image_name.jpg', 'Quality', 100)
end
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Historical Contests についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!