Hello All,<br> 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'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> <br> # find the pixels that are different in two images<br> diff = ImageChops.difference(file1,file2)<br> #shows the resultant image<br>
diff.show()<br> #convert the different pixels into grayscale so that they are counted once for each pixel<br> diff = ImageOps.grayscale(diff)<br><br> # read the ascii file<br> hdr = read_ascii.header(inFile)<br>
temp= hdr[4].strip().split() # temp is a list which is ['cellsize', '127']<br> cellsize = temp[1]<br><br> def clip(x):<br> if x>=1:<br> return 1<br> else:<br> return 0<br>
# apply the clipping function to eval<br> diff = Image.eval(diff,clip)<br><br> <br> #return the resultant area<br> val = ImageStat.Stat(diff).sum<br> area = val * cellsize<br> print "area is ",area<br>
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 <<a href="mailto:kent37@tds.net">kent37@tds.net</a>> 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>
> Yeahh so by doing this i am counting only the difference part since we<br>
> have grayscaled the image and assuming it will count only the pixels<br>
> that evolve as difference....<br>
<br>
</div>Yes<br>
<div class="Ih2E3d"><br>
> if i use sum2 instead of sum i think it<br>
> will give squared sum which is area... and if i just use count it would<br>
> count the number of pixels developed like that... sounds interesting ..<br>
> 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'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