Steve on Image Processing

September 7th, 2006

Use makehgtform for 3-D rotation

Developer Mike G. read my recent post about three-dimensional image rotation and suggested that users might want to use the MATLAB function makehgtform to construct the affine transform matrix. It has some convenient syntaxes.

As an alternative to the code I posted, Mike says you could do something like this:

  T = makehgtform('translate',blob_center,...
                   'yrotate',pi/8,...
                   'translate',-blob_center);
  T = T';

(The transposition step is necessary to satisfy the convention used in the Image Processing Toolbox functions.)

Thanks, Mike - I didn't know about that one.

7 Responses to “Use makehgtform for 3-D rotation”

  1. Shanika replied on :

    Steve, cool artwork you’ve created there. I got a question but its nothing to do with 3-D stuff. How can I convert RGB values to L*a*b values in MATLAB? I have uploaded a digital image to MATLAB workspace and wanting to get Lab values for each pixel. Please give me an idea…I tried the MATLAB help also. cheers

  2. Steve replied on :

    Shanika - use makecform and applycform in the Image Processing Toolbox. There’s an example in one of my blog postings from June.

  3. Qi Chen replied on :

    hi, Steve

    I have a question that needs your kind help. I have two images/grids with different projections (UTM and Alberts) for the same area. Do you have any ideas on how to convert any image from one projection to another (say, Alberts -> UTM).
    I checked the Mapping Toolbox and Image processing toolbox and haven’t found a solution to this problem. Any of your hints will be highly appreciated!

    Sincerely,
    Qi

  4. Steve replied on :

    Qi Chen - We don’t have a function that performs raster reprojection end-to-end. A knowledgeable person could combine functions such as tformarray or interp2 with Mapping Toolbox functions mfwdtran and minvtran to write a reprojection function. There’s a Mapping Toolbox demo about unprojecting a DEM that shows some of the steps for reprojecting a grid. The demo is called “Un-Projecting a Digital Elevation Model (DEM).”

  5. Qi Chen replied on :

    Steve, thank you very much. I have been reading this demo and thinking in the same direction as you suggested. Another question I have is: if two projections (UTM and Alberts) have different ellipsoids, the geographic coordinates would be different even when they are converted from UTM and Alberts coordinates with minvtran. Is there a function that can convert the geographic coordinates between different ellipsoids?

  6. Rob Comer replied on :

    Qi Chen - You are correct, you can’t use reprojection alone to move data from one reference ellipsoid to another. What you need is a datum conversion. In fact, just knowing two numbers, a latitude and a longitude, doesn’t tell you where something is. You also need to know which datum (reference system) the numbers refer to. We don’t have a Mapping Toolbox function for datum conversion, but there are some free resources that you can find by searching the Internet.

  7. Qi Chen replied on :

    Thanks a lot. Rob.

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Steve Eddins manages the Image & Geospatial development team at The MathWorks and coauthored Digital Image Processing Using MATLAB. He writes here about image processing concepts, algorithm implementations, and MATLAB.

  • Steve: Kezia—Try imrotate.
  • kezia: steve, how to perform rotation of structuring element by 15 degrees. kindly answer my question. thank u kezia...
  • Steve: Tasha—I only accept comments that are relevant to the particular blog post or are questions or comments...
  • Tasha: Steve,I send you a comment here but still didn’t get any reply yet.I did not see my comment posted here...
  • Steve: Carsten—Thanks for your input.
  • Carsten: Another vote for either imtranslate.m, or at least a blurb in the imtransform help why pure translation...
  • Loren Shure: If you look towards the end of the fftfilt program, you will see that there’s a check to see if...
  • Steve: Sonja—My imwritesize submission on the MATLAB Central File Exchange might be helpful. It was posted...
  • Steve: Grant—Sorry, but it won’t be for R2010a. That development deadline has already passed.
  • Sonja: My publisher is wanting images for a new book to be 300 dpi. Only 5 of the 19 images are 300, the rest are...

These postings are the author's and don't necessarily represent the opinions of The MathWorks.