Slider to scroll through image slices

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 commentaires

Rik
Rik le 26 Mai 2018
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 le 27 Mai 2018
Modifié(e) : Image Analyst le 27 Mai 2018
Try setting the Value property AFTER you set the min and max properties. Also, did you see my answer below?
Stelios Fanourakis
Stelios Fanourakis le 27 Mai 2018
@Image Analyst. I tried but still the same error. I saw your answer but its not what I want
Stelios Fanourakis
Stelios Fanourakis le 27 Mai 2018
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.

Connectez-vous pour commenter.

Réponses (1)

Image Analyst
Image Analyst le 26 Mai 2018

0 votes

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

Catégories

En savoir plus sur Convert Image Type dans Centre d'aide et File Exchange

Commenté :

Jan
le 12 Juil 2018

Community Treasure Hunt

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

Start Hunting!

Translated by