Hello All,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I had posted this question in this community. I have a trouble. Actually in my application i need to multiply the resultant value i am getting with a cellsize. I am getting this cellsize by reading an ascii file&#39;s header. But when i am trying to multiply it with the result of imagestat i am getting an error.<br>
<br>this is my code. <br><br>def ImageStatistics(file1,file2,inFile):<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; # find the pixels that are different in two images<br>&nbsp;&nbsp;&nbsp; diff = ImageChops.difference(file1,file2)<br>&nbsp;&nbsp;&nbsp; #shows the resultant image<br>
&nbsp;&nbsp;&nbsp; diff.show()<br>&nbsp;&nbsp;&nbsp; #convert the different pixels into grayscale so that they are counted once for each pixel<br>&nbsp;&nbsp;&nbsp; diff = ImageOps.grayscale(diff)<br><br>&nbsp;# read the ascii file<br>&nbsp;&nbsp;&nbsp; hdr = read_ascii.header(inFile)<br>
&nbsp;&nbsp;&nbsp; temp= hdr[4].strip().split() # temp is a list which is [&#39;cellsize&#39;, &#39;127&#39;]<br>&nbsp;&nbsp;&nbsp; cellsize = temp[1]<br><br>&nbsp;&nbsp;&nbsp; def clip(x):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if x&gt;=1:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 0<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # apply the clipping function to eval<br>&nbsp;&nbsp;&nbsp; diff = Image.eval(diff,clip)<br><br>&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; #return the resultant area<br>&nbsp;&nbsp;&nbsp; val = ImageStat.Stat(diff).sum<br>&nbsp;&nbsp;&nbsp; area = val * cellsize<br>&nbsp;&nbsp;&nbsp; print &quot;area is &quot;,area<br>
&nbsp;&nbsp;&nbsp; return area<br><br>i am getting an error that i cannot combine imagestat with cellsize and i cannot multiply it like that. But in my application i need to multiply cellsize with the value i am getting in the image.eval.... <br>
<br>i tried to multiply cellsize with 1 in the clip function where i am writing<br>return 1*cellsize.<br><br>but even it is not working .... can anyone tell me what i am doing wrong here ???<br><div class="gmail_quote">On Mon, Mar 3, 2008 at 12:55 PM, Kent Johnson &lt;<a href="mailto:kent37@tds.net">kent37@tds.net</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">Varsha Purohit wrote:<br>
&gt; Yeahh so by doing this i am counting only the difference part since we<br>
&gt; have grayscaled the image and assuming it will count only the pixels<br>
&gt; that evolve as difference....<br>
<br>
</div>Yes<br>
<div class="Ih2E3d"><br>
&gt; if i use sum2 instead of sum i think &nbsp;it<br>
&gt; will give squared sum which is area... and if i just use count it would<br>
&gt; count the number of pixels developed like that... sounds interesting ..<br>
&gt; thanks for throwing light for me in right direction....<br>
<br>
</div>No. First, pixels are already a measure of area. Second, if each pixel<br>
value is 0 or 1, squaring the values won&#39;t make any difference.<br>
<font color="#888888"><br>
Kent<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Varsha Purohit,<br>Graduate Student