How to do multiple saves during a loop?
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Historical Contests in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!