Computer Vision News - September 2016

26 Computer Vision News Trick For a full list of return values and their type see here . Note that even though the Python list was returned to Matlab, the operators are still Matlab. For example, you cannot use the ‘-1’ to get the last variable as you normally do in Python, but you need to use the ‘end’ operators as in Matlab. Example in the code snippets below: D. Passing Image (3D matrix) to Python Module We are dealing here with computer vision applications. Thus, it is most likely that we would need to pass an image (3D matrix - RGB image of the size nRow x nCol x 3) to Python and not just a list/string etc. Unfortunately, matrices can’t be passed directly into Python since this option is not supported yet , as of Matlab 2016a. The way of doing so is by converting the image into a 1D matrix, i.e. a vector. For this demonstration we will assume that we have a Python file named ThePythonCode in the current directory with our famous functions: getEdges, getHoughlines and PlotHoughLines . Not famous yet? See the Tool of the month at page 14 for more info . Trick >> whos Name Size Bytes Class my_list 1x4 32 double my_list2 1x8 112 py.list my_list2 defined in section B above. Note that you have to use the ‘{}‘ and not the ‘()‘ for extracting a value from the py.list. For a full list of Python/Matlab operators of other types see here . >> my_list2 (1) ans = Python list with no properties. [1.0] >> my_list2 {1} ans = 1 For example, to access the last variable in the list. >> my_list2 {-1} Error using py.list/subsref Subscript indices must be real, positive integers. >> l1{end} ans = 8

RkJQdWJsaXNoZXIy NTc3NzU=