pixel

Get pixel's RGB using PIL

坚强是说给别人听的谎言 提交于 2019-12-17 03:00:14
问题 Is it possible to get the RGB color of a pixel using PIL? I'm using this code: im = Image.open("image.gif") pix = im.load() print(pix[1,1]) However, it only outputs a number (e.g. 0 or 1 ) and not three numbers (e.g. 60,60,60 for R,G,B). I guess I'm not understanding something about the function. I'd love some explanation. Thanks a lot. 回答1: Yes, this way: im = Image.open('image.gif') rgb_im = im.convert('RGB') r, g, b = rgb_im.getpixel((1, 1)) print(r, g, b) (65, 100, 137) The reason you

How to read the RGB value of a given pixel in Python?

三世轮回 提交于 2019-12-17 01:41:05
问题 If I open an image with open("image.jpg") , how can I get the RGB values of a pixel assuming I have the coordinates of the pixel? Then, how can I do the reverse of this? Starting with a blank graphic, 'write' a pixel with a certain RGB value? I would prefer if I didn't have to download any additional libraries. 回答1: It's probably best to use the Python Image Library to do this which I'm afraid is a separate download. The easiest way to do what you want is via the load() method on the Image

How to Get Pixel Color in Android

对着背影说爱祢 提交于 2019-12-14 03:44:29
问题 I'm using Intent to call and show an image from Gallery, and now I made it enable to get me the coordinates of the image in a TextView using these: final TextView textView = (TextView)findViewById(R.id.textView); final TextView textViewCol = (TextView)findViewById(R.id.textViewColor); targetImage.setOnTouchListener(new ImageView.OnTouchListener(){ @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub int x=0; int y=0; textView.setText("Touch

Algorithm to find the coordinates of a corner in a simple image

孤街醉人 提交于 2019-12-14 02:17:33
问题 I have a bitmap where two large blocks of colors intersect, and I would like to find the intersection of these two blocks. Note that I do not know the actual geometry of the two shapes, because this is all just raw pixel data. Is there any algorithm I could use to do this? 回答1: If you have all the pixel data in memory (which I'd assume you do, but this is a major sticking point) and there are only two distinct colours, all you should need to do is run a horizontal scanline to find the point

Open Images Dataset V4 Train - Valid - Test 解析为 Darknet-YOLO 训练数据 (backpack-handbag-suitcase)

时间秒杀一切 提交于 2019-12-14 00:37:40
Open Images Dataset V4 Train - Valid - Test 解析为 Darknet-YOLO 训练数据 (backpack-handbag-suitcase) 1. Backpack - Handbag - Suitcase # category_id = '/m/01940j' - Backpack - 0 # category_id = '/m/080hkjn' - Handbag - 1 # category_id = '/m/01s55n' - Suitcase - 2 # category_id = '/m/0hf58v5' - Luggage and bags - 3 2. open_images_dataset_v4_parser.py #!/usr/bin/env python3 # -*- coding: utf-8 -*- # Yongqiang Cheng from __future__ import absolute_import from __future__ import division from __future__ import print_function import csv import os import shutil import cv2 # category_id = '/m/01940j' -

Optimization for changing pixels of sprite in Unity3D

放肆的年华 提交于 2019-12-13 20:13:09
问题 Problem : After a month, I'm coming back to the prototype for painting on sprite for my mini game. As you see in this thread I've figured out the solution for painting on sprite and because of big nested loop in the script, the mini game isn't at the good situation (I mean low FPS). So I've tried to use another method instead of Texture2D.SetPixel() then I used Texture2D.SetPixels() but like before the FPS was low. So right now, I don't find any solutions for this problem. Last thing which

OpenGL 使用 PBO 高速复制屏幕图像到内存或者纹理中

我是研究僧i 提交于 2019-12-13 20:05:27
如果你想给游戏做个截图功能,或者想把屏幕图像弄成一个纹理,你就非常需要 PBO 了 通常情况下,你想把屏幕图像的像素数据读到内存需要用 glReadPixels 然后 pixels 参数传进去一块内存地址 这样做是非常非常不好的,因为 glReadPixels 会把屏幕图像的像素数据从显卡的显存复制到内存条,这个过程就非常非常的慢,特别是数据量大的时候 然后如果你要把像素数据再用 glTexImage2D 传到纹理,数据就又要从内存条复制到显存,这个过程也是非常非常慢的,特别是数据量大的时候 那么有没有一种办法,让我们可以通过一个内存指针,直接访问显存的数据呢?当然是有的,那就是 OpenGL 的 Array Buffer 这个东西中文叫做 数组缓冲区 也可以直接省略成 缓冲区 因为它就是 显存里的 一块内存,所以我们下文就叫 缓冲区 吧 你可以用 glMapBuffer 得到它的内存指针,然后就可以为所欲为了,另外,OpenGL 很多用来返回数据的函数,都可以把数据写到缓冲区里,而不是复制到内存条。 就比如说 glReadPixels 原本你是要传一个内存指针进去的,但是有了缓冲区,它就可以把数据复制到缓冲区里而不是复制到内存条 因为,屏幕的像素数据是在显存里的,缓冲区也是在显存里的,所以,显存->复制数据->显存 速度就比 显存->复制数据->内存条 快非常非常的多

How to convert RGB image pixels to L*a*b*?

醉酒当歌 提交于 2019-12-13 15:18:14
问题 Well, I'm working with image processing to identify the color variation of an image and to be able to plot that data in a histogram. For this, I use images of skin spots in the RGB color space. The code below I can get the colors of each pixel and convert to HSV using color.rgb2lab. But as I want to convert to L*a*b*, because it is closer to human vision, in the python library there is no conversion to L*a*b*. With this, through the separated pixels of RGB, how do I transform these pixels

Converting between UIImage (PNG) and RGB8

梦想与她 提交于 2019-12-13 12:43:49
问题 I am using https://github.com/PaulSolt/UIImage-Conversion However, it seems to have a problem on the alpha channel. Problem reconstituting UIImage from RGBA pixel byte data I have simplified the problem so I present it as a tidier question. I download Paul's project, run it. It displays an image in the centre of the screen -- everything so far is correct. But his demo is not testing for Alpha. So I attempt to composite my button image... ... on top. The result is: here is the code -- I have

Creating Image from Pixel Values

蓝咒 提交于 2019-12-13 10:54:12
问题 In java...I have an integer array of RGB pixels, means output of my program is as follows: ' Pixel 1: 255 200 191 231 Pixel 2: 255 237 028 036 Pixel 3: 255 034 177 076 Pixel 4: 255 085 140 066 Pixel 5: 255 200 191 231 Pixel 6: 255 237 028 036 Pixel 7: 255 231 188 167 Pixel 8: 255 237 028 036 Pixel 9: 255 237 028 036 Pixel 10: 255 063 072 204 Pixel 11: 255 226 125 144 Pixel 12: 255 063 072 204 Pixel 13: 255 200 191 231 Pixel 14: 255 062 187 099 Pixel 15: 255 255 127 039 Pixel 16: 255 255 127