473,289 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

PIL and getpixel()

i am trying to get the pixel data using im.getpixel()
i am getting a tuple like (152,118,106) for a pixel in a RGB jpeg
image .
what i really want is an integer value representing a pixel ,like waht
i can get from java's BufferedImage.getRGB(x,y) ..

i am wondering if someone can advise me on how i can do this

thanx
dn

Oct 16 '07 #1
2 21705
On Tue, 16 Oct 2007 07:05:56 +0000, de****@gmail.com wrote:
i am trying to get the pixel data using im.getpixel()
i am getting a tuple like (152,118,106) for a pixel in a RGB jpeg
image .
what i really want is an integer value representing a pixel ,like waht
i can get from java's BufferedImage.getRGB(x,y) ..

i am wondering if someone can advise me on how i can do this
Just pack the RGB values into an `int` by shifting and or-ing. Untested:

red, green, blue = img.getpixel(x, y)
pixel_as_int = red << 16 | green << 8 | blue

Ciao,
Marc 'BlackJack' Rintsch
Oct 16 '07 #2
Just pack the RGB values into an `int` by shifting and or-ing. Untested:

red, green, blue = img.getpixel(x, y)
pixel_as_int = red << 16 | green << 8 | blue

Ciao,
Marc 'BlackJack' Rintsch
thanx Marc

will try that
dn

Oct 16 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: C. Alexander | last post by:
Hey all. I have a whiteboard type program. I have 2 picturebox's (needed for their mousemove/mousedown events) Picture1.Picture = MyPicture ' Here is my hidden picture used to replace (on...
1
by: Morten Nielsen | last post by:
Does anyone have any idea why I can't get a pixel-value of 255 returned in the code below? Any color-value from 0 up to 254 is returned correctly, but any color-component of 255 returns zero. ie....
6
by: Martin Holmgaard | last post by:
I have written the following function to be used for flood filling in a bitmap. The function works fine on Windows XP Prof and Windows 2000 server, but on Windows 2003 server it return a stack...
7
by: Serdar C. | last post by:
ok i searched the internet for this api and i found the usage of getpixel api like this: getpixel(example.hdc,x,y) but i cant find any property about this "hdc".. that does that hdc 's equal in...
0
by: OHM \( One Handed Man \) | last post by:
I would like to find the colour of a specific pixel in a AxWebBrowser, can anybody offer any code for this? Son of OHM. -- ( OHM ) - One Handed Man AKA Terry Burns - http://TrainingOn.net
0
MetalMartian
by: MetalMartian | last post by:
I'm trying to write code for a game based on the original Pacman in Visual Basic .NET 2003, however I can't figure out how to make the character move around the screen and not go through the walls....
6
by: herzog | last post by:
Hi, I am using C# to a draw a graphic on a memory bitmap. I then extract the color information of every pixel of the bitmap. I do this with Bitmap.GetPixel(). The trouble I'm having is that I...
4
by: demc | last post by:
Hi there guys! Today I've spent all evening googling, msdning, codeprojecting and thescripting about problem when trying to get color of pixel somewhere in bounds of a video player form. So let...
1
by: aniketpatil | last post by:
I am trying to extract RGB value of a particular pixel on the SCREEN (NOT picture box or etc)and compare it with given color so far this is a sample code- Dim ldc As Long ldc = GetWindowDC(0) ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.