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.

  • Sana: hi steve, could you explain to me how i would be able to use the dir function, to do a loop through a directory...
  • Nishtha: Sir, I have preprocessed the image in following steps: [1] adaptive histogram equalization [2] thresholding...
  • Kristof: I also strongly support the idea. I have just recently bumped into the problem that im2single was not...
  • Steve: David—I’ m glad you found it useful!
  • David Lalejini: I found your example very useful for finding connected nodes in a large set of input pairs. I start...
  • tommy: Dear Steve, I have a question,please if you are kind to help me regarding the accumulator array dimensions of...
  • Steve: Abc—I don’t know how to distinguish the faces. You might try posting your question in the MATLAB...
  • Manju: well if we have a few ovals within each other like in a cell how do we measure the distance from the center...
  • Steve: Manju—What do you mean? How is each region defined?
  • Manju: if we have 2-3 regions within each other how do we measure the regions of each one?

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