lcs tp7 figure groupe 20

Voir le sujet précédent Voir le sujet suivant Aller en bas

lcs tp7 figure groupe 20

Message par aminezer le Mar 16 Fév - 11:06

figure('name','agpa','numbertitle','off','position',[700 500 550 150]);
dat={'toyota','21210-114-35',true,'chaufdisp';...
   'renault','46110-114-35',false,'chaufdisp';...
   'peugeot','78813-115-35',false,'chaufdisp';...
   'chevrolet','43132-113-35',false,'chaufdisp';...
   'hundai','12323-112-35',false,'chaufdisp'};
columname={'typevhecule','immatricule','programme','chaufprog'};
columnformat={'char','char',[],{'ahmed' 'lounas' 'omar' 'miloud'}};
columneditable=[false false true true];
t=uitable('Units','normalized','position',[0.1 0.1 0.9 0.9],'Data',dat,...
   'ColumnName',columname,'ColumnFormat',columnformat,...
   'ColumnEditable',columneditable);
set(t,'ColumnWidth',{120 120 'auto' 120});

aminezer

Messages : 17
Date d'inscription : 04/12/2015

Revenir en haut Aller en bas

Re: lcs tp7 figure groupe 20

Message par aminezer le Mar 16 Fév - 11:09

function tfig
figure('KeyPressFcn',@printfig);
dat={'toyota','21210-114-35',true,'chaufdisp';...
   'renault','46110-114-35',false,'chaufdisp';...
   'peugeot','78813-115-35',false,'chaufdisp';...
   'chevrolet','43132-113-35',false,'chaufdisp';...
   'hundai','12323-112-35',false,'chaufdisp'};
columname={'typevhecule','immatricule','programme','chaufprog'};
columnformat={'char','char',[],{'ahmed' 'lounas' 'omar' 'miloud'}};
columneditable=[false false true true];
t=uitable('Units','normalized','position',[0.1 0.1 0.9 0.9],'Data',dat,...
   'ColumnName',columname,'ColumnFormat',columnformat,...
   'ColumnEditable',columneditable);
set(t,'ColumnWidth',{120 120 'auto' 120});
function printfig(src,evnt)
if evnt.Character=='e'
   print('-deps','-r200',['-f' num2str(src)])
     elseif evnt.Key == 't'
   print('-dtiff','-r200',['-f' num2str(src)])
end
end
end

aminezer

Messages : 17
Date d'inscription : 04/12/2015

Revenir en haut Aller en bas

Re: lcs tp7 figure groupe 20

Message par aminezer le Mar 16 Fév - 11:13

ctrl+t


function pj = name( pj )
%NAME Method to check or create valid filename.
% Validate FileName in PrintJob object. If empty, no name passed to PRINT
% command, but one is required by the driver, image file formats, we invent
% a name and tell the user what it is. Also invent name, but do not tell
% user, for temporary PS file created on disk when printing directly
% to output device or for GhostScript conversion.

% Copyright 1984-2010 The MathWorks, Inc.
% $Revision: 1.8.4.13 $

%Generate a name we would use if had to in various circumstances.
if isfigure( pj.Handles{1}(1) )
objName = ['figure' int2str( double(pj.Handles{1}(1) ))];
else
objName = get_param(pj.Handles{1}(1),'name');
end

tellUserFilename = 0;
if isempty(pj.FileName)
if pj.DriverExport && ...
~strcmp(pj.DriverClass,'MW') && ~pj.DriverClipboard && ~pj.RGBImage
%These kinds of files shouldn't go to printer, generate file on disk
pj.FileName = objName;
tellUserFilename = 1;

else
%File is going to be sent to an output device by OS or us.
if ~strcmp(pj.DriverClass,'MW') && ~pj.DriverClipboard && ~pj.RGBImage
%Going to a file, invent a name
pj.FileName = tempname;
pj.PrintOutput = 1;
end
end

