Clim Change to help slider

조회 수: 7 (최근 30일)
Adam
Adam 2012년 3월 1일
hello everyone do not know how slider can change the value Clim [0 b]. The property inspectr axes I have not found the box for the callback.
function varargout = books(varargin)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @books_OpeningFcn, ...
'gui_OutputFcn', @books_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
function books_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = books_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function slider1_Callback(hObject, eventdata, handles)
set(handles.edit1,'String',...
num2str(get(handles.slider1,'Value')));
I = imread('cameraman.tif');
imshow(I)
function slider1_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
function edit1_Callback(hObject, eventdata, handles)
val=str2double(get(handles.slider1,'Slider'));
if isnumeric(val) & length(val)==1 & ...
val >= get(handles.slider1,'Min') & ...
vas <= get(handles.slider1,'Max')
set(handles.slider1,'Value',val);
else
handles.numberOfErrors = handles.numberOfErrors + 1;
set(handles.edit1,'CLim',...
[handles.errorCLim,num2str(handsles.numberOfErrors)]);
guidata(gcbo, handles);
end
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

채택된 답변

Adam
Adam 2012년 3월 2일
if I want to change only one parameter Clim help riders as I enter the second value that remained unchanged.
max_val = get(handles.slider1,'Value');
min_val = 256;
set(handles.axes,'CLim',[min_val. max_val],...
get(handles.slider1,'Value'));
  댓글 수: 1
Walter Roberson
Walter Roberson 2012년 3월 2일
The period after min_val does not appear to have any purpose in the set() line.

댓글을 달려면 로그인하십시오.

추가 답변 (4개)

Adam
Adam 2012년 3월 1일
what's wrong?
.
.
.
set(handles.axes,'CLim',get(handles.slider1,'Value'));
.
.
.

Walter Roberson
Walter Roberson 2012년 3월 1일
Clim needs to be set to a pair of numeric values (an array of 2 elements). When you get() the Value of a slider, you only get one numeric value.

Adam
Adam 2012년 3월 2일
I have tried something like that, but in vain.
min_val = get(handles.Slider1,'Value');
max_val = max(max(get(handles.I,'CData')));
set(handles.axes,'CLim',[min_val. max_val],...
get(handles.slider1,'Value'));
I can help somehow? I do not know how. thank you
  댓글 수: 3
Adam
Adam 2012년 3월 2일
ok, I did so, and it still has an error I put a specific value and it worked.
min_val=16;
max_val=60;
set(handles.axes,'CLim',[min_val max_val]);
When you insert a
min_val = get(handles.Slider1,'Value');
max_val = max(max(get(handles.I,'CData')));
is stop to working
Walter Roberson
Walter Roberson 2012년 3월 2일
CD = get(handles.I,'CData');
max_val = max(CD(:));
This will work whether the CD is 2 dimensional (indexed image) or 3 dimensional (RGB image). Your previous code would fail on RGB images because max(max()) would only reduce 2 of the 3 dimensions.

댓글을 달려면 로그인하십시오.


Adam
Adam 2012년 3월 2일
I'm sorry I had found out why: We use Slider1 Slider1 and I wrote .... Many times I thank everyone for their help

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by