ラジオボタンとスライダーを含む質問があります。私の目的は次のとおりです。スライダーの値が変更された場合、その時点で選択されているラジオボタンのコードを再実行して、効果を更新する必要があります。
スライダの最大値、最小値、ステップはオープニング関数で定義され、現在の値は に定義されhandles.value
ます。
これが私のスライダーコードです。
function slider1_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.svalue = get(handles.slider1, 'Value');
guidata(hObject, handles)
これが私のラジオボタングループの選択変更コードです。
function uipanel3_SelectionChangeFcn(hObject, eventdata, handles)
% hObject handle to the selected object in uipanel3
% eventdata structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was selected
% NewValue: handle of the currently selected object
% handles structure with handles and user data (see GUIDATA)
switch get(eventdata.NewValue,'Tag') % Get Tag of selected object.
case 'hte'
h_te = zeros(handles.rows, handles.colums);
for m = handles.row_0:handles.rows
gauss = fspecial('gaussian',[1 round(1+handles.svalue*(m-handles.row_0+1))], (0.3*round(1+handles.svalue*(m-handles.row_0+1))));
h_te(m,:,1) = filter2(gauss, handles.img_d(m,:,1));
h_te(m,:,2) = filter2(gauss, handles.img_d(m,:,2));
h_te(m,:,3) = filter2(gauss, handles.img_d(m,:,3));
h_te(handles.rows-m+1,:,1) = filter2(gauss, handles.img_d(handles.rows-m+1,:,1));
h_te(handles.rows-m+1,:,2) = filter2(gauss, handles.img_d(handles.rows-m+1,:,2));
h_te(handles.rows-m+1,:,3) = filter2(gauss, handles.img_d(handles.rows-m+1,:,3));
end
axes(handles.axes2);
imshow(h_te);
case 'hc'
h_c = zeros(handles.rows, handles.colums);
for m = handles.row_0:handles.rows
gauss = fspecial('gaussian',[1 round(1+handles.svalue*(m-handles.row_0+1))], (0.3*round(1+handles.svalue*(m-handles.row_0+1))));
h_c(m-handles.row_0+1,:,1) = filter2(gauss, handles.img_d(m-handles.row_0+1,:,1));
h_c(m-handles.row_0+1,:,2) = filter2(gauss, handles.img_d(m-handles.row_0+1,:,2));
h_c(m-handles.row_0+1,:,3) = filter2(gauss, handles.img_d(m-handles.row_0+1,:,3));
h_c(handles.rows-m+handles.row_0,:,1) = filter2(gauss, handles.img_d(handles.rows-m+handles.row_0,:,1));
h_c(handles.rows-m+handles.row_0,:,2) = filter2(gauss, handles.img_d(handles.rows-m+handles.row_0,:,2));
h_c(handles.rows-m+handles.row_0,:,3) = filter2(gauss, handles.img_d(handles.rows-m+handles.row_0,:,3));
end
axes(handles.axes2);
imshow(h_c);
case 'vlr'
v_lr = zeros(handles.rows, handles.colums);
for m = handles.colum_0:handles.colums
gauss = fspecial('gaussian',[round(1+handles.svalue*(m-handles.colum_0+1)) 1], (0.3*round(1+handles.svalue*(m-handles.colum_0+1))));
v_lr(:,m,1) = filter2(gauss, handles.img_d(:,m,1));
v_lr(:,m,2) = filter2(gauss, handles.img_d(:,m,2));
v_lr(:,m,3) = filter2(gauss, handles.img_d(:,m,3));
v_lr(:,handles.colums-m+1,1) = filter2(gauss, handles.img_d(:,handles.colums-m+1,1));
v_lr(:,handles.colums-m+1,2) = filter2(gauss, handles.img_d(:,handles.colums-m+1,2));
v_lr(:,handles.colums-m+1,3) = filter2(gauss, handles.img_d(:,handles.colums-m+1,3));
end
axes(handles.axes2);
imshow(v_lr);
case 'vc'
v_c = zeros(handles.rows, handles.colums);
for m = handles.colum_0:handles.colums
gauss = fspecial('gaussian',[round(1+handles.svalue*(m-handles.colum_0+1)) 1], (0.3*round(1+handles.svalue*(m-handles.colum_0+1))));
v_c(:,m-handles.colum_0+1,1) = filter2(gauss, handles.img_d(:,m-handles.colum_0+1,1));
v_c(:,m-handles.colum_0+1,2) = filter2(gauss, handles.img_d(:,m-handles.colum_0+1,2));
v_c(:,m-handles.colum_0+1,3) = filter2(gauss, handles.img_d(:,m-handles.colum_0+1,3));
v_c(:,handles.colums-m+handles.colum_0,1) = filter2(gauss, handles.img_d(:,handles.colums-m+handles.colum_0,1));
v_c(:,handles.colums-m+handles.colum_0,2) = filter2(gauss, handles.img_d(:,handles.colums-m+handles.colum_0,2));
v_c(:,handles.colums-m+handles.colum_0,3) = filter2(gauss, handles.img_d(:,handles.colums-m+handles.colum_0,3));
end
axes(handles.axes2);
imshow(v_c);
end
guidata(hObject, handles)
スライダー内で uipanel3 関数を呼び出すとうまくいくと思いましたが、うまくいきません。これが私がうまくいくと思ったものです。
function slider1_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.svalue = get(handles.slider1, 'Value');
uipanel3_SelectionChangeFcn(hObject, eventdata, handles);
guidata(hObject, handles)