{"id":111,"date":"2007-10-16T14:17:19","date_gmt":"2007-10-16T19:17:19","guid":{"rendered":"https:\/\/blogs.mathworks.com\/loren\/2007\/10\/16\/tire-rotation\/"},"modified":"2016-08-03T14:49:29","modified_gmt":"2016-08-03T19:49:29","slug":"tire-rotation","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/loren\/2007\/10\/16\/tire-rotation\/","title":{"rendered":"Tire Rotation"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction>\r\n      <p>If only rotating tires were really this easy!  After graduate school, I drove east for my post-doc at <a href=\"http:\/\/www.whoi.edu\/\">Woods Hole Oceanographic Institution<\/a>. 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\r\n         and later realized that my tire wasn't oriented for easily reading the make of the car.\r\n      <\/p>\r\n   <\/introduction>\r\n   <h3>Contents<\/h3>\r\n   <div>\r\n      <ul>\r\n         <li><a href=\"#1\">Some Simple Image Processing<\/a><\/li>\r\n         <li><a href=\"#2\">Read an Image<\/a><\/li>\r\n         <li><a href=\"#3\">Crop the Image<\/a><\/li>\r\n         <li><a href=\"#4\">Resize the Image<\/a><\/li>\r\n         <li><a href=\"#5\">Rotate the Image<\/a><\/li>\r\n         <li><a href=\"#6\">Check the Tire Rotation<\/a><\/li>\r\n         <li><a href=\"#7\">Quick Ideas?<\/a><\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <h3>Some Simple Image Processing<a name=\"1\"><\/a><\/h3>\r\n   <p>Today I am going to use some features from <a href=\"https:\/\/www.mathworks.com\/products\/image\/\">Image Processing Toolbox<\/a>.  You might also benefit from reading <a href=\"https:\/\/blogs.mathworks.com\/steve\">Steve's blog<\/a> on image processing.\r\n   <\/p>\r\n   <h3>Read an Image<a name=\"2\"><\/a><\/h3>\r\n   <p>Here's a gray-scale image of my tire photo.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">I = imread(<span style=\"color: #A020F0\">'tire.tif'<\/span>);\r\nwhos <span style=\"color: #A020F0\">I<\/span>\r\ncolormap(gray(256))\r\nimage(I), axis <span style=\"color: #A020F0\">image<\/span>, axis <span style=\"color: #A020F0\">off<\/span><\/pre><pre style=\"font-style:oblique\">  Name        Size             Bytes  Class    Attributes\r\n\r\n  I         205x232            47560  uint8              \r\n\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/111\/tireRotation_01.png\"> <h3>Crop the Image<a name=\"3\"><\/a><\/h3>\r\n   <p>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\r\n      used <tt>imcrop<\/tt> interactively earlier to isolate the central portion.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">rect = [90 74 41 41]\r\nmidI = imcrop(I,rect);\r\nimage(midI), axis <span style=\"color: #A020F0\">image<\/span>, axis <span style=\"color: #A020F0\">off<\/span><\/pre><pre style=\"font-style:oblique\">rect =\r\n    90    74    41    41\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/111\/tireRotation_02.png\"> <h3>Resize the Image<a name=\"4\"><\/a><\/h3>\r\n   <p>Next, I want to resize the image so I can see details better.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">midI5 = imresize(midI,5);\r\nimshow(midI5)<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/111\/tireRotation_03.png\"> <h3>Rotate the Image<a name=\"5\"><\/a><\/h3>\r\n   <p>Looking at the function <tt>imrotate<\/tt>, I see I specify the rotation I want in a counterclockwise sense. Eyeballing the angle, I choose 135 degrees.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">midI5r = imrotate(midI5, 135);\r\nimshow(midI5r)<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/111\/tireRotation_04.png\"> <h3>Check the Tire Rotation<a name=\"6\"><\/a><\/h3>\r\n   <p>Here's the rotated tire.  Now you know what kind of car I drove across the country some years ago.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">Ir = imrotate(I,135);\r\nimshow(Ir)<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/111\/tireRotation_05.png\"> <h3>Quick Ideas?<a name=\"7\"><\/a><\/h3>\r\n   <p>Like today's blog, I occasionally enjoy trying out products in addition to MATLAB, in part so I can learn more about a particular\r\n      domain or discipline.  Have you used MATLAB or other MathWorks tools to teach yourself about some new technology or application?\r\n       If so, please let me know <a href=\"https:\/\/blogs.mathworks.com\/loren\/?p=111#respond\">here<\/a>.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_f9e29f5158cc461080c80d1ae0bc01ea() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='f9e29f5158cc461080c80d1ae0bc01ea ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' f9e29f5158cc461080c80d1ae0bc01ea';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Loren Shure';\r\n        copyright = 'Copyright 2007 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_f9e29f5158cc461080c80d1ae0bc01ea()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; 7.5<br><\/p>\r\n<\/div>\r\n<!--\r\nf9e29f5158cc461080c80d1ae0bc01ea ##### SOURCE BEGIN #####\r\n%% Tire Rotation\r\n% If only rotating tires were really this easy!  After graduate school, I\r\n% drove east for my post-doc at <http:\/\/www.whoi.edu\/ Woods Hole Oceanographic Institution>.\r\n% In late winter, I noticed that my tires still had red dust on them from\r\n% visiting national parks in Utah. So I took a picture and later realized\r\n% that my tire wasn't oriented for easily reading the make of the car.\r\n%% Some Simple Image Processing\r\n% Today I am going to use some features from\r\n% <https:\/\/www.mathworks.com\/products\/image\/ Image Processing Toolbox>.  You\r\n% might also benefit from reading <https:\/\/blogs.mathworks.com\/steve Steve's blog>\r\n% on image processing.\r\n%% Read an Image\r\n% Here's a gray-scale image of my tire photo.\r\nI = imread('tire.tif');\r\nwhos I\r\ncolormap(gray(256))\r\nimage(I), axis image, axis off\r\n%% Crop the Image\r\n% Next I want to select the hub to look at it more closely.  I happen to\r\n% know that region I want to look at, having already used\r\n% <https:\/\/www.mathworks.com\/help\/images\/index.htmlimcrop.html |imcrop|>\r\n% interactively earlier to isolate the central portion.\r\nrect = [90 74 41 41]\r\nmidI = imcrop(I,rect);\r\nimage(midI), axis image, axis off\r\n%% Resize the Image\r\n% Next, I want to resize the image so I can see details better.\r\nmidI5 = imresize(midI,5);\r\nimshow(midI5)\r\n%%  Rotate the Image\r\n% Looking at the function\r\n% <https:\/\/www.mathworks.com\/help\/images\/index.htmlimcrop.html |imrotate|>,\r\n% I see I specify the rotation I want in a counterclockwise sense.\r\n% Eyeballing the angle, I choose 135 degrees.\r\nmidI5r = imrotate(midI5, 135);\r\nimshow(midI5r)\r\n%% Check the Tire Rotation\r\n% Here's the rotated tire.  Now you know what kind of car I drove across\r\n% the country some years ago.\r\nIr = imrotate(I,135);\r\nimshow(Ir)\r\n%% Quick Ideas?\r\n% Like today's blog, I occasionally enjoy trying out products in addition\r\n% to MATLAB, in part so I can learn more about a particular domain or\r\n% discipline.  Have you used MATLAB or other MathWorks tools to teach\r\n% yourself about some new technology or application?  If so, please let me\r\n% know <https:\/\/blogs.mathworks.com\/loren\/?p=111#respond here>.\r\n\r\n\r\n##### SOURCE END ##### f9e29f5158cc461080c80d1ae0bc01ea\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   \r\n      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... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/loren\/2007\/10\/16\/tire-rotation\/\">read more >><\/a><\/p>","protected":false},"author":39,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[18],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/111"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/users\/39"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/comments?post=111"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/111\/revisions"}],"predecessor-version":[{"id":1922,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/111\/revisions\/1922"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/media?parent=111"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/categories?post=111"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/tags?post=111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}