How to show a sequence of images

조회 수: 19 (최근 30일)
Jose Andrés
Jose Andrés 2015년 3월 31일
댓글: Jose Andrés 2015년 4월 2일
Hello everyone,
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:
for z=1:size(directory)
archivo = directory(z).name;
Im = (dicomread(archivo));
Im=imadjust(Im);
imshow(Im);
XXXXXXXXXXXXXXX
imcrop(Im)
end
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?
Thank you!

답변 (3개)

Adam Wyatt
Adam Wyatt 2015년 3월 31일
편집: Adam Wyatt 2015년 3월 31일
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
clf;
I = randn(100, 100, 10);
count = 1;
Selected = [];
h = imagesc(I(:, :, count));
hb1 = uicontrol('Style', 'PushButton', 'String', 'Next', ...
'Callback', @NextBtnCB);
hb2 = uicontrol('Style', 'PushButton', 'String', 'Store', ...
'Callback', @StoreBtnCB);
hb1.Position(2) = hb2.Position(2)+1.1*hb2.Position(4);
while isempty(Selected)
pause(.1);
end
function NextBtnCB(src, evnt)
if count<size(I, 3)
count = count + 1;
h.CData = I(:, :, count);
end
end
function StoreBtnCB(src, evnt)
Selected = count;
end
end

Jose Andrés
Jose Andrés 2015년 3월 31일
편집: Jose Andrés 2015년 3월 31일
I am sorry but I am starting to work with images and I don´t know how to do this kind of things. I have the ideas but not the way to execute them. It is very difficult? Could you show me the easiest way?
Thank you!
  댓글 수: 3
Adam Wyatt
Adam Wyatt 2015년 4월 1일
Sorry mate, I made a question and you answered to me yesterday. I really like your idea but I am lost with all this image function thing. I have copied the Code you post on my question in a new .m file, replacing the variable "I" for my image, but I have a lot of errors and I don´t know what to do because I don´t know how it works...
You need to be more specific. Use the documentation. for any items you do not understand. Read the sections on GUI programming and Callbacks.
Jose Andrés
Jose Andrés 2015년 4월 2일
Yes I have tried it but I haven't used GUI never and it is so difficult to me; I am looking for the easiest way to execute my idea (what I showed is what I know to do) or get the Code to learn it.
Right now, I have a MatLab file with this code:
function Selected = TestFun
clf;
I = dicomread('IM-0237-0233.dcm');
count = 1;
Selected = [];
h = imagesc(I(:, :, count));
hb1 = uicontrol('Style', 'PushButton', 'String', 'Next', ...
'Callback', @NextBtnCB);
hb2 = uicontrol('Style', 'PushButton', 'String', 'Store', ...
'Callback', @StoreBtnCB);
hb1.Position(2) = hb2.Position(2)+1.1*hb2.Position(4);
while isempty(Selected)
pause(.1);
end
function NextBtnCB(src, evnt)
if count<size(I, 3)
count = count + 1;
h.CData = I(:, :, count);
end
end
function StoreBtnCB(src, evnt)
Selected = count;
end
end
... and that's all I know to do.
Sorry but I am really lost with this.

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


Ashish Uthama
Ashish Uthama 2015년 3월 31일
You could try using the image batch processor app to browse your images. You could then right-click on the image you want to select and export it to the workspace (to do further processing like cropping).

카테고리

Help CenterFile Exchange에서 Import, Export, and Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by