-1
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)
f=imread('/Users/MoChutima/Desktop/WORK1:2560/ImageProcess/dip/dip/baboon.jpg');
Tscale = [handles.sx 0 0; 0 handles.sy 0; 0 0 1];
Trotation = [cos(handles.theta) sin(handles.theta) 0; -sin(handles.theta) cos(handles.theta) 0; 0 0 1];
Tshear = [1 handles.shx 0; handles.shy 1 0; 0 0 1];
T=Tscale*Trotation*Tshear;
tform=maketform('affine',T);
g=imtransform(f,tform,'bilinear');
imshow(g);

and I have error

Error in Workex63>pushbutton1_Callback (line 82)
Tscale = [handles.Sx 0 0; 0 handles.Sy 0; 0 0 1];

Error in gui_mainfcn (line 95)
    feval(varargin{:});

Error in Workex63 (line 42)
gui_mainfcn(gui_State, varargin{:});

Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)Workex63('pushbutton1_Callback',hObject,eventdata,guidata(hObject)) 

Error while evaluating UIControl Callback

I do Geometric in GUI and I want to create slider and edit text to fill number of Shear X,Y Scale X,Y but now I can't Load Picture to process.

Thanks

  • Hi and welcome to SO! We are here to help *you* write better code. As it is currently stated, your problem is virtually impossible for us to reproduce, so you'll likely not get many responses. Also, it rather looks like a direct copy-paste of your code+output without applying standard debugging techniques, which is not typically what we do here. Please read the FAQ on how to write a [minimal working example](https://stackoverflow.com/help/mcve), and [what kinds of questions you can ask here](https://stackoverflow.com/help/on-topic). – Rody Oldenhuis Sep 09 '17 at 13:14

1 Answers1

0

Actually, I think your are confusing controls (textbox, checkbox, etc...) with their underlying value.

Let's assume, for example, that handles.theta references a Slider control and that handles.ssomething references an EditText control in which the user can insert a numeric value. If you want to retrieve their values and use them in order to process your calculations, this is what you have to do:

th = get(handles.theta,'Value');
ss = str2double(get(handles.ssomething,'String'));

or (it's the same but I prefer this approach):

th = handles.theta.Value;
ss = str2double(handles.ssomething.String);

So, to fix up your code, first retrieve all the numeric values you need from your application controls, then proceed with calculations:

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)

th = handles.theta.Value;
shx = str2double(handles.shx.String);
shy = str2double(handles.shy.String);
sx = str2double(handles.sx.String);
sy = str2double(handles.sy.String);

f = imread('myimage.jpg');
Tscale = [sx 0 0; 0 sy 0; 0 0 1];
Trotation = [cos(th) sin(th) 0; -sin(th) cos(th) 0; 0 0 1];
Tshear = [1 shx 0; shy 1 0; 0 0 1];
T=Tscale*Trotation*Tshear;
tform=maketform('affine',T);
g=imtransform(f,tform,'bilinear');
imshow(g);

Don't forget to implement a sanity check in your EditText controls through a Callback in order to validate the input of the user (and prevent the insertion of wrong values). This is not part of the question but I'm pretty sure you will find hundreds of examples googling for it.

Tommaso Belluzzo
  • 23,232
  • 8
  • 74
  • 98