Matlab图像采集与处理.docx
- 文档编号:9397201
- 上传时间:2023-02-04
- 格式:DOCX
- 页数:51
- 大小:626.99KB
Matlab图像采集与处理.docx
《Matlab图像采集与处理.docx》由会员分享,可在线阅读,更多相关《Matlab图像采集与处理.docx(51页珍藏版)》请在冰豆网上搜索。
Matlab图像采集与处理
CONTENTS
I、BasicImageAcquisitionProcedure
II、图像采集工具箱重要图解
III、ImageTypesandConverting图像类型及其转换
IV、DisplayingandExploringImages图像显示
V、SpatialTransformations图像的几何运算
VI、ImageRegistration图像的对齐
VII、DesigningandImplementing2-DLinearFiltersforImageData二维滤波器
VIII、Transforms图像的变换
IX、MorphologicalOperations形态学运算
X、AnalyzingandEnhancingImages图像分析和增强
XI、ROI-BasedProcessing图像分区域处理
XII、ImageDeblurring图像复原
XIII、Color色彩空间
XIV、NeighborhoodandBlockOperations邻域运算
FunctionReference
一、
BasicImageAcquisitionProcedure
Step1
硬件安装
Step2
获取信息
>>imaqhwinfo
InstalledAdaptors:
{'coreco''winvideo'}
MATLABVersion:
'7.9(R2009b)'
ToolboxName:
'ImageAcquisitionToolbox'
ToolboxVersion:
'3.4(R2009b)'
>>imaqhwinfo('winvideo')
AdaptorDllName:
C:
\...\toolbox\imaq\imaqadaptors\win32\mwwinvideoimaq.dll'
AdaptorDllVersion:
'3.4(R2009b)'
AdaptorName:
'winvideo'
DeviceIDs:
{[1]}
DeviceInfo:
[1x1struct]
>>imaqhwinfo('winvideo',1)
DefaultFormat:
'RGB24_320x240'
DeviceFileSupported:
0
DeviceName:
'USBPCCamera'
DeviceID:
1
ObjectConstructor:
'videoinput('winvideo',1)'
SupportedFormats:
{1x6cell}
>>dev_info.SupportedFormats
'RGB24_160x120''RGB24_176x144''RGB24_320x240'
'RGB24_352x288''RGB24_640x480''RGB24_800x600'
>>dev_info.SupportedFormats(6)
'RGB24_800x600'
Step3
创建videoinput对象
>>vid=videoinput('winvideo',1,'RGB24_800x600')
SummaryofVideoInputObjectUsing'USBPCCamera'.
AcquisitionSource(s):
input1isavailable.
AcquisitionParameters:
…
TriggerParameters:
1'immediate'trigger(s)onSTART.
Status:
….
Step4
(optional)
预览视频流
>>preview(vid)
>>closepreview(vid)
Step5
(optional)
配置对象属性
>>get(vid)
GeneralSettings:
DeviceID=,DiskLogger=[],DiskLoggerFrameCount=0
EventLog=[1x0struct],FrameGrabInterval=1,FramesAcquired=0
FramesAvailable=0,FramesPerTrigger=10,Logging=off
LoggingMode=memory,Name=RGB24_800x600-winvideo-1
NumberOfBands=3,Previewing=off,ROIPosition=[00800600]
Running=off,Tag=,Timeout=10,Type=videoinput,UserData=[]
VideoFormat=RGB24_800x600,VideoResolution=[800600]
ColorSpaceSettings:
BayerSensorAlignment=grbg,ReturnedColorSpace=rgb
CallbackFunctionSettings:
ErrorFcn=@imaqcallback,FramesAcquiredFcn=[]
FramesAcquiredFcnCount=0,StartFcn=[],StopFcn=[],TimerFcn=[]
TimerPeriod=1,TriggerFcn=[]
TriggerSettings:
InitialTriggerTime=[],TriggerCondition=none,TriggerFrameDelay=0
TriggerRepeat=0,TriggersExecuted=0,TriggerSource=none
TriggerType=immediate
AcquisitionSources:
SelectedSourceName=input1,Source=[1x1videosource]
>>get(getselectedsource(vid))
GeneralSettings:
Parent=[1x1videoinput],Selected=on,SourceName=input1,Tag=
Type=videosource
DeviceSpecificProperties:
BacklightCompensation=on,Brightness=20,ColorEnable=on,Contrast=20
Exposure=1,FrameRate=30.0000,Gamma=4,Hue=18
Saturation=50,Sharpness=3
>>set(vid,'TriggerRepeat',Inf);
>>vid.FrameGrabInterval=5;
>>vid_src=getselectedsource(vid);
>>set(vid_src,'Tag','motiondetectionsetup');
Step6
获取图像数据
>>start(vid)
>>data=getdata(vid,6);
>>stop(vid)
Step7
清理
>>delete(vid)
>>clear
>>close(gcf)
二、图像采集工具箱重要图解
1.TheImageAcquisitionToolboxSoftwareComponents
2.RelationshipofVideoInputObjectsandVideoSourceObjects
3.TransitionsfromRunningtoStoppedStates
4.LoggingStateTransitions
5.OverviewofDataLogging
6.ImmediateTrigger
7.ManualTrigger
8.HardwareTrigger
9.SpecifyingtheAmountofDatatoLog
10.ImpactofFrameGrabIntervalonDataLogging
11.FramesAvailableAfterInitialTriggerExecution
12.ContentsofMemoryBufferBeforeandAfterRemovingFrames
13.SpecifyingaDelayBeforeDataLoggingBegins
14.ExecutingMultipleTriggers
15.UsingwaittoBlocktheMATLABCommandLine
16.Deleteatrigger'sworthofimagedata(Theframesacquiredbeforeandafterthecalltoflushdata)
17.LoggingDatatoaDiskFile
18.OverviewofImageAcquisition
19.getdataBlocksUntilFramesBecomeAvailable
20.FramesReturnedbypeekdata
21.FormatofanIndividualFrame
22.InitialTriggerTimeRecordsFirstTriggerExecution
三、ImageTypesandConverting图像类型及其转换
dither
Dithering(抖动)是Gif压缩中一项十分有用的技术。
由于GIF和PNG只有256种颜色,因此,在表现一些含有丰富色彩信息的照片图像或含有平缓过度色的图像时,就会出现梯田状的条形色块,这时,我们就需要用到Dithering(抖动)功能,Dithering可以模仿一些在调色板无法找到的颜色,从而使得整个图像颜色与颜色之间的过渡更为自然,不过,Dithering同样会使图像Size变大,因此,我们更多的将这项技术应用于区域压缩。
demosaic
ConvertBayerpatternencodedimage(与相机RAW格式相关)totruecolor(RGB)image.
类型转换
gray2ind,grayslice,im2bw,ind2gray,ind2rgb,mat2gray,rgb2gray,rgb2ind
Imageclass转换
im2uint8,im2uint16,im2int16,im2single,orim2double
imapprox
索引图像转换可能使用,Approximateindexedimageusingonewithfewercolors
ImageArithmeticSaturationRules
∙Valuesthatexceedtherangeoftheintegertypearesaturatedtothatrange
如300255,-450
∙Fractionalvaluesarerounded
DICOM
DICOM(DigitalimagingandCommunicationsinMedicine)即数字影像和通信标准,规范医学影像及其相关信息的交换。
由美国发射学会和美国国家电器制造商协会NEMA(NationalElectronicalManufacturersAssociation)制定。
∙从文件格式上看,用于保存医学数据的DICOM包容的信息量大(除图像信息外,还有很多附加信息,比如患者病例档案等),格式复杂。
∙DICOM的压缩算法种类很多,也可以保存动画图像
∙DICOM的图像基本都是与医学相关的(MRI,CT等),医学图像的特点是分辨率低,特征不清晰等等。
对这类图像做分割和特征提取难度较大。
MayoAnalyze7.5
Afileformat,developedbytheMayoClinic,forstoringMRI(MagneticResonanceImaging核磁共振成像)data,包含两个文件.hdr和.img。
Interfile
为了使核医学图像和信息能在不同系统上共享,传递以前将各系统的文件转换成统一的Interfile文件格式。
转换后的图像和文件,就可以在不同厂商的计算机上进行图像传递。
HighDynamicRangeImages
Dynamicrangereferstotherangeofbrightnesslevels,using32-bitfloating-pointvaluestostoreeachcolorchannel.
hdrread,makehdr,tonemap(HDR-->RGB),hdrwrite
四、DisplayingandExploringImages图像显示
1.DisplayingImagesUsingtheimshowFunction
∙ImageDisplayedinaFigureWindowbyimshow
>>imshow('moon.tif');
>>I=getimage;%assignstheimagedatafromthefigurewindowcurrentlyactive
∙SpecifyingtheInitialImageMagnification
>>imshow(I,'InitialMagnification',150)
∙ImageDisplayedWithandWithoutaBorder
>>imshow(I,'Border','tight')%'tight'|'loose'
∙DisplayingEachImageinaSeparateFigure
>>figure
∙DisplayingMultipleImagesintheSameFigure
>>subplot(m,n,p)
>>subplot(1,2,1),imshow(I1)
2.UsingimtooltoExploreImages
∙OpeningtheImageTool
>>imtool('moon.tif');
∙SpecifyingtheInitialImageMagnification
∙SpecifyingtheColormap
∙ImportingImageDatafromtheWorkspace
∙ExportingImageDatatotheWorkspace
∙SavingtheImageDataDisplayedintheImageTool
∙ClosingtheImageTool
>>imtoolcloseall
3.ExploringVeryLargeImages
∙Createreducedresolutiondataset(R-Set)fromimagefile
>>rsetfile=rsetwrite(File_Name)
>>rsetfile=rsetwrite(File_Name,output_filename)
File_NameisaTIFForNITFimagefile
4.ViewingImageSequences查看图像序列
∙ViewingImageSequencesintheMoviePlayer
>>loadmristack%<256x256x21uint8>
>>implay(mristack)
∙ViewingImageSequencesasaMontage
>>I=reshape(mristack,[256256121]);%repmatmaybeused
>>montage(I)
∙ConvertingaMultiframeImagetoaMovie
>>I=reshape(mristack,[256256121]);
>>mov=immovie(I);
>>implay(mov)
5.DisplayingDifferentImageTypes(imshow和imtool可替换)
∙DisplayingGrayscaleImagesThatHaveUnconventionalRanges
>>imshow(I,'DisplayRange',[lowhigh])
>>imtool(I,'DisplayRange',[]);
∙ChangingtheDisplayColorsofaBinaryImage
>>imshow(~BW)
>>imshow(BW,[100;001])
∙AddingaColorbartoaDisplayedImage
>>colorbar
6.SettingToolboxPreferences
∙ViewingandChangingPreferencesUsingthePreferencesDialogBox
selectPreferences>ImageProcessingintheFilemenu
∙RetrievingtheValuesofToolboxPreferencesProgrammatically
>>iptgetpref('ImtoolInitialMagnification')
∙SettingtheValuesofToolboxPreferencesProgrammatically
>>iptsetpref('ImshowBorder','tight');
五、SpatialTransformations图像的几何运算
1.基本运算
∙Resizing
>>I1=imresize(I,1.25);
>>X1=imresize(X,[100150],'bilinear')
∙Rotating
>>I1=imrotate(I,35,'bilinear');
∙Cropping
>>I1=imcrop(I);
>>I1=imcrop(I,[604010090]);
2.PerformingGeneral2-DSpatialTransformations
∙OverviewofGeneral2-DSpatialTransformationProcess
∙Example:
PerformingaTranslation
Step1:
ImporttheImagetoBeTransformed
>>I=checkerboard;%<80x80double>
Step2:
DefinetheSpatialTransformation
>>xform=[100;010;40401];
Step3:
CreatetheTFORMStructure
>>tt=maketform('affine',xform);
Step4:
PerformtheTransformation
>>[I1x1y1]=imtransform(I,tt);
Step5:
ViewtheOutputImage
∙AffineTransform仿射变换
是一种二维坐标到二维坐标之间的线性变换,保持二维图形的“平直性”(straightness,即变换后直线还是直线不会打弯,圆弧还是圆弧)和“平行性”(parallelness,其实是指保二维图形间的相对位置关系不变,平行线还是平行线,相交直线的交角不变。
)。
仿射变换可以通过一系列的原子变换的复合来实现,包括:
平移(Translation)、缩放(Scale)、翻转(Flip)、旋转(Rotation)和错切(Shear)。
∙CreatingTFORMStructures
TransformationType:
'affine','projective','box','custom','composite'
∙PerformingN-DimensionalSpatialTransformations
>>maketform
>>makeresampler
>>imtransform
其它:
fliptform,tformfwd,tforminv,findbounds,tformarray
六、ImageRegistration图像的对齐
1.Agraphicillustrationoftheimageregistrationprocess
2.Example:
Performingaregistration
∙Step1:
ReadtheImages
∙Step2:
ChooseControlPointsintheImagesbycpselect
>>I0=imread('westconcordorthophoto.png');%base
>>I1=imread('westconcordaerial.png');%input
>>cpselect(I1,I0)
∙Step3:
SavetheControlPointPairstotheMATLABWorkspace
点击File->ExportPointstoWorkspace,得到
base_points
input_points
∙Step4:
Fine-TunetheControlPointPairPlacement(Optional)
>>INPUT_POINTS=cpcorr(input_points,base_points,I1,I0)
∙Step5:
SpecifytheT
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Matlab 图像 采集 处理
![提示](https://static.bdocx.com/images/bang_tan.gif)