% only support going to clipboard w/o specifying -clipboard option
% for the grandfathered cases on Windows
if ~pj.ClipboardOption && pj.DriverClipboard
if ~ispc || (ispc && ~any(strcmp(pj.Driver, {'meta', 'bitmap'})))
pj.FileName = objName;
tellUserFilename = 1;
end
end
else
%Both / and \ are commonly used, but in MATLAB we recognize only filesep
pj.FileName = strrep( pj.FileName, '/', filesep );
pj.FileName = strrep( pj.FileName, '\', filesep );
end

%Append appropriate extension to filename if
% 1) it doesn't have one, and
% 2) we've determined a good one
if ~isempty( pj.DriverExt ) && ~isempty( pj.FileName )
%Could assert that ~isempty( pj.FileName )
[p,n,e] = fileparts( pj.FileName );
if isempty( e )
pj.FileName = fullfile( p, [n '.' pj.DriverExt] );
end
end

% on unix fix the file spec if it starts with '~/' so we look at the user's home dir
if (isunix)
pj.FileName = fixTilde(pj.FileName);
end

if tellUserFilename
%Invented name above because of device or bad filename
if tellUserFilename == 1
errStr1 = sprintf( 'Files produced by the ''%s'' driver cannot be sent to printer.\n', pj.Driver);
else
errStr1 = '';
end

warning(message('MATLAB:print:SavingToDifferentName', errStr1, pj.FileName))
end

% Check that we can write to the output file
if ~isempty(pj.FileName)
[fpath,fname,ext] = fileparts(pj.FileName);
if isempty(fpath)
fpath = '.';
end
pj.FileName = fullfile(fpath,[fname ext]);
% first check if readable file already exists there
fidread = fopen(pj.FileName,'r');
didnotexist = (fidread == -1);
if ~didnotexist
fclose(fidread);
end
% now check if file is appendable (will create file if not there)
fidappend = fopen(pj.FileName,'a');
if fidappend ~= -1
fclose(fidappend);
% check if we have to delete the created file
if didnotexist
% @todo Replace This once we have a flag on delete
% for disabling the recycle.
ov=recycle('off');
delete(pj.FileName);
recycle(ov);
end
else
error(message('MATLAB:print:CannotCreateOutputFile', pj.FileName));
end
end

%A little business to clear up.
%Now that we found good extension and all that for GS driver,
%we swap in a PS driver and temporary name for later conversion
%to a file whose name we just prettied up.
if strcmp( pj.DriverClass, 'GS' )
%Remember actual device, get MATLAB to produce PostScript
%for later conversion by GhostScript
pj.GhostDriver = pj.Driver;
if pj.DriverColor
pj.Driver = 'psc';
else
pj.Driver = 'ps';
end
pj.GhostName = pj.FileName;
pj.FileName = [tempname '.ps'];
end

