Why slider not working?

3 ビュー (過去 30 日間)
Stelios Fanourakis
Stelios Fanourakis 2018 年 6 月 1 日
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
Stelios Fanourakis 2018 年 6 月 3 日
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
Stelios Fanourakis 2018 年 6 月 5 日
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 2018 年 6 月 5 日
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 Center および File ExchangeDisplay Image についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by