Вы можете получить информацию о файле изображения, используя imfinfo, который выводит структуру с различными полями, включая ширину, высоту и цветовой тип.
Например:
InfoImage = imfinfo('peppers.png');
InfoImage =
Filename: '/Applications/MATLAB_R2014a.app/toolbox/matlab/imagesc...'
FileModDate: '02-Apr-2013 15:55:52'
FileSize: 287677
Format: 'png'
FormatVersion: []
Width: 512
Height: 384
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: [137 80 78 71 13 10 26 10]
Colormap: []
Histogram: []
InterlaceType: 'none'
Transparency: 'none'
SimpleTransparencyData: []
BackgroundColor: []
RenderingIntent: []
Chromaticities: []
Gamma: []
XResolution: []
YResolution: []
ResolutionUnit: []
XOffset: []
YOffset: []
OffsetUnit: []
SignificantBits: []
ImageModTime: '16 Jul 2002 16:46:41 +0000'
Title: []
Author: []
Description: 'Zesty peppers'
Copyright: 'Copyright The MathWorks, Inc.'
CreationTime: []
Software: []
Disclaimer: []
Warning: []
Source: []
Comment: []
OtherText: []
Затем вы можете получить необходимую информацию с помощью регулярного назначения структуры:
With = InfoImage.Width;
Height = InfoImage.Height;
Colortype = InfoImage.ColorType;
После этого ты можешь идти. Вы можете отобразить эту информацию в текстовых полях, установив для их свойства «String» то, что вы хотите:
set(handles.WidthTextbox,'String',num2str(InfoImage.Width));
and so on for the other fields.
ПРОВЕРИТЬ БОЛЬШЕ ЗДЕСЬ .