I need a code for a slider to scroll through a stack of images. Like a 3D Viewer.
Any idea please? I have 4 axes and need to control them with a single slider.

댓글 수: 6

Rik
Rik 2018년 5월 26일
You have asked quite a lot of questions before, and each time my questions are the same: what have you tried already? What is the code you tried? How is your data organized?
If it is difficult to describe it, just attach it.
A slider type uicontrol object has a Min property, a Max property, a Value property and a Callback property. Make that callback a function that sets some axes to some state you want based on the min, max and value properties.
This is my code:
function Load_image_Callback(hObject, eventdata, handles)
% hObject handle to Load_image (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global im im2
axes(handles.axes1);
[fileName, isCancelled] = imgetfile();
im = DicomReader(fileName)
imshow(fileName)
im2 = makeImIsoRGB(im, [1,1,15], 2.1, 'cubic')
if ischar(fileName); fileName = {fileName}; end
filenames = fullfile(fileName);
handles.imagedata = cellfun(@dicomread, filenames, 'uniformoutput', 0);
handles.image = imshow(handles.imagedata{1}, 'Parent', handles.axes1);
set(handles.slider1, 'Value', 1, 'Min', 1, 'Max', numel(filenames), ...
'SliderStep', [0,1]./(numel(filenames) - 1))
guidata(hObject, handles);
And I get the error:
Warning: 'slider' control cannot have a 'Value' outside of 'Min'-'Max' range Control will not be rendered until all of its parameter values are valid
Any help?
Image Analyst
Image Analyst 2018년 5월 27일
편집: Image Analyst 2018년 5월 27일
Try setting the Value property AFTER you set the min and max properties. Also, did you see my answer below?
Stelios Fanourakis
Stelios Fanourakis 2018년 5월 27일
@Image Analyst. I tried but still the same error. I saw your answer but its not what I want
Stelios Fanourakis
Stelios Fanourakis 2018년 5월 27일
I also get the following error "Cell contents indices must be greater than 0"
@Stelios: Again: please post the complete error message. We cannot guess, in which line the problem occurs.
This does nothing:
filenames = fullfile(fileName);
You have to provide the folder in addition, such that fullfile can join the parts.

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

답변 (1개)

Image Analyst
Image Analyst 2018년 5월 26일

0 개 추천

Try Image Browser on the Apps tab of the tool ribbon and see if that's okay.

카테고리

도움말 센터 및 File Exchange에서 DICOM Format에 대해 자세히 알아보기

질문:

2018년 5월 26일

댓글:

Jan
2018년 7월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by