function Multi_images()
%Simple GUI example to show how to use NEXT and BACK buttons.
%Images should be of same size and class.
i=1;%initialize the pointer
figure('units','pixels','position',[350 150 500 380],'menubar','none','numbertitle','off',...
'name','GUI EXAMPLE(1)','resize','off');
NX = uicontrol('style','push','units','pixels','position',[265 10 150 30],...
'fontsize',14,'string','NEXT','callback',{@nextButton});
BK = uicontrol('style','push','units','pixels', 'position',[105 10 150 30],...
'fontsize',14,'string','BACK','callback',{@backButton});
set(BK,'visible','off');
FN = {'cameraman.tif','rice.png','testpat1.png'}';
no = numel(FN);%Returns the number of elements.
A = imread(FN{1});
imshow(A);
%Allocation: size, No of images, image type(uint8,uint16,logical,...)
images = zeros([size(A) no],class(A));
images(:,:,1) = A;
%Create multiple images array.
for inc = 2:no
images(:,:,inc) = imread(FN{inc});
end
%Pushbutton function for NEXT
function nextButton(source,eventdata)
if(i < = no)
i=i+1;
set(BK,'Visible','on');
set(NX,'Visible','on');
else
set(NX,'Visible','off');
end
if(i==no)
set(NX,'Visible','off');
end
imshow(images(:,:,i));
end
%Pushbutton function for BACK
function backButton(source,eventdata)
if(i < = 1)
i=i-1;
set(NX,'Visible','on');
set(BK,'Visible','on');
else
%Set the Back button invisible
set(BK,'Visible','off');
end
if(i==1)
%Set the Back button invisible
set(BK,'Visible','off');
end
imshow(images(:,:,i));
end
%Simple GUI example to show how to use NEXT and BACK buttons.
%Images should be of same size and class.
i=1;%initialize the pointer
figure('units','pixels','position',[350 150 500 380],'menubar','none','numbertitle','off',...
'name','GUI EXAMPLE(1)','resize','off');
NX = uicontrol('style','push','units','pixels','position',[265 10 150 30],...
'fontsize',14,'string','NEXT','callback',{@nextButton});
BK = uicontrol('style','push','units','pixels', 'position',[105 10 150 30],...
'fontsize',14,'string','BACK','callback',{@backButton});
set(BK,'visible','off');
FN = {'cameraman.tif','rice.png','testpat1.png'}';
no = numel(FN);%Returns the number of elements.
A = imread(FN{1});
imshow(A);
%Allocation: size, No of images, image type(uint8,uint16,logical,...)
images = zeros([size(A) no],class(A));
images(:,:,1) = A;
%Create multiple images array.
for inc = 2:no
images(:,:,inc) = imread(FN{inc});
end
%Pushbutton function for NEXT
function nextButton(source,eventdata)
if(i < = no)
i=i+1;
set(BK,'Visible','on');
set(NX,'Visible','on');
else
set(NX,'Visible','off');
end
if(i==no)
set(NX,'Visible','off');
end
imshow(images(:,:,i));
end
%Pushbutton function for BACK
function backButton(source,eventdata)
if(i < = 1)
i=i-1;
set(NX,'Visible','on');
set(BK,'Visible','on');
else
%Set the Back button invisible
set(BK,'Visible','off');
end
if(i==1)
%Set the Back button invisible
set(BK,'Visible','off');
end
imshow(images(:,:,i));
end
Contact:
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704
Email: roshanphelonde@rediffmail.com