How to show a sequence of images
15 views (last 30 days)
My aim is to load a directory with 300 dicom images, to show them and to choose one of all them to modify it later. What I have to do is to show one-by-one all these images, maybe moving of one to the next one with the direction controllers or something similar and when I find the right image, to take a imcrop of it.
I think the Code would be something like this:
archivo = directory(z).name;
Im = (dicomread(archivo));
I think it could be done with a "pause", but I think it would be better if I could do it more interactive with other controllers.
Could you help me?
Adam Wyatt on 31 Mar 2015
Edited: Adam Wyatt on 31 Mar 2015
You need to either add a callback function to the image/figure to respond to user key presses or mouse clicks, or you could add something like getpts.
I would add two buttons to the figure, one states "Next" and the other "Store", and implement callbacks on those buttons (you could even add a previous).
Here is a quick example - I would implement the callbacks a bit differently and not have the while loop at the end, but it illustrates the point:
function Selected = TestFun
I = randn(100, 100, 10);
count = 1;
Selected = ;
h = imagesc(I(:, :, count));
hb1 = uicontrol('Style', 'PushButton', 'String', 'Next', ...
hb2 = uicontrol('Style', 'PushButton', 'String', 'Store', ...
hb1.Position(2) = hb2.Position(2)+1.1*hb2.Position(4);
function NextBtnCB(src, evnt)
if count<size(I, 3)
count = count + 1;
h.CData = I(:, :, count);
function StoreBtnCB(src, evnt)
Selected = count;