|
-
Jul 11th, 2004, 01:56 PM
#1
Thread Starter
Hyperactive Member
Scanning pixels??
How do i search a picturebox for a certain color in vb.net?
Lets say i got a black image with 50 white pixels, and then i want to count the number of white pixels in the image?
-
Aug 19th, 2004, 05:41 AM
#2
Thread Starter
Hyperactive Member
Pleeease!! Someone, help me...
-
Aug 19th, 2004, 06:35 AM
#3
of the top of my head
VB Code:
Import System.Drawing
Dim b as Bitmap
b = picture1.Image 'might need a cast
'loop x y b.Width-1 b.Height-1
b.getPixel(x,y)
-
Aug 20th, 2004, 12:16 AM
#4
Thread Starter
Hyperactive Member
Thx Deadeyes! So far it works. Now to the point where i want to get the colorvalue of each pixel.
In vb 6 i got the decimal colorvalue from 0 to 1650000 something. I want to use the same in vb.net but i dont know how. In my case i want for example search every pixel that got a colorvalue of 65535 ( thats a yellow color ) and each time i find a pixel with that value i will count that pixel. Did you get that?
-
Aug 20th, 2004, 03:20 AM
#5
GetPixel returns a Color which has a method ToARGB() I think that returns a value that is the same as the long value in VB6.
actuall the A stands for Alpha does VB6 store the Alpha value?
Color also has R G and B properties which return bytes so some messing around could give the value your looking for.
-
Aug 20th, 2004, 03:34 AM
#6
There is a ColorTranslater class which has static methods like:
ToWin32
ToHTML
ToOle
one of them will have to work
-
Aug 20th, 2004, 04:29 AM
#7
Thread Starter
Hyperactive Member
Thx alot. I will try it when im coming home from work.. I will let you know how i solve it.
-
Mar 20th, 2005, 02:28 AM
#8
Lively Member
Re: Scanning pixels??
in .NET u can (as far as my knowledge goes) only getpixel of a bitmap. to do use urbitmap.getpixel (x,y).
-
Mar 20th, 2005, 06:10 AM
#9
Re: Scanning pixels??
 Originally Posted by Libero
How do i search a picturebox for a certain color in vb.net?
Lets say i got a black image with 50 white pixels, and then i want to count the number of white pixels in the image?
Do you need to get a precise number of white pixels, or just an estimate?
An estimate would be an order of magnitude faster, just check every 3rd column and every third row and you can multiply up to get your estimate. Depends of you reasons for counting them.
I don't live here any more.
-
Mar 20th, 2005, 11:15 AM
#10
Lively Member
Re: Scanning pixels??
just make a loop PS my code sucks dont copy it
x=1
y=1
loop until y=50
urbitmap.getpixel(x,y)=z
x=x+1
if x=50 then
y=y+1
x=1
print z
end if
ok this is completely non-functional. if ne1 wants to make soemthing that works out of this its fine by me. its just to give u an idea
-
Mar 21st, 2005, 05:21 AM
#11
Re: Scanning pixels??
VB Code:
Dim x,y, whiteCount as integer
for y = 0 to pic.height - 1
for x = 0 to pic.width - 1
if pic.getpixel(x,y) = color.white then whiteCount += 1
next x
next y
I don't live here any more.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|