How to use slider bars to view images from a dataset?
조회 수: 27 (최근 30일)
이전 댓글 표시
Let's say I have loaded a dataset of 100 images and I want to view those images by scrolling the slide bar. If I set my slide bar to 25%( where min limit of slidebar is 0% and max limit is 100%) then 25 images out of 100 should be displayed likewise if I scroll my slidebar upto 89% then 89 images should be displayed. I tried implementing it by loading an array but it doesnt work.
댓글 수: 7
Rik
2019년 6월 27일
Did either suggestion solve your problem? If so, please consider marking it as accepted answer. It will make it easier for other people with the same question to find an answer. If neither solved your question, please comment with what problems you are still having.
답변 (2개)
Rik
2019년 6월 22일
I didn't implement a case for the 0 position, so I just set the range limits from 1 to 100.
%Load an example image
a=imread('cameraman.tif');
%Replicate 100 times
database=repmat(a,1,1,100);
N_images=size(database,3);
%prepare figure and guidata struct
h=struct;
h.f=figure;
h.ax=axes('Parent',h.f,...
'Units','Normalized',...
'Position',[0.1 0.1 0.6 0.8]);
h.slider=uicontrol('Parent',h.f,...
'Units','Normalized',...
'Position',[0.8 0.1 0.1 0.8],...
'Style','Slider',...
'BackgroundColor',[1 1 1],...
'Min',1,'Max',N_images,'Value',1,...
'Callback',@sliderCallback);
%store image database to the guidata struct as well
h.database=database;
guidata(h.f,h)
%trigger a callback
sliderCallback(h.slider)
function sliderCallback(hObject,eventdata)
h=guidata(hObject);
count=round(get(hObject,'Value'));
IM=h.database(:,:,1:count);
IM=permute(IM,[1 2 4 3]);%montage needs the 3rd dim to be the color channel
montage(IM,'Parent',h.ax);
end
댓글 수: 0
Bjorn Gustavsson
2019년 6월 21일
Perhaps have a look at: Imthumb, it might not be exactly what you want, but it might be close enough for you to easily modify...
HTH
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!