 |
smm Level: Trainee
 Registered: 29-07-2005 Posts: 2
|
Graphics
I have loaded graphic in picturebox and extracted the nos. of pixels throgh the GetPixel API. However, the sum of individual pixel value do not match the total pixel value.
e.g. The total pixel count for a Black & White Picture say is z. Suppose, x & y are pixel counts for VBBlack and VBWhite respectively. x & Y do not add upto z. x+y<>z.
Pls. throw some light.
|
|
29-07-2005 at 09:51 AM |
|
|
Asim-GDI GURU Level: Sage
 Registered: 29-07-2005 Posts: 54
|
Re: Graphics
Can you please describe a little clearly what you wanna do actually.Its something very hard to understand what you wanna say...
Regards,
ASim siddiqui.
|
|
29-07-2005 at 03:08 PM |
|
|
smm Level: Trainee
 Registered: 29-07-2005 Posts: 2
|
Re: Graphics
Actually I want to make microstructure analyaer. As a first step I loaded the micrograph (consisting entirely of black and white components) in the pictire box. Through the GetPixel API I found out the total pixelcount as well as the black pixel as well as the white pixels.
dim scanx, scany, pixcount as long
dim pixb,pixw as long
for scanx=0 to picture1.scalewidth-1
for scany=0 to picture1.scaleheight-1
pixcount=pixcount+1
if (getpixel(picture1.hdc,scanx,scany)=vbblack) then
pixb=pixb+1
end if
if (getpixel(picture1.hdc,scanx,scany)=vbwhite) then
pixw=pixw+1
end if
next scany
next scanx
since the micrograph fitted exactly in the picbox,
pixcount should be equal to pixb+pixw
pixcount=pixb+pixw
But actually it is not so. Why? Kindly throw some light.
|
|
30-07-2005 at 06:06 PM |
|
|
Asim-GDI GURU Level: Sage
 Registered: 29-07-2005 Posts: 54
|
Re: Graphics
Hi there,
Change this code a little bit.Use the following one:
dim scanx, scany, pixcount as long
dim pixb,pixw as long
pixcount=picture1.scalewidth*picture1.scaleheight
for scanx=0 to picture1.scalewidth
for scany=0 to picture1.scaleheight
if GetPixel(picture1.hdc,scanx,scany) then
pixw=pixw+1
end if
next scany
next scanx
pixb = pixcount-pixw
Regards,
Asim Siddiqui...
|
|
30-07-2005 at 07:59 PM |
|
|
|
|
 |
 |