当前位置:网站首页>Import image method
Import image method
2022-07-21 00:39:00 【jk_ one hundred and one】
Catalog
Get information about image files
from TIFF Read image data and metadata from the file
To import the data in the drawing file into MATLAB work area , Use imread function . Using this function, you can import data from many files with standard file formats , These file formats include : Tag image file format (TIFF)、 Graphics exchange format (GIF)、 Joint imaging expert group (JPEG) And portable network graphics (PNG) Format . A complete list of supported formats , You can refer to imread Use of functions .
The following example will JPEG The image data stored in the format file is in an array I Read MATLAB work area :
I = imread('ngc6543a.jpg');
imread Represent the image in the workspace as uint8 Class . The dimension of the array depends on the format of the data . for example ,imread Use three dimensions to represent RGB Color image :
whos I
Name Size Bytes Class
I 650x600x3 1170000 uint8 array
Grand total is 1170000 elements using 1170000 bytes
We should control more TIFF File reading , have access to Tiff object - For details, please refer to from TIFF Read image data and metadata from the file .
Get information about image files
If there are files in standard graphic format , You can use imfinfo Function to get information about its contents .imfinfo Function returns a structure containing information about the file . The fields in the structure differ according to the file format ,imfinfo Always return some basic information , Include the file name 、 Date last modified 、 File size and format .
The following example returns to the joint imaging expert group (JPEG) Information about the format file :
info = imfinfo('ngc6543a.jpg')
info =
Filename: 'matlabroot\toolbox\matlab\demos\ngc6543a.jpg'
FileModDate: '01-Oct-1996 16:19:44'
FileSize: 27387
Format: 'jpg'
FormatVersion: ''
Width: 600
Height: 650
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: ''
NumberOfSamples: 3
CodingMethod: 'Huffman'
CodingProcess: 'Sequential'
Comment: {'CREATOR: XV Version 3.00b Rev: 6/15/94 Quality =...'}
from TIFF Read image data and metadata from the file
Although it can be used imread from TIFF Import image data and metadata into the file , But this function has some limitations . for example ,TIFF The file can contain multiple images , And each image can have multiple sub images . Although it can be used imread From multiple images TIFF Read all images in the file , But the sub image cannot be accessed . Use Tiff Objects can be TIFF Read image data from file 、 Metadata and sub images . Tectonic Tiff Object representation and TIFF File connection , And to provide for LibTIFF Access to numerous routines in the library .
The following example steps through how to use Tiff The methods and properties of the object are from TIFF File read sub image . To make full use of Tiff object , Please be familiar with TIFF Specifications and technical descriptions .
from TIFF Read the sub image in the file
TIFF The file can contain one or more image file directories (IFD). Every IFD Both contain image data and metadata associated with images ( Mark ). Every IFD Can contain one or more subIFD, The latter can also contain image data and metadata . These sub images usually contain subIFD Of IFD Reduced resolution version of image data in ( thumbnail ).
To read IFD Sub image in , Must be from SubIFD Where to get the sub image in the tag .SubIFD The tag contains an array of byte offsets pointing to the sub image . then , Can be subIFD The address of is passed to setSubDirectory Method to convert the subIFD Set to current IFD. majority Tiff Object methods act on the current IFD.
Use Tiff The object constructor opens the TIFF file . The following example uses the TIFF Created in the file subdirectory TIFF file , The file contains one with two subIFD Of IFD Catalog .Tiff Constructor opens the TIFF file , And the first one in the file subIFD Set to current IFD:
t = Tiff('my_subimage_file.tif','r');
Search with current IFD The associated subIFD The location of . Use getTag Method to get SubIFD The value of the tag . This method will return the specified subIFD Byte offset array of position :
offsets = getTag(t,'SubIFD')
Navigate to the first sub image . First , take currentIFD Set as the directory containing the first sub image :
dirNum = 1; setDirectory(t,dirNum);
then , Use setSubDirectory Method to navigate to the first subIFD. Specify the subIFD Byte offset of as a parameter . This call will change the subIFD Set to current IFD:
setSubDirectory(t,offsets(1));
Adopt and read any other in the file IFD In the same way , Read the current IFD( first subIFD) Image data in :
subimage_one = read(t);
View the first sub image :
imagesc(subimage_one)
Navigate to the second sub image . First , take currentIFD Reset to the directory containing the second sub image :
setDirectory(t,dirNum);
And then use setSubDirectory Method to navigate to the second subIFD. Specify the second subIFD Byte offset of :
setSubDirectory(t,offsets(2));
And read any other in the file IFD equally , Read the current IFD( the second subIFD) Image data in .
subimage_two = read(t);
View the second sub image :
imagesc(subimage_two)
close Tiff object :
close(t);
边栏推荐
- Luogu p4305 does not repeat numbers
- How can easycvr solve RTMP offline caused by restarting after configuring RTMP streaming?
- MYSQL中变量的操作
- 吴恩达-02 改善深层神经网络:超参数调试、正则化以及优化
- EL & JSTL: summary of El expression
- 央视新闻《成都开住宿手撕定额发票》新闻频道_人民网
- Web性能测试需求分析,具体应该怎么做?
- codeforces每日5题(均1500)-第二十天
- 央视新闻《北京开住宿手撕定额发票》新闻频道_人民网
- 10. Démarrage rapide du moteur
猜你喜欢
随机推荐
Linux CentOS 7 installation mysql8.0.19
10. Démarrage rapide du moteur
EasyCVR接入国标GB28181设备,通道没有音频是什么原因?
CVE-2014-6271 “破壳“ 漏洞
央视新闻《重庆开餐饮手撕定额发票》新闻频道_人民网
High single kV load caused by tidb read hotspot
央视新闻《南京开餐饮手撕定额发票》新闻频道_人民网
continue Statement
What are the common methods of functional testing of Web testing? What are the main points to pay attention to?
【技术人才懂的浪漫】TiDB 社区为你准备好了给另一半的“七夕节”礼物,人人都有份哟!
MATLAB教程_台大郭彦甫笔记汇总(内附视频资料)
[SWPU2019]Web1-1|SQL注入
Binary installation MySQL 5.7
Apipost :一款值得使用的利器
Yolov5 trains its own VOC dataset
央视新闻《武汉开餐饮手撕定额发票》新闻频道_人民网
央视新闻《青岛开餐饮手撕定额发票》新闻频道_人民网
sudo命令以其他用户执行命令
Chinese Mainland IP segment (including Hong Kong and Macao) [2022-07-15]
央视新闻《杭州开餐饮手撕定额发票》新闻频道_人民网