473,545 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.g etRGB(x,y) ..

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

thanx
dn

Oct 16 '07 #1
2 21724
On Tue, 16 Oct 2007 07:05:56 +0000, de****@gmail.co m 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.g etRGB(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
2345
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 erase) Picture1 Picture2.Picture = MyPicture
1
5575
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. bright white pixel would return 0,0,0 with the function below: The color (234,123,255) returns (234,123,0). I would have thought that the byte...
6
1513
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 overflow if the function runs recursive more than 5495 times. Does anyone know a solution on the problem eg. how to extend the stack size on Windows...
7
9760
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 vb.net??? thanx for helping..
0
1075
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
1503
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. I've tried using a Collide function, however this means I would need to use several labels as the boundaries. This also means the two objects must...
6
7242
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 need Bitmap.GetPixel() to always return pure RGB values -- ones that always have an alpha value of 255. This is because I need to reproduce the graphic...
4
2784
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 me explain what am I trying to do... I want to periodically check if someone is watching "movie" in his favorite video player. I have tested a...
1
1275
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) agl1 = GetPixel(ldc, 230, 534) Red1 = agl1 Mod 256 Green1 = (agl1 \ 256) Mod 256
0
7473
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7406
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7660
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7431
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7761
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5337
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4949
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
709
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.