[Tutor] [tutor] Finding image statistics
varsha.purohit at gmail.com
Mon Mar 10 01:53:37 CET 2008
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.
this is my code.
# find the pixels that are different in two images
diff = ImageChops.difference(file1,file2)
#shows the resultant image
#convert the different pixels into grayscale so that they are counted
once for each pixel
diff = ImageOps.grayscale(diff)
# read the ascii file
hdr = read_ascii.header(inFile)
temp= hdr.strip().split() # temp is a list which is ['cellsize',
cellsize = temp
# apply the clipping function to eval
diff = Image.eval(diff,clip)
#return the resultant area
val = ImageStat.Stat(diff).sum
area = val * cellsize
print "area is ",area
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....
i tried to multiply cellsize with 1 in the clip function where i am writing
but even it is not working .... can anyone tell me what i am doing wrong
On Mon, Mar 3, 2008 at 12:55 PM, Kent Johnson <kent37 at tds.net> wrote:
> Varsha Purohit wrote:
> > Yeahh so by doing this i am counting only the difference part since we
> > have grayscaled the image and assuming it will count only the pixels
> > that evolve as difference....
> > if i use sum2 instead of sum i think it
> > will give squared sum which is area... and if i just use count it would
> > count the number of pixels developed like that... sounds interesting ..
> > thanks for throwing light for me in right direction....
> No. First, pixels are already a measure of area. Second, if each pixel
> value is 0 or 1, squaring the values won't make any difference.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor