Contents
clearing and constant setting
clear;
close all;
clc;
bool_exit = 0;
threshold = 0.7;
maxima = []; stack = [];
filenum = 34;
line = 690;
get the first image
[filename, pathname] = uigetfile({'*.jpg', 'JPG-Images (*.jpg)'},...
'load the 1st image (e.g. prefix_1.jpg)');
imagePrefix = strrep(filename, '1.jpg', '');
if (strcmp(imagePrefix,filename) == false)
info=imfinfo([pathname,imagePrefix,'1'],'jpg');
h = waitbar(0,'Executing Script, wait........', 'Name',...
'Problem 4: Waitbar', 'CreateCancelBtn','button_callback',...
'CloseRequestFcn','button_callback');
for i=1:filenum,
if (bool_exit == 0)
filename = [[pathname,imagePrefix],num2str(i),'.jpg'];
I = imread(filename);
hf = rgb2gray(double(I)/255);
hf = imcrop(hf, [0 line info.Width 20]);
ehf = histeq(hf, 32);
xi = [0 info.Width]; yi = [10 10];
c = improfile(ehf,xi,yi);
c = slidingavg(c,7);
index = find(c>=threshold);
s_edge = index(length(index));
maxima = [maxima; s_edge];
stack = [stack; c'];
waitbar(i/filenum)
else
break;
end
end
if (bool_exit == 0)
delete(h);
time = (6:1/2:22.5);
x = (1:1:1024);
figure(2),
set(2, 'Name', 'Problem 4: Timestack Image', 'Position', ...
[200 100 600 480], 'Color', [0 0 0.3],'NumberTitle','off');
ax1 = subplot (3,3,1:3);
h1 = plot(c);
axis([0 1024 0 1]);
t1 = text(-75,0.5,'Intensity');
ax2 = subplot (3,3,4:9);
h2 = imagesc(x,time,stack);
colormap gray;
hold on;
h3 = plot(maxima, time, 'ro');
hold on;
t3 = text(300,14,'maximum over threshold');
title('SHORELINE HISTORY','fontweight','bold','color',...
[0.5 0.5 0.5]);
t2 = text(-75,16,'Time (hours on 24-JUL-2005)');
xlabel('Cross-shore distance (pixels)');
set(h1, 'Color', [0.1 0.9 0.1]);
set([ax1 ax2], 'XColor', [1 1 1], 'Color', [0 0 0], ...
'YColor', [1 1 1], 'fontsize',8);
set([t1 t2], 'horizontalalignment','center','rotation',90,...
'fontsize',8,'fontangle','italic', 'color', [1 1 1]);
set(t3, 'color', [1,0,0], 'fontweight', 'bold');
end
else
errordlg('invalid image name, e.g. prefix_1.jpg');
end