Geometric transformation using MATLAB Function block

cyberdyne

I tried to apply a geometric transformation to a video using MATLAB Function block in Simulink. I connected a 'From Multimedia File' block to MATLAB Function block ant its output to a 'To Video Display' block. Inside MATLAB Function Block this code:

function outputImage = fcn(inputImage,theta)


coder.extrinsic('affine2d')
coder.extrinsic('imwarp')
outputImage = coder.nullcopy(inputImage);


tform = affine2d([cosd(theta) -sind(theta) 0; sind(theta) cosd(theta) 0; 0 0 1]);

outputImage = imwarp(inputImage,tform);

where angle theta is a constant block of 10. The code above is an example from 'affine2d' function examples. It returns me following error:

Size mismatch for MATLAB expression 'imwarp'. Expected = 120x160x3 Actual = 146x179x3 Block MATLAB Function (#108) While executing: State During Action 

but I don't understand where is the error (why Actual=146x179x3). The input video is a RGB video file ('vipmen.avi') from CV toolbox demos.

EDIT: I solved it: I used Apply Geometric Transformation block for translation and a Rotate block for rotation with:

H = [1 0; 0 1; Ox-X  Oy-Y] %where Ox,Oy are image framework origin coordinates and X,Y are offset coordinates. 

Indeed after translation, the "new" image framework origin is the (X,Y) point and the Rotate block rotates it about (X,Y).

Dima

The Computer Vision System Toolbox includes a block called Apply Geometric Transformation, which will do what you need and save you the trouble of using MATLAB function block.

Edit: The Apply Geometric Transformation block has been deprecated as of R2015b release. Please use the Warp block instead.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

OOP Matlab inheritance issue with Matlab coder (Simulink MATLAB Function block)

From Dev

Using Interpolation in Matlab to return a function

From Dev

Using a Function handle in Matlab

From Dev

Using function "Who" within a function in MATLAB

From Dev

Generating random numbers in Simulink with MATLAB function-block

From Dev

Structure as input for a Matlab function Block

From Dev

Robustly estimate Polynomial geometric transformation with scikit-image and RANSAC

From Dev

Plotting inside Matlab Function Block for real time signals in Simulink

From Dev

Growing snowflakes: optimize geometric transformation

From Dev

Matlab obtain Transformation matrix

From Dev

How to Display wavelet transformation function dwt2 results in matlab

From Dev

Crop borders after image transformation using MATLAB

From Dev

HitMiss transformation in matlab

From Dev

Optimization using lsqnonneg function of MATLAB

From Dev

Using function handle in lsqr MATLAB

From Dev

How can I create multiple inputs for a matlab function block?

From Dev

View class properties while debugging matlab function block in simulink

From Dev

Name of this transformation? Geometric, Affine,

From Dev

Error using impshowpair function in MATLAB

From Dev

compiler for Matlab function block R2011b

From Dev

Embedded MATLAB function : Block Error

From Dev

Generating random numbers in Simulink with MATLAB function-block

From Dev

Growing snowflakes: optimize geometric transformation

From Dev

Compiling error due to variable size Matrix in simulink (matlab function block)

From Dev

Define Initial condition for matlab function blocks as an Initial condition in sfunction block

From Dev

Optimization using lsqnonneg function of MATLAB

From Dev

Geometric mean filter for denoising image in MATLAB

From Dev

How to use syms in Simulink Matlab function block

From Dev

Editing the Code of a "MATLAB Function" Block in Simulink Programmatically

Related Related

  1. 1

    OOP Matlab inheritance issue with Matlab coder (Simulink MATLAB Function block)

  2. 2

    Using Interpolation in Matlab to return a function

  3. 3

    Using a Function handle in Matlab

  4. 4

    Using function "Who" within a function in MATLAB

  5. 5

    Generating random numbers in Simulink with MATLAB function-block

  6. 6

    Structure as input for a Matlab function Block

  7. 7

    Robustly estimate Polynomial geometric transformation with scikit-image and RANSAC

  8. 8

    Plotting inside Matlab Function Block for real time signals in Simulink

  9. 9

    Growing snowflakes: optimize geometric transformation

  10. 10

    Matlab obtain Transformation matrix

  11. 11

    How to Display wavelet transformation function dwt2 results in matlab

  12. 12

    Crop borders after image transformation using MATLAB

  13. 13

    HitMiss transformation in matlab

  14. 14

    Optimization using lsqnonneg function of MATLAB

  15. 15

    Using function handle in lsqr MATLAB

  16. 16

    How can I create multiple inputs for a matlab function block?

  17. 17

    View class properties while debugging matlab function block in simulink

  18. 18

    Name of this transformation? Geometric, Affine,

  19. 19

    Error using impshowpair function in MATLAB

  20. 20

    compiler for Matlab function block R2011b

  21. 21

    Embedded MATLAB function : Block Error

  22. 22

    Generating random numbers in Simulink with MATLAB function-block

  23. 23

    Growing snowflakes: optimize geometric transformation

  24. 24

    Compiling error due to variable size Matrix in simulink (matlab function block)

  25. 25

    Define Initial condition for matlab function blocks as an Initial condition in sfunction block

  26. 26

    Optimization using lsqnonneg function of MATLAB

  27. 27

    Geometric mean filter for denoising image in MATLAB

  28. 28

    How to use syms in Simulink Matlab function block

  29. 29

    Editing the Code of a "MATLAB Function" Block in Simulink Programmatically

HotTag

Archive