VideoandImageProcessing Blockset 2User’s Guide
1 Gettin g StartedWhat Is Video and Image Processing Blockset?Video and Image Processing Blockset is a tool used for the rapid design,prototyping, gra
4 ConversionsColor Space ConversionThe Color Space Conversion blo ck enables you to conve rt co lor informationfrom the R’G’B ’ color space to the Y’C
Color Space Conversion3 Create a new Simulink model, and add to it the blocks shown in thefollowing table.Block Library QuantityImage FromWorkspaceVid
4 ConversionsOnce you have assembled the blocks needed to convert a R’G’B’ image toan intensity image, you are ready to set your block parameters. To
Color Space Conversion7 View the modified image using the Video Viewer block. Accept the defaultparameters.8 Connect theblockssothatyourmodelissimilar
4 Conversions• Solver pane, Stop time = 0• Solver pane, Type = Fixe d-st ep• Solver pane, Solver = discr ete (no continuous states)10 Run your model.T
Chroma ResamplingChroma ResamplingThe Y’CbCr color space separ ate s the luma (Y’) compon ent of an image fromthe chroma (Cb and Cr) components. Luma
4 Conversions3 Create a new Simulink model, and add to it the blocks shown in thefollowingtable.Block Library QuantityImage FromWorkspaceVideoandImage
Chroma ResamplingThe blocks to the left of and including the Chroma Resampling blockrepresent the transmission portion of the model. The remaining blo
4 ConversionsTheImagePadblockaddsonecolumntotherightofeachplaneofthearray by repeating its border values. This padding minimizes the effectof the pixe
Chroma Resampling– Index Option = Select all• 2– Index Option =Select all• 3– Index O ption =Index vector (dialog )– Index = 1Set the Selector1 block
InstallationInstallationThis section describes how to install Video and Image Processing Blockset andits d ocumentation. It also reviews the other Mat
4 Conversionsa gamma corrected signal. Set the Image signal parameter to Separatecolor signals.9 Use the Chroma Resampling block to downsample the chr
Chroma Resampling14 Configure Simulink to display signal dimensions next to each signal line.Click Format > Port/Signal Displays > Signal Dimens
4 Conversions17 Examine the signal dimensions in your model. The Chroma Resamplingblock downsamples the Cb and Cr components of the image from 206-by
5Geometric TransformationThe Geometric Transformations library contains blocks that enable you torotate, translate, shear, and resize images.Interpola
5 Geometri c TransformationInterpolation OverviewVideo a nd Image Processing Blockset contains blocks that perform geometrictransformations. These blo
Interpolation Overview1 Zero pad the input matrix and translate it by 1.7 pixels to the right.1230045600789001.7 pixelsOriginal zero-padded matrixTran
5 Geometri c Transformation123456789represents your input image. You want to translate this image 0.5 p ixel inthe p ositiv e horiz ontal direction us
Interpolation Overview123456789represents your input image. You want to translate this image 0.5 p ixel inthe positive horizontal direction using bicu
5 Geometri c TransformationRotating an ImageYoucanusetheRotateblocktorotateyourimageorvideostreambyaspecified angle. In this exampl e, you le arn how
Rotating an ImageBlock Librar y QuantityRotateVideo and Image ProcessingBlockset > G eo metricTransformations1Video Viewer Video and Image Processi
1 Gettin g Started2 Click Download products.3 Log in to the system using your MathWorks Account e-mail and password.If you do not have a MathWorks Acc
5 Geometri c TransformationYou are now ready to set your block parameters by double-clicking theblocks, modifying the blo ck parameter values, and cli
Rotating an ImageThe Angle port appears on the block. You use this port to input a steadilyincreasing angle. Setting the Output size parameter toExpan
5 Geometri c Transformation• Counter size = 16 bits• Output = Count• Clear the Reset input check box.• Sample time =1/30The Counter block counts upwar
Rotating an Image12 Set the configuration parameters. Open the Configuration dialog box byselecting Configuration Parameters from the Simulation menu.
5 Geometri c TransformationNote If you are on a Windows operatin g system, you c an re pla c e the VideoViewer block with the To Video Display block,
Resizing an ImageResizing an ImageYou can use the Resize block to change the size of your image or video stream.In this example, you learn how to use
5 Geometri c TransformationImage Courtesy of Michael Myers5-14
Resizing an Image3 Create a new Simulink model, and add to it the blocks shown in thefollowing table.Block Library QuantityImage FromWorkspaceVideo an
5 Geometri c TransformationThe Video Viewer1 block autom atically displays the original image in theVideo Viewer1 window when you run the model.7 Use
Resizing an Image10 Set the configuration parameters. Open the Configuration dialog box byselecting Configuration Parameters from the Simulation menu.
Product DemosProduct DemosVideo and Image Processing Blockset has a number of demo models that solvereal-world pro blems. B eg in viewing Video and Im
5 Geometri c TransformationThe reduced image appears in the Video Viewer window. Right-click thewindow and select Set D isplay To True Size. The small
Resizing an ImageIn this example, you used the Resize block to shrink an image. For moreinformationaboutthisblock,seetheResizeblockreferencepageintheV
5 Geometri c TransformationCropping an ImageYou can use the Selector block to cro p your image or video stream. In thisexamp le, you learn how to use
Cropping an ImageBlock Library QuantityImage FromWorkspaceVideo and Image ProcessingBlockset > Source s1Video Viewer Video and Image ProcessingBloc
5 Geometri c Transformation7 Use the Selector block to crop the image. Set the block parameters asfollows:• Number of input dimensions =2• 1– Index Op
Cropping an ImageThe Selector block starts at row 140 a nd co lum n 200 of the im ag e andoutputs the next 70 rows and columns of the image.8 Use the
5 Geometri c Transformation10 Set the configuration parameters. Open the Configuration dialog box byselecting Configuration Parameters from the Simula
Cropping an ImageThe cropped image appears in the Video Viewer w indow. The followingimage is shown at its true size.In this example, you used the Sel
5 Geometri c Transformation5-26
6Morphological OperationsMorphological image analysis can be u sedtoperformimagefiltering,imagesegmentation, and measurement operations.Overview of Mo
1 Gettin g StartedDemos on the WebThe MathWorks Web site contains demos that show you how to useVideo and Image Processing Blockset. You can find thes
6 Morphological OperationsOver view of MorphologyMorphology is the s tudy of the shape and form of objects. Morphologicalimage analysis can be used to
CountingObjectsinanImageCountingObjectsinanImageIn this ex ample, you im port an intensity imag e of a wheel from the MATLABworkspace and convert it t
6 Morphological OperationsThe file testpat1.png is an intensity image of a wheel that contains 24black spokes.3 Create a new Simulink model, and add t
CountingObjectsinanImageYou are now ready to set your block parameters by double-clicking theblocks, modifying the blo ck parameter values, and clicki
6 Morphological OperationsThe strel function creates a circular STREL object with a radius of 5pixels. When working with the Openi ng block, pick a ST
CountingObjectsinanImage12 The Display block displays the number of spokes in the input image. Usethe default parameters.13 Connect the block as shown
6 Morphological Operations14 Set the configuration parameters. Open the Configuration dialog box byselecting Configuration Parameters from the Simulat
CountingObjectsinanImageAsyoucanseeintheprecedingfigure, the spokes are now separate whiteobjects. In the model, the Display b lock correctly indicate
6 Morphological OperationsTo Workspace block in Sim ulink or the Signal to Workspace block in SignalProcessing Blockset. For more information about ST
Correcting for Nonuniform IlluminationCorrecting for Nonuniform IlluminationGlobal threshold techniques, which areoftenthefirststepinobjectmeasurement
Working w ith the DocumentationWorking with the DocumentationVideo and Image Processing Blockset documentation includes the Video andImage Processing
6 Morphological OperationsThis image is darker at the bottom than at the top. You want to createa model to even out this lighting.3 Create a new Simul
Correcting for Nonuniform IlluminationBlock Library QuantitySum Simulink > Math Operations2Data Typ e Conversi on Simu link > Sig n al Attribute
6 Morphological OperationsThe stre l function creates a circular STREL object with a radius of 15pixels. When working with the Openi ng block, pick a
Correcting for Nonuniform Illumination13 UsethesecondSumblocktolightentheimagesothatithasthesamebrightness as the original i mage. Set the block param
6 Morphological OperationsThe original image appears in the Video Viewer window. To view theimage at its true size, right-click the window and select
Correcting for Nonuniform IlluminationThe image without the estimated background appears in the Video Viewer2window. The fo llow ing image is show n a
6 Morphological OperationsIn this section, you h ave used the Opening block to remove irregularillumination from an image. For more information about
7Analysis and EnhancementYou can use Video and Image Processing Blockset blocks to learn more aboutthe structure of images as well as to improve them.
7 Analysis and EnhancementFeature ExtractionFeature extraction techniques return information about the structure of animage. For example, you can use
Feature Extraction3 Create a new Simulink model, and add to it the blocks shown in thefollowing table.Block Library QuantityImage FromWorkspaceVideo a
1 Gettin g StartedDocumentationontheWebYou can also view the documentation from the MathWorks Web site. Thedocumentation available on these Web pages
7 Analysis and Enhancement4 Place the blocks so that your model resembles the following figure.You are now ready to set your block parameters by doubl
Feature ExtractionThe Edge Detection block convolves the input matrix with the Sobel kernelto calculate the gradient components of the image that corr
7 Analysis and Enhancement9 Use the Subtract blocks to subtract the minimum values from each elementof the Gv and Gh matrices. This process ensures th
Feature Extraction• Solver pane, Solver = discr ete (no continuous states)15 Run your model.The Video Viewer window displays the e dg es of the r ice
7 Analysis and EnhancementThe Video Viewer2 window displays the intensity image of the horizontalgradient components of the image. In this image, the
Feature Extraction17 Run your model again.Your model runs faster because the Edge D etection block is more efficientwhen you clear the Edge thinning c
7 Analysis and Enhancementimshow(I)Image Courtesy of Steve Decker and Shujaat Nadeem3 Create a new Simulink model, and add to it the blocks shown in t
Feature ExtractionBlock Library QuantityHough Transform Video and Image Processing Blockset> Transforms1Find Local Maxima Video and Image Processin
7 Analysis and Enhancement5 Use the Image From Workspace block to import your image from theMATLAB workspace. Set the Value parameter toI.6 Use the Ed
Feature Extraction9 Use the Find Local Maxima block to find the location of the m a ximumvalue i n the H oug h matrix. Set the block parameters as fol
Working w ith the Documentation• MATLAB, to write scripts and functions w ith M-code, and to use functionswith the command-line interface• Simulink,to
7 Analysis and Enhancement• 1– Index Option =Index vector (dialog)– In dex = 0• Inputportsize= 2Set the Selector1 block parameters as follows :• Index
Feature Extraction16 Set the configuration parameters. Open the Configuration dialog box byselecting Configuration Parameters from the Simulation menu
7 Analysis and EnhancementThe Video Viewer1 window displays t he original imag e with a white linedrawn over the longest line in the image.You have no
Feature Extractionthese bl ock s, see the Hough Transform, Find Local Maxima, and H ough Li n esblock reference pages in the Video and Image Processin
7 Analysis and EnhancementBlock Library QuantityEmbedded MATLABFunctionSimulink > User-Defined Functions1Draw Shapes Video and Image Processing Blo
Feature ExtractionNote In this example, you segment the image using a thresholdingoperation that performs best on the Cb channel of the Y’CbCr color s
7 Analysis and Enhancement6 Use the Submatrix and Submatrix1 blocks to crop the Y’ and Cb matricesto a particular region of interest (ROI). This ROI c
Feature Extraction9 Use theFind Local Maxima block to find the peak values in the Houghmatrix. These values represent potential lines in the input ima
7 Analysis and Enhancement• Starting row = Index• Starting row index = 2• Ending row = Index• Ending row index = 2The Idx port of the Find Local Maxim
Feature Extraction13 Use the Hough Lines block to find the Cartesian coordinates of lines thatare described by rho and theta pairs. Set the Sine value
1 Gettin g Started• ReadChapter8,“ExampleApplications”tolearnhowtotrackthemotionof an object in a video stream. Also, learn more about motion compensa
7 Analysis and Enhancement19 Set the configuration parameters. Open the Configuration dialog box byselecting Configuration Parameters from the Simulat
Feature ExtractionThe Video Viewer window disp lays the orig inal im age.The Video Viewer1 window displays the ROI w he re two beams intersect.7-25
7 Analysis and EnhancementThe Video Viewer2 window displays the ROI that has been annotated withtwo white lines.The Display block shows a value of 54,
Image EnhancementImage EnhancementImage enhancement techniques improve images. You can use them to removenoisefromimages,increasethesignal-to-noiserat
7 Analysis and EnhancementI is a 384-by-512-by-3 array of double-precision floating-point values.Each plane of this array represents the red, green, o
Image EnhancementBlock Library QuantityImage FromWorkspaceVideoandImageProcessingBlockset>Sources1Color SpaceConversionVideoandImageProcessingBlock
7 Analysis and Enhancement7 Use the 2-D FIR Filter block to filter the luma portion of the image. Set theblock parameters as follows:• Coefficients =f
Image EnhancementThe fspecial('unsharp')command creates two-dimensio nal highpassfiltercoefficients suitable for correlation. This highpassf
7 Analysis and Enhancement9 Use the Video Viewer block to automatically display the n ew, sharperimage in the Video Viewer window when you run the mod
Image Enhancement11 Set the configuration parameters. Open the Configuration dialog box byselecting Configuration Parameters from the Simulation menu.
Key Blockset Con ceptsKey Blockset ConceptsIn this section, you learn how the VideoandImageProcessing Blockset blocksinterpret input matrices and arra
7 Analysis and Enhancement13 To blur theimage,double-clickthe2-D FIR Filter block. Set Coefficientsparameter tofspecial('gaussian',[15 15],7
Image EnhancementIn this exampl e, you used the Color S pa ce Conve rsion and 2-D FIR Filterblocks to sharpen and blur an image. For m o re informatio
7 Analysis and EnhancementI= double(imread('circles.png'));I= imnoise(I,'salt & peppe r',0.02);Iis a 256-by-256 matrix of 8-bi
Image EnhancementBlock Library QuantityImage FromWorkspaceVideo and Image Processing Blockset> Sources1Median Filter Video and Image Process in g B
7 Analysis and EnhancementThe Median Filter block replaces the central value of the 3-by-3neighborhood with the median value of the neighborhood. This
Image Enhancement9 Set the configuration parameters. Open the Configuration dialog box byselecting Configuration Parameters from the Simulation menu.
7 Analysis and EnhancementThe cleaner image appears in the Video Viewer1 window. The followingimage is shown at its true size.YouhaveusedtheMedianFilt
Image EnhancementRemoving Periodic Noise from VideoPeriodic noise can be introduced into a video stream during acquisition ortransmission due to elect
7 Analysis and EnhancementYou are now ready to set your block parameters by double-clicking theblocks, modifying the blo ck parameter values, and clic
Image Enhancement6 UsetheImageDataTypeConversionblock to convert the data type of thevideo to singl e- precision f loating point. Accept the d ef au l
How to Contact The MathWorkswww.mathworks.comWebcomp.soft-sys.matlab Newsgroupwww.mathworks.com/contact_TS.html Technical [email protected]
1 Gettin g StartedImage TypesImages can be b inary, intensity (grayscale), or RGB.Binary ImagesBinary images are represented by a Boolean matrix of 0s
7 Analysis and Enhancementradians per sample. The coefficients were created using the Filter Designand Analysis Tool (FDATool) and theftrans2 function
Image Enhancement12 Use theVideo Viewer2 block to view the approxim ation of t he origina lvideo.Accept the default parameters.13 Connect the block as
7 Analysis and Enhancement14 Set the configuration parameters. Open the Configuration dialog box byselecting Configuration Parameters from the Simulat
Image EnhancementThe noisy video appears in the Video Viewer1 window. The following videois shown at its true size.Theapproximationoftheoriginalvideo
7 Analysis and Enhancementblocks, see the R ead Binary File, 2-D FIR Filter, and Video Viewer blockreference pages in the Video and Image P rocessing
Image Enhancement3 Use the Image From File block to import the first image into the Simulinkmodel. Set the File name parameter topout.tif.4 UsetheImag
7 Analysis and EnhancementThis block adjusts the contrast of the image by linearly scaling the pixelvalues between u ser-specified upper and lower lim
Image EnhancementThis block enhances the contrast of images by transforming the values inan intensity image so that the histogram of the output image
7 Analysis and Enhancement• Solver pane, Stop time = 0• Solver pane, Type = Fixe d-st ep• Solver pane, Solver = discr ete (no continuous states)10 Run
Image EnhancementIn this example, you used the Contrast Adjustment block to linearlyscale the pixel values inpout.tif between new upper and lower limi
Key Blockset Con ceptsDefining Intensity and ColorThe values in a binary, intensity, or RGB image can be different d ata types.The data type of the im
7 Analysis and EnhancementBlock Library QuantityImage FromWorkspaceVideo and Image Processing Blockset> Sources1Color SpaceConversionVideo and Imag
Image Enhancement• Image signal = Separate color signals5 Use the Color Space Conversion block to separate the luma informationfrom the color informat
7 Analysis and Enhancement9 Use the Product block to scale the values back to the 0 to 100 range. Acceptthe default parameters.10 Use the Color Space
Image EnhancementAs shown in the following figure, the model displays the original image inthe Video Viewer1 windo w.7-57
7 Analysis and EnhancementAs the next figure shows, the model displays the enhanced contrast imagein the Video Viewer window.In this example, you used
Pixel StatisticsPixel StatisticsVideo and Image Processing Blockset contains blocks that can provideinformation ab ou t the data values that make up a
7 Analysis and Enhancement3 Create a new Simulink model, and add to it the blocks shown in thefollowing table.Block Library QuantityImage FromWorkspac
Pixel StatisticsBlock Library QuantityReshape Simulink > Math Operations3MatrixConcatenationSimulink > Math Operations1Vector Scope Signal Proce
7 Analysis and Enhancement7 UsetheBusCreatorblocktocombinetheR,G,andB,signalsintoonesignal so you can process it with one 2-D Histogram block. Set the
Pixel Statistics10 UsetheReshapeblockstotransformtherowvectorsoutputfromtheBusSelector block into columns vectors. Set the Output dimensionalityparame
1 Gettin g StartedColor Image ProcessingVideoandImageProcessing Blockset enables you to work with color imagesand video signals as multidimensional ar
7 Analysis and EnhancementThe Bus Selector block still needs to be connected. You cannot configurethe parameters of this block until you connect an in
Pixel StatisticsThe original image appears in the Video Viewer window. To view theimage at its true size, right-click the window and select Set Displa
7 Analysis and EnhancementYouhavenowusedthe2-DHistogramblock to calculate the histogram of theR, G, and B values in an RGB image. For m ore informatio
8Example ApplicationsVideoandImageProcessingBlocksetblocksenableyoutotrackobjectsinanimage, stabilize a video stream, and compress images.Pattern Matc
8 Example ApplicationsPattern MatchingPattern matching can be used to recognize and/or locate specific objects inan image. It can be accomplished usin
Pattern MatchingBlock Library QuantityVideo Viewer Video and Image ProcessingBlockset > Sinks1Data Type Conversion Simulink > Signal Attributes1
8 Example Applications4 UsetheImageDataTypeConversionblock to convert the data type of thevideo to singl e- precision f loating point. Accept the d ef
Pattern MatchingBecause you chose Valid for the Output size parameter, the blockoutputs only those parts of the correlation that are computed without
8 Example Applications9 Use the Constant block to define the size of the image of the cat sculpture.Set the Constant value parameter tosingle([41 41])
Pattern Matchingby single-p recision floating-point values, a value of 0 corresponds to blackand a value of 1 corresponds to wh ite.13 Connect the blo
Key Blockset Con ceptsYou can choose to process the image as a multidimensional array by settingthe Im age signal parameter toOne multidimensional sig
8 Example ApplicationsAs the video plays, you can watch the rectangular ROI follow the s culptureas it moves.In this example, you used the 2-D Correla
Motion CompensationMotion CompensationMotion compensation is a set of techniques that take advantage of redundancyin consecutive video frames. The se
8 Example ApplicationsThis demo model detects motio n by analyzing how much objects move betwee nconsecutive v ideo frames. The model aligns two seque
Image CompressionImage CompressionThe examples in this section illustrate how to b uild a Simulink model that iscapable of image compression. For imag
8 Example ApplicationsImage Courtesy of MIT3 Create a new Simulink model, and add to it the blocks shown in thefollowing table.Block Library QuantityI
Image CompressionYou are nowready to set your block parameters by d ouble -clicking theblocks, modifying the blo ck parameter values, and clicking OK.
8 Example ApplicationsThe Block Processing block’s subsystem opens.8-14
Image CompressionYou can drag blocks into this subsystem to process the submatrices.8 Add the following blocks to your subsystem.Block Library Quantit
8 Example Applications10 The 2-D DCT b lock takes the two-dimensional DCT of each submatrix. Thisprocess p uts m ost of the energy in the image into t
Image CompressionYou are using the Selector block to compress the image by extracting theupper left corner of the submatrix, which contains the high e
1 Gettin g StartedThe blocks that support multidimensional arrays meet at least one of thefollowing criteria:• They have the Image signal parameter on
8 Example ApplicationsViewing the Compressed ImageIn “Compre ssingan Image” on page 8-11, you compressed an image usingthe 2-D DCT and Selector blocks
Image Compression4 Open the block’s subsystem by clicking Open Subsystem,andaddthefollowing blocks to it.Block Library QuantityImage Pad Video and Ima
8 Example Applications5 Connect the blocks as shown in the following figure.6 UsetheImagePadblocktozeropadthe4-by-4submatrixbacktoitsoriginal 8-by-8 s
Image CompressionBecause z eros are replacing the low en ergy transform coefficients, theoutput image is an approximation of the original image.7 The
8 Example Applications9 UsetheVideoViewerblocktoviewthecompressedimage. Acceptthedefault parameters.10 Connect the blocks as shown in the following fi
Image CompressionThe compressed image is displayed in the Video Viewer window. Thecompressed i mage is not as clear as the original image. However, it
8 Example Applicationsreference pages in the Video and Image P rocessing Blockset Reference.Forinformation on the Selector block, see the Simulink doc
IndexIndexAAccelerator mode 1-23adding periodic noise to a signal 7-41adjustingintensity image contrast 7-48RGB image contra st 7-53Adobe Acrobat Read
Indexcontrastincreasing 2-27controlling video duration 1-22conventionscolumn-major format 1-21conversioncolor space 4-14intensity to binary 4-2R’G’B’
Indexlines in images 7-9form of objects 6-2frequency distributionof elements in an image 7-59fspecial function 7-27Ggamma correction 4-14geometric tra
Key Blockset Con cepts1-17
Indexinterpretation ofmatrices 1-11irregular illumination 6-11Kkey blockset concepts 1-11knowledgeuser’s expected 1-8Llabeling objects 6-3lightening i
Indexinterpolation 5-2morphology 6-2VideoandImageProcessingBlockset 1-2Ppadding 7-41pattern matching 8-2performanceimproving 1-23periodic noiseremoval
Indexsummary of morphology 6-2Ttechniquesmotion compensation 8-9sum of absolute differences (SAD) 8-9thresholding 6-11thresholding operation 4-2with u
1 Gettin g StartedTo process the individual color planes of an image or video signal, set theImage signal parameter toSeparate color signal s in both
Key Blockset Con ceptsIf you a re working with a block that only outpu ts multidimensional arrays,you can use the Selector block to separate the color
1 Gettin g StartedFor pixel coordinates, the first comp onent r (the row) increases dow nward,while the second component c (the column) increases to t
Key Blockset Con ceptspositions. Seco nd, the spatial coordinates of the cente r point of any p ix el areidentical to the pixel coordinates for that p
Revision HistoryJuly 2004 First printing New for Version 1.0 (Release 14)October 2004 Second printing Revised for Version 1.0.1 (Release 14SP1)March 2
1 Gettin g StartedThe Solver, w h ile in scheduler mode, uses a block’s sample time to determinewhen the code behind each block is executed. For examp
Key Blockset Con ceptsNormal and Accelerator ModeThe Simulink Accelerator removes much of the computational overheadrequired by Simulink models. It wo
1 Gettin g StartedFor more information, see “Simulink Accelerator” in the Simulinkdocumentation.Strategies for Real-Time Video ProcessingVideo process
Key Blockset Con ceptsOptimizing Your ImplementationOptimizing your implementation is a crucial step toward real-time videoprocessing. The following t
1 Gettin g StartedDeveloping Your ModelsUse the following g eneral process guidelines to develop real-time videoprocessing models to run on embedded t
Key Blockset Con ceptsFor more information about Real-Time Workshop optimization parameters,see “Generated Source Files and File Dependencies” in the
1 Gettin g StartedBlock Data Type SupportThe following table shows what data types are accepted on the main inputdata port of each Video and Image Pro
Block Data Type SupportBlock Double Single BooleanBaseIntegerFixed-Point2-D Variancexx s,us,uAutothresholdxx s,us,uBlob Analysisx (Output) x (Output)
1 Gettin g StartedBlock Double Single BooleanBaseIntegerFixed-PointFind Local Maximaxx s,us,uFrame Rate Displayxxxs,us,uFrom Multimedia File This is a
Block Data Type SupportBlock Double Single BooleanBaseIntegerFixed-PointProjectiveTransformationxxxs,us,uPSNRxx s,us,uRead Binary Files, uResizexx s,u
1 Gettin g StartedImage CreditsThis table lists the copyright owners of the images used in the Video andImage Processing Block set docume ntation.Imag
2Importing and ExportingVideoIn this chapter, you learn how to bring video data i nto a model, display it onyour monitor, and export it to an AVI or m
2 Importing and Exporting VideoWorking with AVI FilesVideoandImageProcessingBlocksetenables you to work with video datawithin the Simulink environment
Working with AVI Files2 Locate an AVI file that you want to import into Simulink. If you do nothave access to an AVI file, Video and Im age Processing
2 Importing and Exporting Video6 Set the configuration parameters. Open the Configuration dialog box byselecting Simulation > Configuration Paramet
Working with AVI FilesNote Thevideo that is d isplayed in the Video Viewer w indow runs as fastas Simulink processes the video frames. If you are on a
2 Importing and Exporting Videoaudio associated with an AVI f il e, use the To Wave Device b lock in SignalProcessing Blockset.Note The Video Viewer b
Working with AVI FilesBlock Library QuantityWrite AVI File Video and Image ProcessingBlockset > Sinks1Gain Simulink > Math Operation s23 Connect
2 Importing and Exporting Video5 UsetheGain1blocktochangethebluevaluesofthevideostream.Settheblock parameters as follows:• Main pane, Gain =1.5• Signa
Working with AVI FilesYou have now manipulated your video stream and exported it from a Simulinkmodel to an AVI fi le. For more information, see the W
ContentsGetting Started1What Is Video andImage Processing Blockset?...1-2Installation... 1-3Installing Videoan
2 Importing and Exporting VideoBlock Library QuantityFrom Mu lti m edia File Video and Image ProcessingBlockset > Sources1Insert TextVideoandImageP
Working with AVI Files5 Click-and-drag the Frame Counter block from the demo model into yourmodel. This block counts the number of frames in an input
2 Importing and Exporting Video9 Set the configuration parameters. Open the Configuration dialog box byselecting Configuration Parameters from the Sim
Working with AVI FilesThe annotated video appears i n the Video Viewer1 window.You have now added descriptive text to a video stream. For more informa
2 Importing and Exporting VideoBlock Library QuantityFrom Mu lti m edia File Video and Image ProcessingBlockset > Sources1Insert TextVideoandImageP
Working with AVI FilesBy setting the Text parameter to 'Text posit ion: Row %d and Column%d', you are asking the block to replace each conv
2 Importing and Exporting Video8 Set the configuration parameters. Open the Configuration dialog box byselecting Configuration Parameters from the Sim
Working with AVI FilesAlternatively, you can input two string values at the Variables port.10 On the Insert Text block dialo g box, set the Text param
2 Importing and Exporting VideoYou have now added descriptive text to a video stream. For more information,see the Insert Text block reference page in
Working with AVI Files3 Use the From Multimedia File block to import a n AVI file into your model.Accept the default parameters.4 UsetheInsertTextbloc
Importing and Exporting Video2Working w ith AVI Files ... 2-2Importing a nd Viewing AV I Files... 2-2Expor
2 Importing and Exporting Video5 Double-click each Enabled Subsystem block, and click-and-drag one of theTo Multimedia File blocks into i t.6 Inside e
Working with AVI Files8 Use the Counter block to count the number of video frames. You use thisinformation to specify which frames are sent to wh ich
2 Importing and Exporting Video10 Use the Compare to Constant1 and Compare to Constant2 blocks to sendframes 10 to 19 to the s econd AVI file. Set the
Working with AVI Files14 Set the configuration parameters. Open the Configuration dialog box byselecting Simulation > Configuration Parameters. Set
2 Importing and Exporting Video16 View the resulting files by typing the following commands at the MATLABcommand prom pt:mplay output1.avimplay output
Working with Multimedia FilesWorkingwithMultimediaFilesIf you are working on a Windows platform, Video and Image ProcessingBlockset contains blocks th
2 Importing and Exporting Video2 Locate a m ultime dia file that you want to import in to Simulink. If you donot have access to a multimedia file, Vid
Working with Multimedia Files• Stop time = 20• Type = Fi xed- step• Solver = discre te (no continuous states)7 Run your model.View your video in the T
2 Importing and Exporting Video1 If the model you created in “Importing and Viewing Multimedia Files” onpage 2-25 is not open on your desktop, you can
Working with Multimedia Files4 Use the To Multimedia File block to export the video to a multime dia file.Set the block parameters as follows:• Output
Chroma Resampling ... 4-19Geometric Transformation5Interpolation Overview ... 5-2Nearest Neighbor
2 Importing and Exporting VideoYou are now ready to set your block parameters by double-clicking theblocks, modifying the blo ck parameter values, and
Working with Multimedia FilesYou have now manipulated y our video stream and exported it from a Simulinkmodel to a multimedia file. For more informati
2 Importing and Exporting Video3 Use the From Multimedia Fil e block to im port a multimedi a file into themodel. Accept the following default paramet
Working with Multimedia FilesThe From Multimedia File block inherits its sample time from vipmen.avi.Forvideosignals,thesampletimeisequivalenttothefra
2 Importing and Exporting VideoTheframeperiodoftheaudiosignalmustmatchtheframeperiodofthevideo signals, which is 0.0333 seconds per frame. Since the f
Working with Multimedia Files6 Set the configuration parameters. Open the Configuration dialog box byselecting Simulation > Configuration Parameter
2 Importing and Exporting Video2-36
3Working with MPlayThe MPlay GU I ena bles you to view videos that are repres ented as variablesin the MATLAB workspace. You can also use it to view v
3 Working with MPlayViewing Videos from the MATLAB WorkspaceThe MPlay GU I ena bles you to view videos that are repres ented as variablesin the MATLAB
Viewing Videos from the MATLAB WorkspaceNote The MPlay GUI supports M ATLAB variables that are in themovie structure array format. It also suppo rts t
Image Enhancem en t ... 7-27Sharpening and Blurring an Image... 7-27Removing Salt and Pepper Noise from Im
3 Working with MPlay5 Experiment with using the MPlay GUI to play and interact with the videosequence. By default, the GUI assumes that the video data
Viewing Videos from the MATLAB WorkspaceFor more informatio n about the MPlay GUI, see the mplay function referencepage in the Video and Image Process
3 Working with MPlayViewing Video FilesThe MPlay GUI enables you to view videos from files without having to loadall the video d ata into m emory at o
Viewing Video Files3 Experiment with the MPlay GUI by using it to play and interact with thevideo stream.For more informatio n about the MPlay GUI, se
3 Working with MPlayViewing Vide o Signals in SimulinkThe MPlay GUI enables you to view video signals in S imulink models withoutadding blocks to your
Viewing Video Signals in SimulinkAlso, some new buttons appear above the video w indow.6 Change to floating-scope mode by clicking the button.7 Experi
3 Working with MPlay3-10
4ConversionsIn this chapter, you learn how to convert an intensity image to a binary imageandanRGBimagetoanintensityimage.Youalsolearnhowtodownsamplet
4 ConversionsIntensitytoBinaryConversionBinary images contain Boolean pixel values that are either 0 or 1. Pixelswith the value 0 are displayed as bla
Intensity to Binary Conversion3 Create a new Simulink model, and add to it the blocks shown in thefollowing table.Block Library QuantityImage FromWork
1Getting StartedVideo and Image Processing Blockset is a tool for processing images andvideo in the Simulink® environment. This chapter provides an in
4 Conversions5 Use the Image from Workspace block to import your image from theMATLAB workspace. Set the Value parameter toI6 Use the Video Viewer1 bl
Intensity to Binary Conversion9 Use the Video Viewer b lock to view the binary ima ge. Accept the defaultparameters.10 Connect theblocks as shown in t
4 Conversions11 Set the configuration parameters. Open the Configuration dialog box byselecting Configuration Parameters from the Simulation menu. Set
Intensity to Binary ConversionNote A single threshold value was unable to effectively threshold thisimage due to its uneven lighting. For information
4 Conversions1 If the model you created in “Thresholding Intensity Images UsingRelational Ope rato rs” on page 4-2 is n ot open on your desktop, you c
Intensity to Binary Conversion5 Connect the blocks as shown in the following figure.6 Use the Autothreshold block to perform a thresholding operation
4 ConversionsThe block outputs the calculated threshold value at the Th port.7 From the Signal Processing Blockset library, and then from the SignalPr
Intensity to Binary Conversion8 Double-clicktheImageFromWorkspaceblock.OntheData Types pane,set the Output data type param eter todouble.9 If you have
4 ConversionsThe binary image appears in the Video Viewer window.In the model window, the Display block shows the thres ho ld value,calculated by the
Intensity to Binary ConversionYou have used the Autothreshold block to convert an intensity image to abinary image. For more information about this bl
Comments to this Manuals