Loren on the Art of MATLAB

October 16th, 2007

Tire Rotation

If only rotating tires were really this easy! After graduate school, I drove east for my post-doc at Woods Hole Oceanographic Institution. In late winter, I noticed that my tires still had red dust on them from visiting national parks in Utah. So I took a picture and later realized that my tire wasn't oriented for easily reading the make of the car.

Contents

Some Simple Image Processing

Today I am going to use some features from Image Processing Toolbox. You might also benefit from reading Steve's blog on image processing.

Read an Image

Here's a gray-scale image of my tire photo.

I = imread('tire.tif');
whos I
colormap(gray(256))
image(I), axis image, axis off
  Name        Size             Bytes  Class    Attributes

  I         205x232            47560  uint8              

Crop the Image

Next I want to select the hub to look at it more closely. I happen to know that region I want to look at, having already used imcrop interactively earlier to isolate the central portion.

rect = [90 74 41 41]
midI = imcrop(I,rect);
image(midI), axis image, axis off
rect =
    90    74    41    41

Resize the Image

Next, I want to resize the image so I can see details better.

midI5 = imresize(midI,5);
imshow(midI5)

Rotate the Image

Looking at the function imrotate, I see I specify the rotation I want in a counterclockwise sense. Eyeballing the angle, I choose 135 degrees.

midI5r = imrotate(midI5, 135);
imshow(midI5r)

Check the Tire Rotation

Here's the rotated tire. Now you know what kind of car I drove across the country some years ago.

Ir = imrotate(I,135);
imshow(Ir)

Quick Ideas?

Like today's blog, I occasionally enjoy trying out products in addition to MATLAB, in part so I can learn more about a particular domain or discipline. Have you used MATLAB or other MathWorks tools to teach yourself about some new technology or application? If so, please let me know here.


Get the MATLAB code

Published with MATLAB® 7.5

8 Responses to “Tire Rotation”

  1. Urs (us) Schwarz replied on :

    loren, loren, loren
    why did you not just rotate your photo a bit…
    urs
    ps: :-)

  2. aj replied on :

    can you analyse the tires so it actually look flat?, through matlab?

  3. Jayson replied on :

    Have you tried marketing this to Discount Tire Company? :)

  4. Tim Davis replied on :

    Now guys, this is a serious blog posting. It brings up a very important and topic, and deserves a well-thought-out and sober reply.

    In particular, I would like to understand what the whitish powdery substance is on the ground where the tire is rolling. Scientists here in my home state (Florida) have hypothesized that di-hydrogen-monoxide could, in extreme circumstances, achieve a solid or perhaps crystalline form. Such conditions do not occur in any natural state (of Florida, that is). They also fear that prolonged contact with this hazardous chemical while in its crystalline state could result in irreparable tissue damage, by transferring its crystalline state subcutaneously. Could we avoid the formation of this hazardous crystalline state of di-hydrogen monoxide by increasing the level of carbon dioxide in our Earth’s atmosphere?

    So, what is it, and can MATLAB be used to help analyze it ;-)

  5. Steve Eddins replied on :

    Dihydrogen monoxide is a prevalent, controversial, possibly quite dangerous substance. See dhmo.org for more information.

  6. shree replied on :

    hi
    we are working on the signature recog project.. need some help regarding alignment of text in an image..
    we want signature in horizontal position.. so please help us align those signatures which are at diff degrees with respect to horizontal..
    thanking u in advance…
    please do the needful at the earliest

  7. Loren replied on :

    Shree-

    Please look at demos in the Image Processing Toolbox and contact technical support if you require more help.

    –Loren

  8. shree replied on :

    hi
    thank you very much for the reply..
    can u please help us regarding how to extract features in a signature.. please can u provide the matlab code for the same… we are trying to extract features …but due to lack of time… we are seeking ur help… please help us…
    please do reply

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


Loren Shure works on design of the MATLAB language at The MathWorks. She writes here about once a week on MATLAB programming and related topics.

  • Jun: I totally can not believe it, Loren. You are really helpful. Thank you so much, MATLAB master!
  • Loren: Wow folks- Always lots of interest when there’s a quickie to try out! I will only make 2 general...
  • Loren: Jun- ismember is your friend here: >> [aa,ind] = ismember(Array2,Arra y1) aa = 1 1 1 1 1 1 1 ind = 1 2 1 4 4 3...
  • Dan: I like the first way better than the second way. Combining the arrays into one and running any is nice, although...
  • James Myatt: How about I = (a == 0 | b == 0); a(I) = []; b(I) = [];
  • Tunc: Hello Loren, love your blog because of such inspiring and challenging comments to such ’small’...
  • Pekka Kumpulainen: Here is my tradeoff. I usually want to keep the original variables as they are most probably...
  • Iain: Followup: Of course, to allow NaNs (counting them as non-zero): mask = (a~=0) & (b~=0); The mask says “a...
  • Matt Fig: I would usually go with something like this: y = a&b; x = a(y); y = b(y); But I was surprised to find...
  • kk: c=all([a;b]) a(c) a(b)

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