<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/170938</link>
    <title>MATLAB Central Newsreader - Image Invariant Moment</title>
    <description>Feed for thread: Image Invariant Moment</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sat, 14 Jun 2008 14:15:04 -0400</pubDate>
      <title>Image Invariant Moment</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/170938#437425</link>
      <author>Nan W.</author>
      <description>Dear all,&lt;br&gt;
&lt;br&gt;
I tried to implement the image invariant moment but it &lt;br&gt;
seems like it doesn't work well. Would you please check &lt;br&gt;
the code for me? The goal is just to find the second &lt;br&gt;
moment of the image though but since it doesn't work I &lt;br&gt;
also try the 3rd and 4th and still doesn't work out.&lt;br&gt;
&lt;br&gt;
Noted thanks for the guideline code from Yuan-Liang Tang.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
function [m2 m3 m4]=findmoment(im)&lt;br&gt;
&lt;br&gt;
%im=im/max(max(im));&lt;br&gt;
cx = immoment(im, 1, 0);&lt;br&gt;
cy = immoment(im, 0, 1);&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
u20= immoment(im,2,0,cx,cy);&lt;br&gt;
u02= immoment(im,0,2,cx,cy);&lt;br&gt;
u11= immoment(im,1,1,cx,cy);&lt;br&gt;
&lt;br&gt;
u30= immoment(im,3,0,cx,cy);&lt;br&gt;
u03= immoment(im,0,3,cx,cy);&lt;br&gt;
u12= immoment(im,1,2,cx,cy);&lt;br&gt;
u21= immoment(im,2,1,cx,cy);&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
m2=sqrt((u20-u02).^2+4*u11.^2);&lt;br&gt;
&lt;br&gt;
m3=(u30-3*u12).^2 + (3*u21-u03).^2;&lt;br&gt;
&lt;br&gt;
m4=(u30+u12).^2 + (u21+u02).^2;&lt;br&gt;
&lt;br&gt;
function m = immoment(im, p, q, cx, cy)&lt;br&gt;
% Compute image moment&lt;br&gt;
[y x v] = find(im);&lt;br&gt;
if nargin == 5&lt;br&gt;
&amp;nbsp;&amp;nbsp;x = x - cx;&lt;br&gt;
&amp;nbsp;&amp;nbsp;y = y - cy;&lt;br&gt;
&amp;nbsp;&amp;nbsp;m = sum(x.^p .* y.^q .* v)/sum(v).^((p+q)/2+1);&lt;br&gt;
end&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;m = sum(x.^p .* y.^q .* v)/sum(v);&lt;br&gt;
return&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
**** Thank you ****</description>
    </item>
    <item>
      <pubDate>Sat, 14 Jun 2008 14:18:01 -0400</pubDate>
      <title>Re: Image Invariant Moment</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/170938#437426</link>
      <author>Nan W.</author>
      <description>&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; m2=sqrt((u20-u02).^2+4*u11.^2);&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
is actually&lt;br&gt;
&lt;br&gt;
&amp;gt; m2=((u20-u02).^2+4*u11.^2);&lt;br&gt;
&lt;br&gt;
sorry I was trying various of versions though.&lt;br&gt;
&lt;br&gt;
Please help I really stucked!&lt;br&gt;
Thank you so much</description>
    </item>
    <item>
      <pubDate>Sat, 14 Jun 2008 14:29:14 -0400</pubDate>
      <title>Re: Image Invariant Moment</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/170938#437430</link>
      <author>ImageAnalyst</author>
      <description>On Jun 14, 10:18=A0am, &quot;Nan W.&quot; &amp;lt;iiuu_c...@yahoo.co.jp&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; m2=3Dsqrt((u20-u02).^2+4*u11.^2);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; is actually&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; m2=3D((u20-u02).^2+4*u11.^2);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; sorry I was trying various of versions though.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Please help I really stucked!&lt;br&gt;