% function to replace, on unix, a leading tilde (~)
% of a directory specification in a file name (ie. '~/test.pdf'
% with the name/path of the user's home directory
% (to get something like '/home/user/test.pdf')
%
% This is done, in part, to work around problem with Ghostscript not
% supporting a filename with the tilde (ie. '~/test.pdf')
function filename = fixTilde(fileName)
persistent homeDir; % keep track of user's home dir
filename = fileName;
% yes, we tested for isunix above...but in case that test gets deleted
if (isunix && (length(fileName) > 1))
if (fileName(1) == '~' && fileName(2) == filesep)
if isempty(homeDir)
% save current location,
% go 'home' and remember that location
% switch back to original location
currDir = pwd;
cd('~');
homeDir = pwd;
cd(currDir);
end
if ~isempty(homeDir)
% now that we know where the home dir is
% replace 1st char (~) with user's home dir and take rest of
% path specified
filename = [homeDir fileName(2:end)];
end
end
end


aminezer

Messages : 17
Date d'inscription : 04/12/2015

Revenir en haut Aller en bas

Re: lcs tp7 figure groupe 20

Message par aminezer le Mar 16 Fév - 11:15

I=imread('figure1.tif');
imshow(I);

aminezer

Messages : 17
Date d'inscription : 04/12/2015

Revenir en haut Aller en bas

Re: lcs tp7 figure groupe 20

Message par aminezer le Mar 16 Fév - 11:15

figure('name','agpa','numbertitle','off','position',[700 500 550 158]);
dat={'toyota','21210-114-35',true,'chaufdisp';...
'renault','46110-114-35',false,'chaufdisp';...
'peugeot','78813-115-35',false,'chaufdisp';...
'chevrolet','43132-113-35',false,'chaufdisp';...
'hundai','12323-112-35',false,'chaufdisp'};
columname={'typevhecule','immatricule','programme','chaufprog'};
columnformat={'char','char',[],{'nouh' 'zenda' 'lounas' 'omar' 'miloud'}};
columneditable=[true true true true];
t=uitable('Units','normalized','position',[0.1 0.1 0.9 0.9],'Data',dat,...
'ColumnName',columname,'ColumnFormat',columnformat,...
'ColumnEditable',columneditable);
set(t,'ColumnWidth',{120 120 'auto' 120});

aminezer

Messages : 17
Date d'inscription : 04/12/2015

Revenir en haut Aller en bas

Re: lcs tp7 figure groupe 20

Message par aminezer le Mar 16 Fév - 11:17

function h=imshow(varargin)
%IMSHOW Display image in Handle Graphics figure.
% IMSHOW(I) displays the grayscale image I.
%
% IMSHOW(I,[LOW HIGH]) displays the grayscale image I, specifying the display
% range for I in [LOW HIGH]. The value LOW (and any value less than LOW)
% displays as black, the value HIGH (and any value greater than HIGH) displays
% as white. Values in between are displayed as intermediate shades of gray,
% using the default number of gray levels. If you use an empty matrix ([]) for
% [LOW HIGH], IMSHOW uses [min(I(Smile) max(I(Smile)]; that is, the minimum value in
% I is displayed as black, and the maximum value is displayed as white.
%
% IMSHOW(RGB) displays the truecolor image RGB.
%
% IMSHOW(BW) displays the binary image BW. IMSHOW displays pixels with the
% value 0 (zero) as black and pixels with the value 1 as white.
%
% IMSHOW(X,MAP) displays the indexed image X with the colormap MAP.
%
% IMSHOW(FILENAME) displays the image stored in the graphics file FILENAME.
% The file must contain an image that can be read by IMREAD or
% DICOMREAD. IMSHOW calls IMREAD or DICOMREAD to read the image from the file,
% but does not store the image data in the MATLAB workspace. If the file
% contains multiple images, the first one will be displayed. The file must be
% in the current directory or on the MATLAB path.
%
% HIMAGE = IMSHOW(...) returns the handle to the image object created by
% IMSHOW.
%
% IMSHOW(...,PARAM1,VAL1,PARAM2,VAL2,...) displays the image, specifying
% parameters and corresponding values that control various aspects of the
% image display. Parameter names can be abbreviated, and case does not matter.
%
% Parameters include:
%
% 'Border' String that controls whether
% a border is displayed around the image in the
% figure window. Valid strings are 'tight' and
% 'loose'.
%
% Note: There can still be a border if the image
% is very small, or if there are other objects
% besides the image and its axes in the figure.
%
% By default, the border is set to the value
% returned by
% IPTGETPREF('ImshowBorder').
%
% 'Colormap' 2-D, real, M-by-3 matrix specifying a colormap.
% IMSHOW uses this to set the figure's colormap
% property. Use this parameter to view grayscale
% images in false color.
%
% 'DisplayRange' Two-element vector [LOW HIGH] that controls the
% display range of a grayscale image. See above
% for more details about how to set [LOW HIGH].
%
% Including the parameter name is optional, except
% when the image is specified by a filename.
% The syntax IMSHOW(I,[LOW HIGH]) is equivalent to
% IMSHOW(I,'DisplayRange',[LOW HIGH]).
% The parameter name must be specified when
% using IMSHOW with a filename, as in the syntax
% IMSHOW(FILENAME,'DisplayRange'[LOW HIGH]).
%
% 'InitialMagnification' A numeric scalar value, or the text string 'fit',
% that specifies the initial magnification used to
% display the image. When set to 100, the image is
% displayed at 100% magnification. When set to
% 'fit' IMSHOW scales the entire image to fit in
% the window.
%
% On initial display, the entire image is visible.
% If the magnification value would create an image
% that is too large to display on the screen,
% IMSHOW warns and displays the image at the
% largest magnification that fits on the screen.
%
% By default, the initial magnification is set to
% the value returned by
% IPTGETPREF('ImshowInitialMagnification').
%
% If the image is displayed in a figure with its
% 'WindowStyle' property set to 'docked', then
% IMSHOW warns and displays the image at the
% largest magnification that fits in the figure.
%
% Note: If you specify the axes position (using
% subplot or axes), imshow ignores any initial
% magnification you might have specified and
% defaults to the 'fit' behavior.
%
% When used with the 'Reduce' parameter, only
% 'fit' is allowed as an initial magnification.
%
% 'Parent' Handle of an axes that specifies
% the parent of the image object created
% by IMSHOW.
%
% 'Reduce' Logical value that specifies whether IMSHOW
% subsamples the image in FILENAME. The 'Reduce'
% parameter is only valid for TIFF images and
% you must specify a filename. Use this
% parameter to display overviews of very large
% images.
%
% 'XData' Two-element vector that establishes a
% nondefault spatial coordinate system by
% specifying the image XData. The value can
% have more than 2 elements, but only the first
% and last elements are actually used.
%
% 'YData' Two-element vector that establishes a
% nondefault spatial coordinate system by
% specifying the image YData. The value can
% have more than 2 elements, but only the first
% and last elements are actually used.
%
% Class Support
% -------------
% A truecolor image can be uint8, uint16, single, or double. An indexed
% image can be logical, uint8, single, or double. A grayscale image can
% be any numeric datatype. A binary image is of class logical.
%
% If your grayscale image is single or double, the default display range is
% [0 1]. If your image's data range is much larger or smaller than the default
% display range, you may need to experiment with setting the display range to
% see features in the image that would not be visible using the default
% display range. For all grayscale images having integer types, the default
% display range is [intmin(class(I)) intmax(class(I))].
%
% If your image is int8, int16, uint32, int32, or single, the CData in
% the resulting image object will be double. For all other classes, the
% CData matches the input image class.
%
% Related Toolbox Preferences
% ---------------------------
% You can use the IPTSETPREF function to set several toolbox preferences that
% modify the behavior of IMSHOW:
%
% - 'ImshowBorder' controls whether IMSHOW displays the image with a border
% around it.
%
% - 'ImshowAxesVisible' controls whether IMSHOW displays the image with the
% axes box and tick labels.
%
% - 'ImshowInitialMagnification' controls the initial magnification for
% image display, unless you override it in a particular call by
% specifying IMSHOW(...,'InitialMagnification',INITIAL_MAG).
%
% For more information about these preferences, see the reference entry for
% IPTSETPREF.
%
% Remarks
% -------
% IMSHOW is the toolbox's fundamental image display function, optimizing
% figure, axes, and image object property settings for image display. IMTOOL
% provides all the image display capabilities of IMSHOW but also provides
% access to several other tools for navigating and exploring images, such as
% the Pixel Region tool, Image Information tool, and the Adjust Contrast
% tool. IMTOOL presents an integrated environment for displaying images and
% performing some common image processing tasks.
%
% The imshow function is not supported when MATLAB is started with the
% -nojvm option.
%
% Examples
% --------
% % Display an image from a file
% imshow('board.tif')
%
% % Display an indexed image
% [X,map] = imread('trees.tif');
% imshow(X,map)
%
% % Display a grayscale image
% I = imread('cameraman.tif');
% imshow(I)
%
% % Display a grayscale image, adjust the display range
% h = imshow(I,[0 80]);
%
% See also IMREAD, IMTOOL, IPTPREFS, SUBIMAGE, TRUESIZE, WARP, IMAGE,
% IMAGESC.

% Copyright 1993-2011 The MathWorks, Inc.
% $Revision: 1.1.8.27 $ $Date: 2011/12/11 07:43:05 $

if ~internal.images.isFigureAvailable()
error(message('images:imshow:needJavaFigure'));
end

% translate older syntaxes
varargin_translated = preParseInputs(varargin{:});
% handle 'Reduce' syntax
preparsed_varargin = processReduceSyntax(varargin_translated{:});

[common_args,specific_args] = ...
imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});

cdata = common_args.CData;
cdatamapping = common_args.CDataMapping;
clim = common_args.DisplayRange;
map = common_args.Map;
xdata = common_args.XData;
ydata = common_args.YData;
initial_mag = common_args.InitialMagnification;


if isempty(initial_mag)
initial_mag = iptgetpref('ImshowInitialMagnification');
else
initial_mag = checkInitialMagnification(initial_mag,{'fit'},...
mfilename,'INITIAL_MAG', ...
[]);
end

parent_specified = isfield(specific_args,'Parent');
if parent_specified
validateParent(specific_args.Parent)
end

new_figure = isempty(get(0,'CurrentFigure')) || ...
strcmp(get(get(0,'CurrentFigure'), 'NextPlot'), 'new');

if parent_specified
ax_handle = specific_args.Parent;
elseif new_figure
fig_handle = figure('Visible', 'off');
ax_handle = axes('Parent', fig_handle);
else
ax_handle = newplot;
end
fig_handle = ancestor(ax_handle,'figure');

do_fit = strcmp(initial_mag,'fit');
style = get(fig_handle,'WindowStyle');
if ~do_fit && strcmp(style,'docked')
warning(message('images:imshow:magnificationMustBeFitForDockedFigure'))
do_fit = true;
end

hh = basicImageDisplay(fig_handle,ax_handle,...
cdata,cdatamapping,clim,map,xdata,ydata);
set(get(ax_handle,'Title'),'Visible','on');
set(get(ax_handle,'XLabel'),'Visible','on');
set(get(ax_handle,'YLabel'),'Visible','on');

single_image = isSingleImageDefaultPos(fig_handle, ax_handle);

border = getBorder(specific_args);
is_border_tight = strcmp(border,'tight');
if single_image && do_fit && is_border_tight
% Have the image fill the figure.
set(ax_handle, 'Units', 'normalized', 'Position', [0 0 1 1]);
axes_moved = true;

elseif single_image && ~do_fit
initSize(hh,initial_mag/100,is_border_tight)
axes_moved = true;

else
axes_moved = false;

end

if axes_moved
% The next line is so that a subsequent plot(1:10) goes back
% to the default axes position.
set(fig_handle, 'NextPlot', 'replacechildren');
end

if (nargout > 0)
% Only return handle if caller requested it.
h = hh;
end

if (new_figure)
set(fig_handle, 'Visible', 'on');
end

end % imshow

%---------------------------------------------------------------------
function border = getBorder(specific_args)

border_specified = isfield(specific_args,'Border');
if ~border_specified
border = iptgetpref('ImshowBorder');
else
valid_borders = {'loose','tight'};
border = validatestring(specific_args.Border,valid_borders,mfilename,'BORDER',[]);
end

end

%----------------------------------------------------------------------
function validateParent(h_parent)

if ~ishghandle(h_parent)
error(message('images:validate:invalidAxes','HAX'))
end

parentType = get(h_parent,'type');
if ~strcmp(parentType,'axes')
error(message('images:validate:invalidAxes','HAX'))
end
end

%----------------------------------------------------------------------
function varargin_translated = preParseInputs(varargin)
% Catch old style syntaxes and error, as well as validate uses of the
% 'Reduce' param/value pair

% Removed syntaxes:
% IMSHOW(I,N)
%
% IMSHOW(...,DISPLAY_OPTION)
%
% IMSHOW(x,y,A,...)

new_args = {};
num_args = nargin;

if (num_args == 0)
error(message('images:imshow:tooFewArgs'))
end

if (num_args > 1) && ischar(varargin{end})
% IMSHOW(...,DISPLAY_OPTION)

str = varargin{end};
strs = {'truesize', 'notruesize'};
try
% If trailing string is not 'truesize' or 'notruesize' jump to
% catch block and pass trailing string argument to regular input
% parsing so error will come from that parsing code.
option = validatestring(str, strs, mfilename,'DISPLAY_OPTION', nargin);

% Remove old argument
varargin(end) = [];
num_args = num_args - 1;

% Translate to InitialMagnification
new_args{1} = 'InitialMagnification';
if strncmp(option,'truesize',length(option))
new_args{2} = 100;
optionStr = 'truesize';
magStr = '100';
else
new_args{2} = 'fit';
optionStr = 'notruesize';
magStr = '''fit''';
end

calledSyntax = sprintf('IMSHOW(...,''%s'')',optionStr);
alternateSyntax = sprintf('IMSHOW(...,''InitialMagnification'',%s)',magStr);
error(message('images:removed:syntax',calledSyntax,alternateSyntax))
catch ME

if strcmp(ME.identifier,'images:removed:syntax')
rethrow(ME)
end

% Trailing string did not match 'truesize' or 'notruesize' let regular
% parsing deal with it.

% We are ignoring the error from validatestring if a valid syntax was
% used.
end
end

if (num_args==3 || num_args==4) && ...
isvector(varargin{1}) && isvector(varargin{2}) && ...
isnumeric(varargin{1}) && isnumeric(varargin{2}) && ...
(isnumeric(varargin{3}) || islogical(varargin{3}))
% IMSHOW(x,y,...)

error(message('images:removed:syntax','IMSHOW(x,y,...)','IMSHOW(...,''XData'',x,''YData'',y)'))
end

if num_args == 2 && (numel(varargin{2}) == 1)
% IMSHOW(I,N)

error(message('images:removed:syntaxNoReplacement','IMSHOW(I,N)'))
end


if isempty(new_args)
varargin_translated = varargin;
else
varargin_translated = [varargin new_args];
end

end


function preparsed_varargin = processReduceSyntax(varargin)
% Handles the 'Reduce' P/V pair in IMSHOW syntaxes. We have to preparse
% this particular P/V pair before we call imageDisplayParseInputs.

preparsed_varargin = varargin;

% Ignore first position if filenane is a string, looking for p/v pairs.
str_loc = cellfun('isclass',varargin,'char');
str_loc(1) = false;
first_param_loc = find(str_loc,1);
if isempty(first_param_loc)
return
end

% scan input args looking for 'Reduce' related args
[reduce,xdata,ydata,initmag] = scanArgsForReduce(first_param_loc,varargin{:});

if reduce

% Make sure we have no parameter conflicts
checkForReduceErrorConditions(initmag,varargin{:});

% get filename and file info
filename = varargin{1};
image_info = imfinfo(filename);
if numel(image_info) > 1
image_info = image_info(1);
warning(message('images:imshow:multiframeFile', filename));
end

try
% find sample factor
[usableWidth usableHeight] = getUsableScreenSize;

sampleFactor = max(ceil(image_info.Width / usableWidth), ...
ceil(image_info.Height / usableHeight));

sampled_rows = getReduceSampling(image_info.Height,sampleFactor);
sampled_cols = getReduceSampling(image_info.Width,sampleFactor);

[imageData, colormap] = imread(filename, 'PixelRegion', ...
{[sampled_rows(1) sampleFactor sampled_rows(end)], ...
[sampled_cols(1) sampleFactor sampled_cols(end)]});

% if we subsample and initmag is not 'fit', warn
initmag_is_fit = ~isempty(initmag) && strcmpi(initmag,'fit');
if sampleFactor > 1 && ~initmag_is_fit
warning(message('images:imshow:reducingImage', makeDataPercentString( sampleFactor )));
end

% if we have read an intensity image, do not supply empty map
if isempty(colormap)
preparsed_varargin = {imageData,varargin{2:end}};
else
preparsed_varargin = {imageData,colormap,varargin{2:end}};
end

catch %#ok<CTCH>
error(message('images:imshow:unableToReduce', filename));
end

% we slightly modify the X & Y Data to take into account the sampling
% of the image
new_xdata = adjustXYData(xdata,image_info.Width,sampled_cols);
p = length(preparsed_varargin);
preparsed_varargin{p+1} = 'XData';
preparsed_varargin{p+2} = new_xdata;

new_ydata = adjustXYData(ydata,image_info.Height,sampled_rows);
p = length(preparsed_varargin);
preparsed_varargin{p+1} = 'YData';
preparsed_varargin{p+2} = new_ydata;

end

end


function [reduce,xdata,ydata,initmag] = scanArgsForReduce(first_param_loc,...
varargin)
% Make initial pass through param list. Check for presence of 'Reduce'
% param/value pair as well as user provided X/YData and InitMag.

reduce = false;
xdata = [];
ydata = [];
initmag = [];
isParam = @(arg,param) ~isempty(strmatch(lower(arg),{param}));
for i = first_param_loc:2:numel(varargin)-1

% check for provided x/y data
if isParam(varargin{i},'xdata')
xdata = varargin{i+1};
continue
end
if isParam(varargin{i},'ydata')
ydata = varargin{i+1};
continue
end

% check for initial magnification
if isParam(varargin{i},'initialmagnification')
initmag = varargin{i+1};
continue
end

% check for reduce
if isParam(varargin{i},'reduce');
reduce = varargin{i+1};
validateattributes(reduce,{'numeric','logical'},{'nonempty'},...
mfilename,'Reduce', i+1);
continue
end
end

end


function checkForReduceErrorConditions(initmag,varargin)
% checks for several error conditions that can occur with uses of 'Reduce'
% parameter.

% Check for the IMSHOW(FILENAME,...) syntax
filename_syntax = ischar(varargin{1});
if ~filename_syntax
error(message('images:imshow:badReduceSyntax'))
end
filename = varargin{1};

% Check for supplied 'InitialMagnification' param/value pair
if ~isempty(initmag)
if isnumeric(initmag)
error(message('images:imshow:incompatibleParameters'))
end
end

% Verify input file is a TIFF file for Reducing
image_info = imfinfo(filename);
image_info = image_info(1);
if ~strcmpi(image_info.Format,'tif');
error(message('images:imshow:badReduceFormat'))
end

end


function string_value = makeDataPercentString(sampleFactor)
% generates magnification string with significant digits that change based
% on the magnitude

actual_val = 100 / sampleFactor;
if actual_val < 1
string_value = sprintf('%.2f',actual_val);
elseif actual_val < 10
string_value = sprintf('%.1f',actual_val);
else
string_value = sprintf('%d',round(actual_val));
end

end


function [usableWidth usableHeight] = getUsableScreenSize
% returns the width and height of the usable screen area. Assumes 'Border'
% is loose for simplicity

% get the size of screen and the figure decorations
wa = getWorkArea;
p = figparams;

% compute usable area
usableWidth = wa.width - p.horizontalDecorations - p.looseBorderWidth;
usableHeight = wa.height - p.verticalDecorations - p.looseBorderHeight;

end


function new_data = adjustXYData(default_data,image_dim,samples)
% adjusts the X and Y data to account for sub sampling.

% provide default XYData if none was specified
if isempty(default_data)
default_data = [1 image_dim];
end

% verify x/ydata is 2-element numeric
if ~isequal(numel(default_data),2) || ~isnumeric(default_data)
error(message('images:imshow:invalidXYData'));
end

% adjust the endpoints of the X/YData to account for clipped pixels
spatial_to_pixel_ratio = (default_data(2) - default_data(1)) / (image_dim - 1);

% start clipping
first_pixel = samples(1);
removed_pixels = first_pixel - 1;
removed_spatial_units = removed_pixels * spatial_to_pixel_ratio;
first_spatial_coord = default_data(1) + removed_spatial_units;

% end clipping
last_pixel = samples(end);
removed_pixels = image_dim - last_pixel;
removed_spatial_units = removed_pixels * spatial_to_pixel_ratio;
last_spatial_coord = default_data(2) - removed_spatial_units;

new_data = [first_spatial_coord last_spatial_coord];

end

aminezer

Messages : 17
Date d'inscription : 04/12/2015

Revenir en haut Aller en bas

Re: lcs tp7 figure groupe 20

Message par Contenu sponsorisé


Contenu sponsorisé


Revenir en haut Aller en bas

Voir le sujet précédent Voir le sujet suivant Revenir en haut

- Sujets similaires

 
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum