Info

This question is closed. Reopen it to edit or answer.

what is wrong with this??

3 views (last 30 days)
memo eid
memo eid on 26 Dec 2014
Closed: MATLAB Answer Bot on 20 Aug 2021
function open_Callback(hObject, eventdata, handles)
[File_Name, Path_Name] = uigetfile('*.jpg')
axes(handles.axes1);
image=imread(fullfile(Path_Name,File_Name));
imshow(image)
handles.image = image;
guidata( hObject, handles )
function rotation_Callback(hObject,eventdata , handles)
close all;
clear all;
if true
% code
end
image=(handles.image);
a=imread(image);
c=size(a);
for i = 1:1:c(1)
for j = 1:1:c(2)
b(j,i)=a(i,j);
end
end
figure(),imshow(b)
And Error:----
Error in ==> proj>rotation_Callback at 149 image=get(handles.image);
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> proj at 42 gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)proj('rotation_Callback',hObject,eventdata,guidata(hObject))
if true
% code
end

Answers (1)

Image Analyst
Image Analyst on 26 Dec 2014
Well, lots of things.
Don't use image as the name of your image because it's the name of a built-in function.
The error message you posted does not refer to a line of code in your program: "image=get(handles.image);" - there is no such line.
The for loops can simply be replaced by
b=a;
The variable names are horrible - not descriptive. Single letter variable names lead to a confusing alphabet soup of code that is very hard to maintain.
You're not using the folder the user browsed to. Use code like this instead:
% Have user browse for a file, from a specified "starting folder."
% For convenience in browsing, set a starting folder from which to browse.
startingFolder = 'C:\Program Files\MATLAB';
if ~exist(startingFolder, 'dir')
% If that folder doesn't exist, just start in the current folder.
startingFolder = pwd;
end
% Get the name of the file that the user wants to use.
defaultFileName = fullfile(startingFolder, '*.*');
[baseFileName, folder] = uigetfile(defaultFileName, 'Select a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
And MOST SERIOUS OF ALL, you're calling "clear all" inside your callback which blows away everything including the vital handles structure. Get rid of that line.
There are other things but that's enough for now.

Tags

Community Treasure Hunt

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

Start Hunting!