&amp;gt; Thank you so much&lt;br&gt;
&lt;br&gt;
------------------------------------&lt;br&gt;
NaN:&lt;br&gt;
Is your original image a uint8 (with values of 0-255)?  If so the&lt;br&gt;
squaring and summing operations may exceed its range and it will&lt;br&gt;
either clip or wrap around (I don't know which), or maybe just give an&lt;br&gt;
error or warning or NaN (I'm not sure).  You might need to convert&lt;br&gt;
your image to floating point with single() or double() before&lt;br&gt;
computing the moments.&lt;br&gt;
&lt;br&gt;
You need to detail more what &quot;doesn't work out&quot; actually means.  Does&lt;br&gt;
that mean there is an error message, warnings displayed in the command&lt;br&gt;
window, or the results just don't seem like the correct results?&lt;br&gt;
Regards,&lt;br&gt;
ImageAnalyst</description>
    </item>
    <item>
      <pubDate>Sat, 14 Jun 2008 23:19:02 -0400</pubDate>
      <title>Re: Image Invariant Moment</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/170938#437476</link>
      <author>Nan W.</author>
      <description>I'm sorry for haven't posted the details.&lt;br&gt;
&lt;br&gt;
My test image is in gray-scale and the thing that is&lt;br&gt;
incorrect is the result (value) of the output 'm2 m3 m4'.&lt;br&gt;
&lt;br&gt;
I set up the experiment as &lt;br&gt;
1.Reference image&lt;br&gt;
2.Translated and Rotated image&lt;br&gt;
&lt;br&gt;
Then I cropped a part from Image1 and almost exactly portion&lt;br&gt;
from Image2 with a circular mask to make it safe for some&lt;br&gt;
unwanted details. Then only pixel in those masks are fed&lt;br&gt;
into my above moment invariant code. But the result didn't&lt;br&gt;
give the nearly the same moment value from both. Some are!&lt;br&gt;
but some aren't! So I was wondering whether my code is wrong&lt;br&gt;
or not.&lt;br&gt;
&lt;br&gt;
Please guide me so. Thank you so much.</description>
    </item>
    <item>
      <pubDate>Sun, 15 Jun 2008 01:12:45 -0400</pubDate>
      <title>Re: Image Invariant Moment</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/170938#437481</link>
      <author>ImageAnalyst</author>
      <description>On Jun 14, 10:15=A0am, &quot;Nan W.&quot; &amp;lt;iiuu_c...@yahoo.co.jp&amp;gt; wrote:&lt;br&gt;
&amp;gt; Dear all,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I tried to implement the image invariant moment but it&lt;br&gt;
&amp;gt; seems like it doesn't work well. Would you please check&lt;br&gt;
&amp;gt; the code for me? The goal is just to find the second&lt;br&gt;
&amp;gt; moment of the image though but since it doesn't work I&lt;br&gt;
&amp;gt; also try the 3rd and 4th and still doesn't work out.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Noted thanks for the guideline code from Yuan-Liang Tang.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; function [m2 m3 m4]=3Dfindmoment(im)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; %im=3Dim/max(max(im));&lt;br&gt;
&amp;gt; cx =3D immoment(im, 1, 0);&lt;br&gt;
&amp;gt; cy =3D immoment(im, 0, 1);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; u20=3D immoment(im,2,0,cx,cy);&lt;br&gt;
&amp;gt; u02=3D immoment(im,0,2,cx,cy);&lt;br&gt;
&amp;gt; u11=3D immoment(im,1,1,cx,cy);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; u30=3D immoment(im,3,0,cx,cy);&lt;br&gt;
&amp;gt; u03=3D immoment(im,0,3,cx,cy);&lt;br&gt;
&amp;gt; u12=3D immoment(im,1,2,cx,cy);&lt;br&gt;
&amp;gt; u21=3D immoment(im,2,1,cx,cy);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; m2=3Dsqrt((u20-u02).^2+4*u11.^2);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; m3=3D(u30-3*u12).^2 + (3*u21-u03).^2;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; m4=3D(u30+u12).^2 + (u21+u02).^2;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; function m =3D immoment(im, p, q, cx, cy)&lt;br&gt;
&amp;gt; % Compute image moment&lt;br&gt;
&amp;gt; [y x v] =3D find(im);&lt;br&gt;
&amp;gt; if nargin =3D=3D 5&lt;br&gt;
&amp;gt; =A0 x =3D x - cx;&lt;br&gt;
&amp;gt; =A0 y =3D y - cy;&lt;br&gt;
&amp;gt; =A0 m =3D sum(x.^p .* y.^q .* v)/sum(v).^((p+q)/2+1);&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; =A0 =A0 m =3D sum(x.^p .* y.^q .* v)/sum(v);&lt;br&gt;
&amp;gt; return&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; **** Thank you ****&lt;br&gt;
&lt;br&gt;
---------------------------------------&lt;br&gt;
Well you're passing in 5 arguments so you're getting into the if&lt;br&gt;
statement and assigning m, yet right after that if statement, you're&lt;br&gt;
setting m to some other value, so, in essence, the if statement was&lt;br&gt;
useless.  Is that what you want to do?&lt;br&gt;
Regards,&lt;br&gt;
ImageAnalyst</description>
    </item>
  </channel>
</rss>

