Image Resizing before loading

1 visualizzazione (ultimi 30 giorni)
10B
10B il 5 Ott 2015
Commentato: 10B il 6 Ott 2015
Hello Community,
When I read in an image - it is always too big to fit on screen so needs resizing, as below:
>> figure
>> myImage = ('IMG_2512.JPG');
>> imshow(myImage)
Warning: Image is too big to fit on screen; displaying at 17%
> In imuitools\private\initSize at 71
In imshow at 282
How can I resize the image beforehand so this error is not a problem, and it speeds up the loading process?
Thanks.
Regards,
10B.

Risposta accettata

Image Analyst
Image Analyst il 5 Ott 2015
Modificato: Image Analyst il 5 Ott 2015
That's not an error. It's not even really a warning - I consider it more of a notification. Just ignore it. If you want to suppress that warning, run this function:
% http://www.mathworks.com/help/matlab/matlab_prog/suppress-warnings.html
function TurnOffWarnings
try
% To set the warning state, you must first know the message identifier for the one warning you want to enable.
% Query the last warning to acquire the identifier. For example:
% warnStruct = warning('query', 'last')
% messageID = warnStruct.identifier
% messageID =
% MATLAB:concatenation:integerInteraction
% Turn off this warning "Warning: Image is too big to fit on screen; displaying at 33% "
warning('off', 'Images:initSize:adjustingMag');
% Get rid of warning about directory already existing:
% "Warning: Directory already exists."
warning('off', 'MATLAB:MKDIR:DirectoryExists');
% Turn off note "Warning: Added specified worksheet." that appears in the command window.
warning('off', 'MATLAB:xlswrite:AddSheet');
% Get rid of warning about roipolyold being deprecated:
% "Warning: Function ROIPOLYOLD will be removed in the future. Use ROIPOLY instead"
warning('off', 'images:removing:function');
% Get rid of warning about wavread() being deprecated:
% "Warning: WAVREAD will be removed in a future release. Use AUDIOREAD instead."
warning('off', 'MATLAB:audiovideo:wavread:functionToBeRemoved');
% Get rid of warning about wavread() being deprecated:
% "Warning: figure JavaFrame property will be obsoleted in a future release. For more information see the JavaFrame resource on the MathWorks web site."
warning('off', 'MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');
% Turn off warning about variable names being modified if you use readtable() to read in column headers that have spaces in them.
% "Warning: Variable names were modified to make them valid MATLAB identifiers."
warning('off', 'MATLAB:table:ModifiedVarnames');
catch ME
errorMessage = sprintf('Error in function %s() at line %d.\n\nError Message:\n%s', ...
ME.stack(1).name, ME.stack(1).line, ME.message);
fprintf(1, '%s\n', errorMessage);
uiwait(warndlg(errorMessage));
end
return; % from TurnOffWarnings
  3 Commenti
Image Analyst
Image Analyst il 5 Ott 2015
You forgot the filename. To scale to 0-255, which is what that does, do this:
im2 = uint8(255*mat2gray(im));
imwrite(im2, filename);
10B
10B il 6 Ott 2015
Thank you again Image Analyst - Always top quality answers!

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by