rgb

Build 2D Array of Canvas RGB values

你说的曾经没有我的故事 提交于 2019-12-06 10:29:02
I'm trying to send a 2D array of RGB values to PHP from the array of values from the getImageData().data method: for (var i=0;i<imgData.data.length;i+=4){ // If you want to know the values of the pixel var r = imgData.data[i + 0]; var g = imgData.data[i + 1]; var b = imgData.data[i + 2]; var a = imgData.data[i + 3]; //[...] do what you want with these values } From this, how would I create a 2D array of RGB values of an entire canvas? var rgb = []; for (var i=0;i<imgData.data.length;i+=4){ // If you want to know the values of the pixel var r = imgData.data[i + 0]; var g = imgData.data[i + 1];

Color generation function

試著忘記壹切 提交于 2019-12-06 07:41:58
问题 Let's consider the following scenario: a function which can generate code colors from white to red, from white to blue, from white to pink, from white to orange, etc. The colors code is in RGB format with values from 0 to 255. Any ideas? Can you give me the pseudocode or link to such algorithm? 回答1: It sounds like you're after linear interpolation - in your case, interpolating from white to the specified colour. For example, in C#: public IEnumerable<Color> Interpolate(Color from, Color to,

PHP IMagick RGB to CMYK inverts?

五迷三道 提交于 2019-12-06 07:37:40
问题 I'm trying to convert a RGB .gif to a CMYK .gif using IMagick PHP module. I've wrote this piece of code $i = new Imagick('mosaique.gif'); $i->setImageColorspace(Imagick::COLORSPACE_CMYK); $i->setImageFormat('gif'); $i->writeImage('mosaique-cmyk.gif'); But the resultant "mosaique-cmyk.gif" still a RGB... but with inverted colors (O_O) What am I doing wrong? EDIT: I've tried with a .jpg and the image is converted to CMYK but it stills in negative. EDIT 2: I've tried to run my script making a

Generate a n-color rainbow palette

◇◆丶佛笑我妖孽 提交于 2019-12-06 07:22:18
I'm trying to generate a rainbow with 15 different colors with ( runnable code here ): size(360,100); colorMode(HSB, 360, 100, 100); // Hue in degrees in [0, 360], // saturation/brightness in [0, 100] // like in Photoshop noStroke(); for (int i = 0; i < 15; i++) { fill(i*24, 100, 100); // 24*15 = 360 rect(i*24, 0, 25, 100); } but it doesn't produce a rich 15 rainbow-color palette, instead some colors are missing (vivid yellow for example). Is there a well known algorithm to produce a vivid rainbow color palette? To understand what's going on, try creating a program that shows a line for each

Converting specialized NV12 video frames to RGB

放肆的年华 提交于 2019-12-06 07:16:35
问题 I have an H264 stream that's decoded using an Android MediaCodec. When I query the output MediaFormat, the color format is 2141391875. Apparently, that's a specialized NV12 variant known as HAL_PIXEL_FORMAT_NV12_ADRENO_TILED. This is on a Nexus 7 (2013). I want to take this data and convert it to RGB so I can create a Bitmap. I've found StackOverflow posts for converting other formats to RGB, not this format. I've tried code from those other posts, the result is just streaks of color. (To

Image conversion : RGBA to RGB

与世无争的帅哥 提交于 2019-12-06 06:57:04
问题 assuming i had RGBA (32 bits) output from frame-grabber, with alpha channel unused (values retained while filled by frame-grabbers), is there any effective conversion method to RGB (24 bits) ? I am dealing with 5 MegaPixels streaming images so speed does matter too. keep in mind that data in alpha channel can be discarded. 回答1: Just copy the data and skip the unused alpha bytes. If speed is important for you, you may want to use SSE or MMX and use the built-in bit-shuffling instructions. That

Decimal to RGB in Javascript and PHP

霸气de小男生 提交于 2019-12-06 05:41:18
问题 I am trying to convert a decimal value back to an RGB value. Assuming that this is the formula for compiling the decimal value c = r*(255*255)+g*255+b (For example rgb(16,120,78) adds up to 1071078) How would one solve r, g and b without any "overflow"? Thanks in advance! 回答1: Use division, modulo ( % ) and floor rounding: var r = Math.floor(c / (256*256)); var g = Math.floor(c / 256) % 256; var b = c % 256; Edit: halex spotted the diffence in use of 255 and 256 in the code. You should (as

Cannot get the original colored bitmap after tesseract processing - android

不问归期 提交于 2019-12-06 05:33:03
I use tesseract library for android to capture certain text from an image. I know that the captured image is not saved anywhere, it gets recycled. I need to find the original colored bitmap. I have been trying to locate the original colored bitmap, but all I could find was a grayscaled bitmap: Bitmap bitmap = activity.getCameraManager().buildLuminanceSource(data, width, height).renderCroppedGreyscaleBitmap(); When I save this bitmap to the sdcard, I get a gray scaled image. renderCroppedGreyscaleBitmap() method is as follows: public Bitmap renderCroppedGreyscaleBitmap() { int width = getWidth(

Android MediaCodec output format: GLES External Texture (YUV / NV12) to GLES Texture (RGB)

梦想的初衷 提交于 2019-12-06 04:42:41
I am currently trying to develop a video player on Android, but am struggling with color formats. Context: I extract and decode a video through the standard combinaison of MediaExtractor/MediaCodec . Because I need the extracted frames to be available as OpenGLES textures (RGB) , I setup my decoder ( MediaCodec ) so that it feeds an external GLES texture ( GL_TEXTURE_EXTERNAL_OES ) through a SurfaceTexture. I know the data output by my HW decoder is in the NV12 ( YUV420SemiPlanar ) format, and I need to convert it to RGB by rendering it (with a fragment shader doing the conversion). MediaCodec

How to plot matrix with rgb image?

核能气质少年 提交于 2019-12-06 04:16:06
I want to plot m*n matrix, each element of which is an rgb triple, like in the following gnuplot code snippet (rgb matrix of 3*3 ): $cross << EODcross 255 0 0 0 0 0 255 0 0 0 0 0 0 0 0 0 0 0 255 0 0 0 0 0 255 0 0 EODcross Black cross on red background. I can change delimiters between columns and color components, if needed. Can I achieve the desired avoiding set palette rgbformulae i,j,k and directly using $cross data? Something like: plot '$cross' matrix with image rgb If not, I can pass 24bit-wide integers (of course, in textual representation, i.e. precalculated and converted to text r +