Image Processing Toolbox™ User’s Guide R2013b How to Contact MathWorks www.mathworks.com Web comp.soft-sys.matlab Newsgroup www.mathworks.com/contact_TS.html TechnicalSupport [email protected] Productenhancementsuggestions [email protected] Bug reports [email protected] Documentationerrorreports [email protected] Orderstatus,licenserenewals,passcodes [email protected] Sales,pricing,andgeneralinformation 508-647-7000 (Phone) 508-647-7001 (Fax) The MathWorks, Inc. 3 Apple Hill Drive Natick, MA 01760-2098 Forcontactinformationaboutworldwideoffices,seetheMathWorksWebsite. ImageProcessingToolbox™User’sGuide ©COPYRIGHT1993–2013byTheMathWorks,Inc. Thesoftwaredescribedinthisdocumentisfurnishedunderalicenseagreement.Thesoftwaremaybeused orcopiedonlyunderthetermsofthelicenseagreement. Nopartofthismanualmaybephotocopiedor reproducedinanyformwithoutpriorwrittenconsentfromTheMathWorks,Inc. FEDERALACQUISITION:ThisprovisionappliestoallacquisitionsoftheProgramandDocumentation by,for,orthroughthefederalgovernmentoftheUnitedStates. ByacceptingdeliveryoftheProgram orDocumentation,thegovernmentherebyagreesthatthissoftwareordocumentationqualifiesas commercialcomputersoftwareorcommercialcomputersoftwaredocumentationassuchtermsareused ordefinedinFAR12.212,DFARSPart227.72,andDFARS252.227-7014. Accordingly,thetermsand conditionsofthisAgreementandonlythoserightsspecifiedinthisAgreement,shallpertaintoandgovern theuse,modification,reproduction,release,performance,display,anddisclosureoftheProgramand Documentationbythefederalgovernment(orotherentityacquiringfororthroughthefederalgovernment) andshallsupersedeanyconflictingcontractualtermsorconditions. IfthisLicensefailstomeetthe government’sneedsorisinconsistentinanyrespectwithfederalprocurementlaw,thegovernmentagrees toreturntheProgramandDocumentation,unused,toTheMathWorks,Inc. Trademarks MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See www.mathworks.com/trademarksforalistofadditionaltrademarks. Otherproductorbrand namesmaybetrademarksorregisteredtrademarksoftheirrespectiveholders. Patents MathWorks products are protected by one or more U.S. patents. Please see www.mathworks.com/patentsformoreinformation. Revision History August1993 Firstprinting Version1 May1997 Secondprinting Version2 April2001 Thirdprinting RevisedforVersion3.0 June2001 Onlineonly RevisedforVersion3.1(Release12.1) July2002 Onlineonly RevisedforVersion3.2(Release13) May2003 Fourthprinting RevisedforVersion4.0(Release13.0.1) September2003 Onlineonly RevisedforVersion4.1(Release13.SP1) June2004 Onlineonly RevisedforVersion4.2(Release14) August2004 Onlineonly RevisedforVersion5.0(Release14+) October2004 Fifthprinting RevisedforVersion5.0.1(Release14SP1) March2005 Onlineonly RevisedforVersion5.0.2(Release14SP2) September2005 Onlineonly RevisedforVersion5.1(Release14SP3) March2006 Onlineonly RevisedforVersion5.2(Release2006a) September2006 Onlineonly RevisedforVersion5.3(Release2006b) March2007 Onlineonly RevisedforVersion5.4(Release2007a) September2007 Onlineonly RevisedforVersion6.0(Release2007b) March2008 Onlineonly RevisedforVersion6.1(Release2008a) October2008 Onlineonly RevisedforVersion6.2(Release2008b) March2009 Onlineonly RevisedforVersion6.3(Release2009a) September2009 Onlineonly RevisedforVersion6.4(Release2009b) March2010 Onlineonly RevisedforVersion7.0(Release2010a) September2010 Onlineonly RevisedforVersion7.1(Release2010b) April2011 Onlineonly RevisedforVersion7.2(Release2011a) September2011 Onlineonly RevisedforVersion7.3(Release2011b) March2012 Onlineonly RevisedforVersion8.0(Release2012a) September2012 Onlineonly RevisedforVersion8.1(Release2012b) March2013 Onlineonly RevisedforVersion8.2(Release2013a) September2013 Onlineonly RevisedforVersion8.3(Release2013b) Contents Getting Started 1 ImageProcessingToolboxProductDescription ...... 1-2 KeyFeatures ..................................... 1-2 ConfigurationNotes ............................... 1-3 RelatedProducts .................................. 1-4 Compilability ..................................... 1-5 ImageImportandExport .......................... 1-6 Introduction ...................................... 1-6 Step1: ReadandDisplayanImage ................... 1-6 Step2: CheckHowtheImageAppearsintheWorkspace .. 1-7 Step3: ImproveImageContrast ..................... 1-8 Step4: WritetheImagetoaDiskFile ................ 1-10 Step5: ChecktheContentsoftheNewlyWrittenFile .... 1-10 ImageEnhancementandAnalysis ................... 1-12 Introduction ...................................... 1-13 Step1: ReadImage ................................ 1-13 Step 2: Use Morphological Opening to Estimate the Background .................................... 1-13 Step 3: View the Background Approximation as a Surface ........................................ 1-14 Step4: SubtracttheBackground Imagefrom the Original Image ......................................... 1-15 Step5: IncreasetheImageContrast .................. 1-16 Step6: ThresholdtheImage ........................ 1-17 Step7: IdentifyObjectsintheImage ................. 1-17 Step8: ExamineOneObject ......................... 1-18 Step9: ViewAllObjects ............................ 1-19 Step10: ComputeAreaofEachObject ................ 1-20 Step11: ComputeArea-basedStatistics ............... 1-21 v Step12: CreateHistogramoftheArea ................ 1-22 GettingHelp ...................................... 1-23 ProductDocumentation ............................ 1-23 ImageProcessingExamples ......................... 1-23 MATLABNewsgroup .............................. 1-24 Acknowledgments ................................. 1-25 Introduction 2 ImagesinMATLAB ................................ 2-2 ExpressingImageLocations ........................ 2-3 PixelIndices ..................................... 2-3 SpatialCoordinates ................................ 2-4 ImageTypesintheToolbox ........................ 2-10 OverviewofImageTypes ........................... 2-10 BinaryImages .................................... 2-11 IndexedImages ................................... 2-12 GrayscaleImages ................................. 2-14 TruecolorImages .................................. 2-15 ConvertingBetweenImageTypes ................... 2-19 ConvertingBetweenImageClasses ................. 2-21 OverviewofImageClassConversions ................. 2-21 LosingInformationinConversions ................... 2-21 ConvertingIndexedImages ......................... 2-21 WorkingwithImageSequences ..................... 2-23 Overview of Toolbox Functions That Work with Image Sequences ..................................... 2-23 ProcessImageSequences ........................... 2-26 ProcessMulti-FrameImageArrays ................... 2-27 vi Contents ImageArithmetic .................................. 2-29 OverviewofImageArithmeticFunctions .............. 2-29 ImageArithmeticSaturationRules ................... 2-30 NestingCallstoImageArithmeticFunctions ........... 2-30 Reading and Writing Image Data 3 GettingInformationAboutaGraphicsFile .......... 3-2 ReadingImageData ............................... 3-3 WritingImageDatatoaFile ........................ 3-5 Overview ........................................ 3-5 SpecifyingFormat-SpecificParameters ................ 3-6 ReadingandWritingBinaryImagesin1-BitFormat .... 3-6 DeterminingtheStorageClassoftheOutputFile ....... 3-7 ConvertingBetweenGraphicsFileFormats .......... 3-8 WorkingwithDICOMFiles ......................... 3-9 OverviewofDICOMSupport ........................ 3-9 ReadingMetadatafromaDICOMFile ................ 3-10 ReadingImageDatafromaDICOMFile .............. 3-12 WritingImageDataorMetadatatoaDICOMFile ...... 3-13 WorkingwithMayoAnalyze7.5Files ................ 3-19 WorkingwithInterfileFiles ........................ 3-20 WorkingwithHighDynamicRangeImages .......... 3-21 UnderstandingDynamicRange ...................... 3-21 ReadingaHighDynamicRangeImage ................ 3-21 CreatingaHighDynamicRangeImage ............... 3-22 ViewingaHighDynamicRangeImage ................ 3-22 WritingaHighDynamicRangeImagetoaFile ......... 3-23 vii Displaying and Exploring Images 4 ImageDisplayandExplorationOverview ............ 4-2 DisplayingImagesUsingtheimshowFunction ....... 4-4 Overview ........................................ 4-4 SpecifyingtheInitialImageMagnification ............. 4-6 ControllingtheAppearanceoftheFigure .............. 4-6 DisplayingEachImageinaSeparateFigure ........... 4-7 DisplayingMultipleImagesintheSameFigure ........ 4-8 UsingtheImageViewerApptoExploreImages ...... 4-11 ImageViewerAppOverview ........................ 4-11 OpeningtheImageViewer .......................... 4-13 SpecifyingtheInitialImageMagnification ............. 4-14 SpecifyingtheColormap ............................ 4-15 ImportingImageDatafromtheWorkspace ............ 4-17 ExportingImageDatatotheWorkspace ............... 4-18 SavingtheImageDataDisplayedintheImageViewer ... 4-18 ClosingtheImageViewer ........................... 4-20 PrintingtheImageintheImageViewer ............... 4-20 ExploringVeryLargeImages ....................... 4-21 Overview ........................................ 4-21 CreatinganR-SetFile ............................. 4-21 OpeninganR-SetFile .............................. 4-22 UsingImageViewerAppNavigationAids ............ 4-23 NavigatinganImageUsingtheOverviewTool ......... 4-23 PanningtheImageDisplayedintheImageViewer ...... 4-26 Zooming In and Out on an Image in the Image Viewer App ........................................... 4-27 SpecifyingtheMagnificationoftheImage ............. 4-27 GettingInformationaboutthePixelsinanImage .... 4-30 DeterminingtheValueofIndividualPixels ............ 4-30 DeterminingtheValuesofaGroupofPixels ........... 4-32 DeterminingtheDisplayRangeofanImage ........... 4-35 viii Contents MeasuringtheDistanceBetweenTwoPixels ......... 4-37 UsingtheDistanceTool ............................ 4-37 ExportingEndpointandDistanceData ................ 4-38 CustomizingtheAppearanceoftheDistanceTool ....... 4-39 Getting Information About an Image Using the Image InformationTool ................................ 4-40 Adjusting Image Contrast Using the Adjust Contrast Tool ............................................ 4-42 UnderstandingContrastAdjustment ................. 4-42 StartingtheAdjustContrastTool .................... 4-43 UsingtheHistogramWindowtoAdjustImageContrast .. 4-46 UsingtheWindow/LevelTooltoAdjustImageContrast .. 4-47 ModifyingImageData ............................. 4-50 CropanImageUsingtheImageViewerApp ......... 4-52 ViewingImageSequences .......................... 4-55 ImageSequences .................................. 4-55 ViewImageSequencesintheVideoViewerApp ........ 4-55 ViewingImageSequencesasaMontage ............... 4-64 ConvertingaMultiframeImagetoaMovie ............ 4-66 DisplayingDifferentImageTypes ................... 4-67 DisplayingIndexedImages ......................... 4-67 DisplayingGrayscaleImages ........................ 4-68 DisplayingBinaryImages .......................... 4-69 DisplayingTruecolorImages ........................ 4-71 AddingaColorbartoaDisplayedImage ............. 4-73 PrintingImages ................................... 4-75 PrintingandHandleGraphicsObjectProperties ........ 4-75 SettingToolboxPreferences ........................ 4-77 ViewingandChangingPreferencesUsingthePreferences DialogBox ..................................... 4-77 Retrieving the Values of Toolbox Preferences Programmatically ............................... 4-77 ix Setting the Values of Toolbox Preferences Programmatically ............................... 4-78 Building GUIs with Modular Tools 5 ModularInteractiveTools .......................... 5-2 DisplayingtheTargetImage ........................ 5-10 CreatingtheModularTools ........................ 5-11 Overview ........................................ 5-11 AssociatingModularToolswithaParticularImage ...... 5-12 GettingtheHandleoftheTargetImage ............... 5-14 SpecifyingtheParentofaModularTool ............... 5-15 PositioningtheModularToolsinaGUI ............... 5-18 BuildaPixelInformationGUI ....................... 5-19 AddingNavigationAidstoaGUI .................... 5-22 CustomizingModularToolInteractivity ............. 5-28 Overview ........................................ 5-28 BuildImageComparisonTool ....................... 5-29 CreatingYourOwnModularTools .................. 5-33 Overview ........................................ 5-33 CreateAngleMeasurementTool ..................... 5-35 Geometric Transformations 6 ResizeanImage ................................... 6-2 Overview ........................................ 6-2 SpecifyingtheInterpolationMethod .................. 6-3 PreventingAliasingbyUsingFilters .................. 6-4 x Contents
Description: