GUIDE next button inquiry
Show older comments
I have a series of images (let's say, 60) that are created in Matlab that are a 256 x 256 image. Therefore, I have a 256 x 256 x 60 matrix. I want to be able to create a button in GUIDE to be able to function as a "next" button, as well as a "previous" button, to view images in succession.
The initial code is:
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
code to loop through image creation
imagesc(Z(:,:,1))
colormap(jet)
caxis([0 60])
title('Reflectivity')
handles.currentimage = 1
This initial button creates the first image. Now the button to be able to click "next" is coded as:
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if handles.currentimage < length(Z)
imagesc(Z(:,:,handles.currentimage+1))
end
however, I get the error:
Reference to non-existent field 'currentimage'.
Error in untitled1>pushbutton5_Callback (line 162)
if handles.currentimage < length(Z)
Any help would be greatly appreciated!
Answers (1)
Image Analyst
on 26 Apr 2016
I suggest you use a scrollbar. Set up the scrollbar to go from 1 to the number of slices. Then get the value and display that slice
scrollbarValue = handles.scrollbar1.Value;
oneSlice = Z(:, :, scrollbarValue);
imshow(oneSlice, []);
4 Comments
Micheal Simpson
on 26 Apr 2016
Image Analyst
on 26 Apr 2016
One problem is that you're using and overwriting the reserved variable "path" with your own version. That is dangerous. Use the name "folder" instead of path.
Then, apparently it thinks Z(:,:,1) is a "multi-plane image for some reason. What happens when you do this
oneSlice = Z(:,:, 1);
whos oneSlice
imshow(oneSlice, []);
What do you see in the command window?
Micheal Simpson
on 26 Apr 2016
Image Analyst
on 27 Apr 2016
That doesn't make any sense to me. oneSlice is obviously a 384x384 grayscale image, not a multi-plane image. You're going to have to call the mathworks on that one.
Categories
Find more on Image Preview and Device Configuration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!