{"id":377,"date":"2011-07-16T13:21:21","date_gmt":"2011-07-16T17:21:21","guid":{"rendered":"https:\/\/blogs.mathworks.com\/steve\/2011\/07\/16\/jahne-test-pattern\/"},"modified":"2019-10-29T16:45:55","modified_gmt":"2019-10-29T20:45:55","slug":"jahne-test-pattern","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/steve\/2011\/07\/16\/jahne-test-pattern\/","title":{"rendered":"J\u00e4hne test pattern"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <p>Earlier this week I posted a summary of posts from the beginning of this blog, including my <a href=\"https:\/\/blogs.mathworks.com\/steve\/2006\/01\/13\/synthesizing-images-using-simple-equations\/\">January 13, 2006 post<\/a> on generating test images. Today I want to revisit one of the examples from that old post.\r\n   <\/p>\r\n   <p>In my 2006 post I showed this test image, consisting of concentric rings with increasing frequency as you move away from the\r\n      center of the image:\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/19\/image_synthesis_01.png\"> <\/p>\r\n   <p>Since then I have seen this type of image referred to as the J&auml;hne test pattern. This week I decided to go looking for the\r\n      source of this reference, and I found a very similar image described in <i>Practical Handbook on Image Processing for Scientific and Technical Applications<\/i>, by Bernd J&auml;hne, CRC Press, 1997. Here's a scan of Figure 10.23a, page 348, from that book:\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2011\/jahne-fig1023a.jpg\"> <\/p>\r\n   <p>The test image is constructed using equation (10.63):<\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2011\/more_on_synthetic_images_eq56929.png\"> <\/p>\r\n   <p>where <img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2011\/more_on_synthetic_images_eq62297.png\">  is the vector offset from the image center, <img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2011\/more_on_synthetic_images_eq57844.png\">  is therefore the distance from the image center, and <img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2011\/more_on_synthetic_images_eq48843.png\">  is the maximum value of <img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2011\/more_on_synthetic_images_eq57844.png\">  in the image.\r\n   <\/p>\r\n   <p>Today I'm going to ignore the second term (tanh) and just focus on the first term, and I'm going to substitute <img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2011\/more_on_synthetic_images_eq25861.png\">  for <img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2011\/more_on_synthetic_images_eq57844.png\"> . The instantaneous frequency of the sinusoid is given by:\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2011\/more_on_synthetic_images_eq62017.png\"> <\/p>\r\n   <p>The maximum instantaneous frequency, which occurs when <img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2011\/more_on_synthetic_images_eq00423.png\"> , is therefore <img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2011\/more_on_synthetic_images_eq10078.png\"> . For a discrete signal defined on a grid with unit spacing, the maximum representable frequency is <img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2011\/more_on_synthetic_images_eq11731.png\"> , which corresponds to a period of 2 units.\r\n   <\/p>\r\n   <p>OK, let's try it.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">km = pi;\r\n[x,y] = meshgrid(-200:200);\r\nr = hypot(x,y);\r\nrm = max(r(:));\r\n\r\ng = sin( (km * r.^2) \/ (2 * rm) );\r\nimshow(g,[])<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2011\/more_on_synthetic_images_01.jpg\"> <p>I used the autoscaling syntax of <tt>imshow<\/tt> because the values of <tt>g<\/tt> range from -1 to 1. We can scale and shift <tt>g<\/tt> to get it into the range [0,1]. Then we don't need the second input to <tt>imshow<\/tt>, and the image will write out correctly if we use <tt>imwrite<\/tt>.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">g = (g + 1)\/2;\r\nimshow(g)<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2011\/more_on_synthetic_images_02.jpg\"> <p>Just for fun, let's push the maximum instantaneous frequency way past reasonable and look at the resulting aliasing artifacts.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">km = 4*pi;\r\ng = sin( (km * r.^2) \/ (2 * rm) );\r\ng = (g + 1) \/ 2;\r\nimshow(g)<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/steve\/2011\/more_on_synthetic_images_03.jpg\"> <p>I spent really much too long playing with this image yesterday, so I'm going to subject you to one or two more posts about\r\n      it. For one thing, having the instantaneous frequency vary directly with distance from the image means we can explore interesting\r\n      effects using bandpass filters. For another, I want to come back to the tanh term in the equation from J&auml;hne's book. I'm a\r\n      bit puzzled by it.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_0f3b7595673846b68cf94c5ef51bca89() {\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='0f3b7595673846b68cf94c5ef51bca89 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 0f3b7595673846b68cf94c5ef51bca89';\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 = 'Steve Eddins';\r\n        copyright = 'Copyright 2011 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_0f3b7595673846b68cf94c5ef51bca89()\"><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.12<br><\/p>\r\n<\/div>\r\n<!--\r\n0f3b7595673846b68cf94c5ef51bca89 ##### SOURCE BEGIN #####\r\n%%\r\n% Earlier this week I posted a summary of posts from the beginning of this\r\n% blog, including my\r\n% <https:\/\/blogs.mathworks.com\/steve\/2006\/01\/13\/synthesizing-images-using-simple-equations\/\r\n% January 13, 2006 post> on generating test images. Today I want to revisit\r\n% one of the examples from that old post. \r\n%\r\n% In my 2006 post I showed this test image, consisting of concentric rings\r\n% with increasing frequency as you move away from the center of the image:\r\n%\r\n% <<https:\/\/blogs.mathworks.com\/images\/steve\/19\/image_synthesis_01.png>>\r\n%\r\n% Since then I have seen this type of image referred to as the J\u00c3\u00a4hne test\r\n% pattern. This week I decided to go looking for the source of this\r\n% reference, and I found a very similar image described in _Practical\r\n% Handbook on Image Processing for Scientific and Technical Applications_,\r\n% by Bernd J\u00c3\u00a4hne, CRC Press, 1997. Here's a scan of Figure 10.23a, page\r\n% 348, from that book:\r\n%\r\n% <<https:\/\/blogs.mathworks.com\/images\/steve\/2011\/jahne-fig1023a.jpg>>\r\n%\r\n% The test image is constructed using equation (10.63):\r\n% \r\n% $$g({\\bf x}) = g_0 \\sin\\left(\\frac{k_m|{\\bf x}|^2}{2r_m}\\right) \\left[\\frac{1}{2}\r\n% \\tanh\\left(\\frac{r_m-|{\\bf x}|}{w}\\right) + \\frac{1}{2}\\right]$$\r\n% \r\n% where ${\\bf x}$ is the vector offset from the image center, $|{\\bf x}|$\r\n% is therefore the distance from the image center, and $r_m$ is the maximum\r\n% value of $|{\\bf x}|$ in the image.\r\n%\r\n% Today I'm going to ignore the second term (tanh) and just focus on the\r\n% first term, and I'm going to substitute $r$ for $|{\\bf x}|$. The\r\n% instantaneous frequency of the sinusoid is given by:\r\n%\r\n% $$\\frac{d}{dr}\\frac{k_m r^2}{2r_m} = \\frac{k_m r}{r_m}$$\r\n%\r\n% The maximum instantaneous frequency, which occurs when $r=r_m$, is\r\n% therefore $k_m$. For a discrete signal defined on a grid with unit\r\n% spacing, the maximum representable frequency is $\\pi$, which corresponds\r\n% to a period of 2 units.\r\n%\r\n% OK, let's try it.\r\n\r\nkm = pi;\r\n[x,y] = meshgrid(-200:200);\r\nr = hypot(x,y);\r\nrm = max(r(:));\r\n\r\ng = sin( (km * r.^2) \/ (2 * rm) );\r\nimshow(g,[])\r\n\r\n%%\r\n% I used the autoscaling syntax of |imshow| because the values of |g| range\r\n% from -1 to 1. We can scale and shift |g| to get it into the range [0,1].\r\n% Then we don't need the second input to |imshow|, and the image will write\r\n% out correctly if we use |imwrite|.\r\n\r\ng = (g + 1)\/2;\r\nimshow(g)\r\n\r\n%%\r\n% Just for fun, let's push the maximum instantaneous frequency way past\r\n% reasonable and look at the resulting aliasing artifacts.\r\n\r\nkm = 4*pi;\r\ng = sin( (km * r.^2) \/ (2 * rm) );\r\ng = (g + 1) \/ 2;\r\nimshow(g)\r\n\r\n%%\r\n% I spent really much too long playing with this image yesterday, so I'm\r\n% going to subject you to one or two more posts about it. For one thing,\r\n% having the instantaneous frequency vary directly with distance from the\r\n% image means we can explore interesting effects using bandpass filters.\r\n% For another, I want to come back to the tanh term in the equation from\r\n% J\u00c3\u00a4hne's book. I'm a bit puzzled by it.\r\n##### SOURCE END ##### 0f3b7595673846b68cf94c5ef51bca89\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   Earlier this week I posted a summary of posts from the beginning of this blog, including my January 13, 2006 post on generating test images. Today I want to revisit one of the examples from that... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/steve\/2011\/07\/16\/jahne-test-pattern\/\">read more >><\/a><\/p>","protected":false},"author":42,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[334,36,122,30,532,34],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/377"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/comments?post=377"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/377\/revisions"}],"predecessor-version":[{"id":3737,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/377\/revisions\/3737"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/media?parent=377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/categories?post=377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/tags?post=377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}