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

 채택된 답변

Orion
Orion 2014년 12월 9일

0 개 추천

I guess all your .jpg are named image_name.jpg ?
Inside the loop, you coded :
imwrite( uint8( cat(3, hot_px, hot_px, hot_px)*255 ), 'image_name.jpg', 'Quality', 100)
so the name is unchanged during the loop.
make something like :
MyImageName = sprintf('image_name%d.jpg',zz);
imwrite( uint8( cat(3, hot_px, hot_px, hot_px)*255 ), MyImageName , 'Quality', 100)

댓글 수: 1

Anson Hancock
Anson Hancock 2014년 12월 9일
Thanks Orion,
That seems to have done the trick.
Cheers.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Historical Contests에 대해 자세히 알아보기

태그

질문:

2014년 12월 9일

댓글:

2014년 12월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by