Why slider not working?

8 次查看(过去 30 天)
Stelios Fanourakis
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 个评论
Walter Roberson
Walter Roberson 2018-6-3
Type that at the command line and then run the code.
Stelios Fanourakis
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/?

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2018-6-2
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 个评论
Stelios Fanourakis
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
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Display Image 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by