Why slider not working?

8 Ansichten (letzte 30 Tage)
Stelios Fanourakis
Stelios Fanourakis am 1 Jun. 2018
I got this function
function slider1_Callback(hObject,eventdata, handles,im2,S,sno)
% test it out - get the handles object and display the current value
handles.sliderImages = handles.im2;
im2 = handles.sliderImages
SIZE_Z = handles.SIZE_Z;
set(handles.slider1,'Value',1);
set(hObject,'Min',1,'Max',SIZE_Z);
set(hObject,'SliderStep',[1/(SIZE_Z-1),1/(SIZE_Z-1)]);
slider2Val=floor(get(hObject,'Value'));
currentSlice=slider2Val;
imshow(im2(:,:,currentSlice),[752 1512],'Parent',handles.axes1);
handles.currentSlice=currentSlice;
guidata(hObject,handles);
edit12_Callback(hObject, eventdata, handles);
And I get the error "Struct contents reference from a non-struct array object." at line
handles.sliderImages = handles.im2;
What can this mean?
  9 Kommentare
Walter Roberson
Walter Roberson am 3 Jun. 2018
Type that at the command line and then run the code.
Stelios Fanourakis
Stelios Fanourakis am 3 Jun. 2018
Well. When the slider finishes at the end right and start to drag it back to left. I get the error at the first left click and the values are, CurrentFrame: 14 frameindex: 16.
Should they be equal? What to do to change it/?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 2 Jun. 2018
You cannot bring a variable defined in another function into the current function just by mentioning its name in the function() definition.
If you are defining those variables in the load image callback, then you need to store those values somewhere that the slider callback can get at, such as in the handles structure (though storing an entire image in a handles structure is not the best idea for performance reasons.)
  17 Kommentare
Stelios Fanourakis
Stelios Fanourakis am 5 Jun. 2018
I know what I want. I explained to my previous comment. If you can give me a code that actually changes images forward and backwards, I'll accept your answer
Stelios Fanourakis
Stelios Fanourakis am 5 Jun. 2018
Can you please let me know how can I make this line
CurrentFrame = round((get(handles.SliderFrame,'Value')));
To actually work and change between frames and not just dim the first image.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Display Image finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by