Thread Subject: inverse fisheye and perspective transform in simulink

Subject: inverse fisheye and perspective transform in simulink

From: Samuel Dorrell

Date: 29 Jun, 2009 17:40:19

Message: 1 of 3

I'm trying to build a Simulink model to perform a combined inverse fisheye and perspective transform. As an extra step, it would be desirable to use real time workshop (plus the other toolboxes) to generate efficient c-code for a dsp! But first things first...

Can I use simulink blocks (I have the 'image and video' and 'signal processing' blockset) to perform an inverse fisheye transform? How can this be done?

I am using the 'Projective transform block' (with mode 'quadrilateral to rectangle' and inverse mapping method 'Exact Solution' - I understand that this equates to a reverse mapping method) to perform a perspective transform. From the help file it seems like the input pixel coordinates are being calculated new each time (??). Is it possible to specify that a look-up table method should be used, afterall isn't this how the image processing toolbox function 'imtransform' works (I've tried using this these functions with embedded Matlab but simulink does not support them)?

Have I got any hope of using Real time workshop and the TIc6 support package to generate fast code for a TIc64xx dsp? (However, the model will still be useful even if fast code cannot be created.)

Subject: inverse fisheye and perspective transform in simulink

From: witek@mathworks.com

Date: 1 Jul, 2009 13:09:51

Message: 2 of 3

Hi Samuel,

> Can I use simulink blocks (I have the 'image and video' and 'signal processing' blockset)
> to perform an
>inverse fisheye transform? How can this be done?

There is no block for fisheye transform in the video blockset. You'd have to write that transform
yourself.

> Can I use simulink blocks (I have the 'image and video' and 'signal processing' blockset) to
> perform an inverse fisheye transform? How can this be done?

You can although for a block with complexity of a fisheye transform, I'd recommend writing it as
a C or C++ s-function. It is also possible to write it using basic
blocks and/or EML.

> I am using the 'Projective transform block' (with mode 'quadrilateral to rectangle' and inverse
> mapping method 'Exact Solution' - I understand that this equates to a reverse mapping method) to perform a perspective transform. From the help file it seems like the input pixel coordinates are being calculated new each time (??).

That's correct, the mapping is not stored. Storage of the mapping per pixel would require a sizable
amount of memory. If you are planning to go to a DSP, this approach would potentially create an
issue in terms of memory resources. BTW. Have a look at Estimate Geometric Transform and Apply
Geometric Transform blocks. The Apply Geo Tform block takes a transformation matrix instead of
a set of points and it is also suitable for performing projective transformation.

> Is it possible to specify that a look-up table method should be used, afterall isn't this how the
> image processing toolbox function 'imtransform' works (I've tried using this these functions
> with embedded Matlab but simulink does not support them)?

That is how the image processing function works although it's designed for a PC. Besides, every time
you invoke the image processing toolbox function, it also recomputes that mapping so you end up
recomputing it either way. To use the image proc. toolbox functions in EML, you can use the
extrinsics keyword (just google "EML extrinsics"). Using extrinsics implies that you will not
be able to generate code from the functions that you'd use by using the keyword.

> Have I got any hope of using Real time workshop and the TIc6 support package to generate fast
> code for a TIc64xx dsp? (However, the model will still be useful even if fast code cannot be created.)

You do have hope -:). It will not be a trivial task though if you want to achieve high frame rates.

Witek

Subject: inverse fisheye and perspective transform in simulink

From: Samuel Dorrell

Date: 1 Jul, 2009 14:53:01

Message: 3 of 3

Hi Witek, thanks for the response.

> > I am using the 'Projective transform block' (with mode 'quadrilateral to rectangle' and inverse
> > mapping method 'Exact Solution' - I understand that this equates to a reverse mapping method) to perform a perspective transform. From the help file it seems like the input pixel coordinates are being calculated new each time (??).
>
> That's correct, the mapping is not stored. Storage of the mapping per pixel would require a sizable
> amount of memory. If you are planning to go to a DSP, this approach would potentially create an
> issue in terms of memory resources.

Actually this is an algorithm that is already created for a TI DSP and I'm looking at whether I could have created it using Simulink tools. The approach that is taken is to compute the lookup table in advance, and there is some clever memory managent for bringing the relevent bits of the lookup table. (This frees up the DSP for doing other things!). I'm starting to realise that Real time Workshop (like most things) is no magic box and wont be able to do any complex memory management without me doing a lot of work.

I think that, as you suggested, an extrinsic embedded matlab function or a C++ s-function is what is needed and I should perhaps forget about generating code for perspective transforms. There's plenty of other more suitable tasks that Simulink automatic code generation would be more suited to.

>BTW. Have a look at Estimate Geometric Transform and Apply
> Geometric Transform blocks. The Apply Geo Tform block takes a transformation matrix instead of
> a set of points and it is also suitable for performing projective transformation.
>
Thanks, I had a look at this block but couldn't seem to get this working. I generated my tranform matrix using the image processing function 'maketform' with argument 'projective' (and this worked when I used the image processing imtransform function to transform my image) but using this tranform matrix in the 'Apply Geometric Transform block' didn't seem to produce the right transform at all. Is there some difference between the transform matrix used by 'imtransform' and the one used by the 'Geometric Transform block'?

Best Regards
Sam :-)

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
video and image... Samuel Dorrell 1 Jul, 2009 05:33:51
fisheye Samuel Dorrell 29 Jun, 2009 13:44:03
perspective Samuel Dorrell 29 Jun, 2009 13:44:03
video transform Samuel Dorrell 29 Jun, 2009 13:44:03
geometric trans... Samuel Dorrell 29 Jun, 2009 13:44:03
simulink Samuel Dorrell 29 Jun, 2009 13:44:03
realtime workshop Samuel Dorrell 29 Jun, 2009 13:44:03
image transform Samuel Dorrell 29 Jun, 2009 13:44:03
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com