How to set the scaling of an image (I think using Clim)

13 views (last 30 days)
If I display an image IM, on an axes 1 by,
handles.axes1
imshow(IM, [100, 500];
How do I obtain the scaling parameters that have been used for the imshow and use a default "auto" as one option if a checkbox is ticked. I have the following code, but its not quite there.
InitialScale=get(handles.axes1, 'Clim')
lowInitial=InitialScale(1);
highInitial=InitialScale(2);
if (get(handles.checkboxAS,'Value') == 1)
set(handles.axes1, 'Clim',[]);
else
set(handles.axes1, 'Clim',[lowInitial, highInitial]);
end
  1 Comment
Jason
Jason on 16 Oct 2014
just to add, I want this line to scale automsatically. but I dont want to have to redraw the image using imshow(IM,[]) as it seems pointless as the data is already there.
set(handles.axes1, 'Clim',[]);

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 16 Oct 2014
Try caxis().
  1 Comment
Jason
Jason on 17 Oct 2014
Thanks for the suggestion. I have the following code, but nothing happens??
%Recall saved values from when originally drawn
lowInitial=getappdata(0,'ScaleLow');
highInitial=getappdata(0,'ScaleHigh');
handles.axes1;
if (get(handles.checkboxAS,'Value') == 1)
%set(handles.axes1, 'Clim','auto');
%caxis auto;
caxis([-1 1]);
else
%set(handles.axes1, 'Clim',[lowInitial, highInitial]);
caxis manual;
caxis([lowInitial, highInitial]);
end
handles.axes1;
title('Caxis =')
drawnow;

Sign in to comment.

Categories

Find more on Image Processing and Computer Vision 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!