MATLAB Image Processing and Video Blockset

MATLAB Image Processing and Video Blockset.  Machine Vision and Smart Sensor for Intelligent Lab.  University of Klagenfurt.   Email: Alireza.Fasih@un...
Author: Chad Sherman
0 downloads 2 Views 968KB Size
MATLAB Image Processing and Video Blockset.  Machine Vision and Smart Sensor for Intelligent Lab.  University of Klagenfurt.   Email: Alireza.Fasih@uni‐klu.ac.at 

What Is Video and Image Processing Blockset?  Video  and  Image  Processing  Blockset  is  a  tool  used  for  the  rapid  design,  prototyping,  graphical  simulation,  and  efficient  code  generation  of  video  processing algorithms. Video and Image Processing Blockset blocks can import  streaming  video  into  the  Simulink  environment  and  perform  two‐dimensional  filtering,  geometric  and  frequency  transforms,  block  processing,  motion  estimation, edge detection and other signal processing algorithms. You can also  use  the  blockset  in  conjunction  with  Real‐Time  Workshop®  to  automatically  generate  embeddable  C  code  for  real‐time  execution.Video  and  Image  Processing Blockset blocks support floating‐point, integer, and fixed‐point data  types.  To  use  any  data  type  other  than  double‐precision  and  single‐precision  floating point, you must install Simulink Fixed Point.                            1   

Sample 1:  Loading and Displaying an Image  Create a new project on simulink program, open video and image processing  blockset tab, and drag “Image From File” blockset to the page.   

  This blockset can load papers.png file by default. To change parameters value,  you must double click on the component. 

Load New Image 

  If you want to access a RGB layer, in image signal combobox select “Separate  Color Signal” item. 

  After this step, you have three separate RGB signal. 

2   

  Method for displaying an image or video signals is easy as loading image.  Drag  a  “Video  Display”  component  on  the  page.  By  default  Input  signal  in  this  component is multi dimensional signal. It means that you can connect any kind  of  multi  dimensional  signal  to  this  component,  and  system  can  detect  it  automatically.  If  you  need  three  separate  RGB  signal,  go  to  properties  and  change  the  Image  signal  to  Separated  Color  Signal,  similar  process  to  the  previous step.          Next step is wiring these two components. Connects the component same as  below image. And press F5 to see the result.                      3   

Sample 2: Color Conversion using Blockset– RGB to Gray Level  For converting RGB Color space to Gray level scale, we need a color conversion  component. By this component we can convert the color information between  9 different color spaces. Such as RGB, HSV, Intensity, etc.   

                 Result: Gray Scale Image    Sample 3: Implementing RGB to Gray Scale by basic components  We have a simple equation for color conversion from RGB to gray scale:  (Gray Scale Value) Luminance value = 0.3 R + 0.59 G + 0.11 B  For implementing this equation we need three multipliers and two adders.     

4   

 

 Change the parameters:   Output data type in all component must change to (uchar 8)   unsigned char 8bit.   

  Result: Gray Scale Image 

5   

  Sample 4: Embedding Matlab Code in Simulink  An Embedded MATLAB Function block lets you compose a MATLAB function in  Simulink like the following example: 

  This  capability  is  useful  for  coding  algorithms  that  are  better  stated  in  the  textual  language  of  MATLAB  than  in  the  graphical  language  of  Simulink.  This  block  works  with  a  subset  of  the  MATLAB  language  called  the  Embedded  MATLAB  subset,  which  provides  optimizations  for  generating  efficient,  production‐quality C code for embedded applications.  6   

  First  of  all,  drag  and  drop  “Embedded  Matlab  Function”  on  the  page,  and  double click on it. It will open a new Matlab Code Editor. Change the function  content, according to the RGB to Gray Scale equation.   

  After this step, if you close the editor page, the component schematic IO, will  change according to the function input and output parameters.    Double Click on it and  Change the Code 

7   

  Homework‐1:  Design a project in Simulink for loading and displaying an image, after  that  embed  a  Matlab  Code  for  Image  Thresholding.  Only  Display  pixels value smaller than 127 and filter the rest. The scale is between  0 and 255. Assign zero for those pixels value which are greater than  127.  Hint: Don’t forget to change the data type parameters to uchar‐8.   

  Result must be similar to this Image.          Reference:  Matlab Rev. 2007 Help and Mathworks Company Web site.  8   

Suggest Documents