How can I display image size, dimensions and color type in the GUI?

9 次查看(过去 30 天)
What i want to do is basically display the image dimension i.e. its height and width along with colotype (ex. truecolor) and size of the image in kb.

采纳的回答

Ben11
Ben11 2014-8-18
编辑:Ben11 2014-8-18
You can get the information about an image file using imfinfo, which outputs a structure with various fields including the width, height and colortype.
For example:
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: []
Then you can get the info you want with regular structure assignment:
With = InfoImage.Width;
Height = InfoImage.Height;
Colortype = InfoImage.ColorType.
After that you're good to go. You can display this information in textboxes by setting their "String" property to what you want:
set(handles.WidthTextbox,'String',num2str(InfoImage.Width));
and so on for the other fields.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Segmentation and Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by