rgb

Python Pil Change GreyScale Tif To RGB

a 夏天 提交于 2019-12-07 07:57:01
问题 I have a greyscale TIF File. I need to convert it to RGB/ read from it in a way I can work with it. img = Image.open(GIF_FILENAME) rgbimg = img.convert('RGB') for i in range(5): print rgbimg.getpixel((i, 0)) The convert.("RGB") will automatically make everything (255,255,255) even though the picture is a really dark mostly black picture. If I just read the greyscale numbers I get numbers from around 1400 to 1900. I need to also save a copy of the picture as a RGB Jpeg. Picture in question:

What's the fastest way to repeatedly fill a window with RGB data from an array?

做~自己de王妃 提交于 2019-12-07 04:24:56
问题 I'm currently writing a simple game. My graphics code runs once per frame (approximately 30 times per second), and writes RGB data to an array with 640 * 480 = 307200 entries. I have created a Win32 window with a client area exactly 640 x 480 pixels in size. What's the fastest way to get my RGB data displayed within the otherwise-empty window? The window will need to be updated every frame, so I need to avoid flickering. Should I use GDI for this? Or is there a faster approach using a

Changing the tint of a bitmap while preserving the overall brightness

一笑奈何 提交于 2019-12-07 04:09:56
问题 I'm trying to write a function that will let me red-shift or blue-shift a bitmap while preserving the overall brightness of the image. Basically, a fully red-shifted bitmap would have the same brightness as the original but be thoroughly red-tinted (i.e. the G and B values would be equal for all pixels). Same for blue-tinting (but with R and G equal). The degree of spectrum shifting needs to vary from 0 to 1. Thanks in advance. 回答1: Here is the effect I was looking for (crappy JPEG, sorry):

Fastest way to compare pixel values between two BufferedImages?

梦想与她 提交于 2019-12-07 03:22:33
问题 I have a BufferedImage of type TYPE_INT_BGR. I need to do a pixel-by-pixel comparison to another BufferedImage to compute the "distance" between the two images. I have something that works, but is slow. I get a pixel from the "reference" image, break it up into RGB bytes with: int pixel = referenceImage.getRGB(col, row); int red = (pixel >> 16) & 0xff; int green = (pixel >> 8) & 0xff; int blue = (pixel) & 0xff; I compare the r/g/b values to the corresponding pixel of the candidate image, and

edit rgb values in a jpg with python

不打扰是莪最后的温柔 提交于 2019-12-07 02:30:21
问题 I am trying to change the RGB values in a photo with the Python Imaging Library. I have been using the function Image.point and it does what I want except I want to be able to implement a different function on the R the G and the B values. Anyone know how I can do this? Thanks! 回答1: You're better off using numpy in addition to PIL for doing math of the individual bands of an image. As a contrived example that is not meant to look good in any way: import Image import numpy as np im = Image

Color detection at a distance (Swift)

落爺英雄遲暮 提交于 2019-12-06 15:13:41
问题 Can someone point me in the right direction with color detection at a distance? I have used the code below and it grabs RBG values of an image properly if an object or point of interest is less than 10 feet away. When the object is at a distance the code returns the wrong values. I want to take a picture of an object at a distance greater than 10 feet and detect the color of that image. //On the top of your swift extension UIImage { func getPixelColor(pos: CGPoint) -> UIColor { let pixelData

How can i convert an uploaded image of RGB format to CMYK format in .Net?

陌路散爱 提交于 2019-12-06 14:30:33
I have a requirement for converting and saving an image in CMYK format. When i have uploaded an image of RGB format, then i need to convert it to CMYK. Is it possible in .Net? Thanks As others mentioned .NET does not natively support image colorspace adjustments. However, ImageMagick is excellent free software suite that will alow you to do this using the -colorspace or -profile option. The .NET library that will allow you to tap into ImageMagick is conveniently named ImageMagick.NET , it can be downloaded from Codeplex ... I don't know the first thing about .Net but I saw a web site where you

linux C++ XImage RGB <-> BGR?

蓝咒 提交于 2019-12-06 12:40:10
问题 I have a vector containing RGBA (actualy I don't care about the alpha channel) value from a picture, I want to draw this picture with xlib. So I have to use an XImage and to got one I need to use XCreateImage. XCreateImage requires "char *data" so first I need to convert my vector. I don't know if what I'm doing is efficient, but that works : vector<unsigned char> picture; cunsigned char *unsigneddata = &picture[0]; char *data; data = (char*)unsigneddata; so now I can use "data" to draw my

OpenCV for Android: Convert Camera preview from YUV to RGB with Imgproc.cvtColor

我是研究僧i 提交于 2019-12-06 11:27:57
问题 I get a runtime error if I try to convert camera preview YUV byte array to a RGB(A) byte array with Imgproc.cvtColor( mYUV_Mat, mRgba_Mat, Imgproc.COLOR_YUV420sp2RGBA, 4 ) in onPreviewFrame(byte[] data, Camera camera): Preview.java: mCamera.setPreviewCallback(new PreviewCallback() { public void onPreviewFrame(byte[] data, Camera camera) { // Pass YUV data to draw-on-top companion System.arraycopy(data, 0, mDrawOnTop.mYUVData, 0, data.length); mDrawOnTop.invalidate(); } }); DrawOnTop.java:

Java: Operations with Colors (add, subtract)? - Colors in a constant class

泄露秘密 提交于 2019-12-06 10:34:13
问题 I'm working with java.awt.Color instances. Is there any way to do arithmetic operations on colors? Something like rgb(20, 20, 20) + rgb(10, 200, 170) = rgb(30, 220, 190) ? What I'm trying to do: I have a gui that features a table, where if the user clicks on a cell, the other cells change color based on their relationship to the selected one. I'm looking for a way to avoid hard coding what the base colors are, and on which color values they change. So the selected cell might be rgb(255, 0, 0)