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.

8 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.

  8. toto replied on :

    thank you about your information and demo location. nice post


MathWorks
Steve Eddins is a software development manager in the MATLAB and image processing areas at MathWorks. Steve coauthored Digital Image Processing Using MATLAB. He writes here about image processing concepts, algorithm implementations, and MATLAB.

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