Haunted Code (Serious)
Show older comments
I know this might sound like a joke but I promise I am being completely serious. I want to preface this question by saying that I don't need help fixing this code, I've rewritten it and it works fine now. I am simply looking to see if anyone knows why this is happening or if it has happened to anyone else
I've been trying to create a GUI where I can click a button, use it to select an image, and then display that image on an axes. All was going well but when I went to test the code (as follows), the image loaded with a small blue square in the corner. Looking closer at that box, I found that there is an image of what appears to be a young boy smiling (3 images attached below show him appearing on 2 different images and then one zoomed in on him). He appears on every image I've tried, in various sizes. I am 99% certain this is not an image from my local storage; my device is brand new and I cannot fathom as to why I would have such an image saved somewhere.
% --- Executes on button press in LoadButton.
function LoadButton_Callback(hObject, eventdata, handles)
% hObject handle to LoadButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, path]=uigetfile('*.jpg','Select an Image')
fullfilename=fullfile(path,filename)
Image= imread(fullfilename);
image(Image,'Parent',handles.Image);
set(handles.Image,'visible');
imshow(image);


If anyone has any idea what's going on please let me know.
3 Comments
Duijnhouwer
on 7 May 2020
Edited: Duijnhouwer
on 7 May 2020
the functin "image" wihout arguments shows that boy by default (yes, it's ridiculous)
The below code shows something similar to yours
you don't need the imshow(image) call
or at least call imshow(Image)
(better not distinguish names on capitalization alone)
clf
M1=imread('peppers.png'); % comes with matlab
image(M1);
hold on
imshow(image) % first displays the default image and then throws an error (wrong input for imshow)
Judy Yang
on 7 May 2020
That is the default image. See:
It gets shown in your axes because of this superfluous line of code:
imshow(image);
where you call image without an input argument, hence it shows the default image. Solution: get rid of that line.
Accepted Answer
More Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects 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!