rgb

Access raw YUV values from JPEG with JavaScript

梦想与她 提交于 2019-12-24 04:55:30
问题 I have dynamically loaded a JPEG image into a 2D html canvas and I would like to access the raw YCbCr pixel values. From what I understand, JPEG encodes the pixel data in YCbCr, but chrome appears convert it to RGB when accessing it with getImageData(). I have tried using the RGB to YCbCr conversion calculations but it appears to be a lossy conversion as they don't map perfectly 1-to-1. Is it possible to access the raw YCbCr pixel values in JavaScript? 回答1: Yes and no. When the browser loads

Tensorflow 2D convolution on RGB channels separately?

半世苍凉 提交于 2019-12-24 04:24:10
问题 I want to apply a Gaussian blur to an RGB image. I want it to be operated on each channel independently. The code below outputs a blurred image with 3 channels but all with the same value, resulting in a grey image . gauss_kernel_2d = gaussian_kernel(2, 0.0, 1.0) # outputs a 5*5 tensor gauss_kernel = tf.tile(gauss_kernel_2d[:, :, tf.newaxis, tf.newaxis], [1, 1, 3, 3]) # 5*5*3*3 image = tf.nn.conv2d(tf.expand_dims(image, 0), gauss_kernel, strides=[1, 1, 1, 1], padding='SAME') # 1*600*800*3

Converting rgb images to grayscale and renaming them using matlab

随声附和 提交于 2019-12-24 02:25:14
问题 I have 500 images named Image1.tif all the way to Image500.tif and I need to convert all of them to grayscale and save them as Image1A.tif to Image500A.tif. Is there a quick way to do this? Thank you. 回答1: If you have Image Processing Toolbox you can use RGB2GRAY function. for k=1:500 Ic=imread(['Image' num2str(k) '.tif']); Ig=rgb2gray(Ic); imwrite(Ig,['Image' num2str(k) 'A.tif'],'tif') end If you don't there is a solution here. Substitute rgb2gray line with: Ig = 0.2989 * Ic(:,:,1) + 0.5870

Converting RGB to Grayscale manually tensorflow

二次信任 提交于 2019-12-24 00:59:26
问题 I wanted to convert an RGB image to grayscale manually without library usage in tensorflow. So I wrote the following... import tensorflow as tf import matplotlib.image as mpimg import matplotlib.pyplot as plt # First, load the image again filename = "MarshOrchid.jpg" raw_image_data = mpimg.imread(filename) image = tf.placeholder("float", [None, None, 3]) slice = tf.slice(image,[0,0,0],[-1,-1,1]) with tf.Session() as session: result = session.run(slice, feed_dict={image: raw_image_data}) plt

Java Color integer to RGB string in JavaScript

情到浓时终转凉″ 提交于 2019-12-24 00:03:04
问题 I'm trying to use some Java Color int values from a database in Javascript. What's the correct way to convert the Java color int (like -2147473665) to an RGB string (like '#ffff00') using Javascript? Right now I'm taking the number, flipping it negative, converting it to hex, and adding a hashtag, but that gives me the wrong color. (The substring is to account for the alpha channel) function getClients() { var query = new Parse.Query(Client); query.each(function(client) { var clientName =

Convert Image to Grayscale with array matrix RGB java

混江龙づ霸主 提交于 2019-12-23 23:16:59
问题 I'm creating an Image filter program and I want to convert a coloured picture to a grayscale picture with the help of an array matrix. This is what I have currently: import java.awt.Color; import se.lth.cs.ptdc.images.ImageFilter; public class GrayScaleFilter extends ImageFilter { public GrayScaleFilter(String name){ super(name); } public Color[][] apply(Color[][] inPixels, double paramValue){ int height = inPixels.length; int width = inPixels[0].length; Color[][] outPixels = new Color[height

How to display an image represented by three matrices in MATLAB?

心已入冬 提交于 2019-12-23 20:08:03
问题 I have 3 2D matrices of the same size (let say 200 rows and 300 columns). Every matrix represent the value of one of the three "basic" color (red, green and blue). The values of the matrix can be between 0 and 255. Now I want to combine these matrices to show them as a colored image (200 by 300 pixels). How can I do it in MATLAB? 回答1: Catenate the images along the 3rd dimension to create an m-by-n-by-3 RGB image. Assuming your red channel image is called red , you write figure, imshow(cat(3

draw polylines with different colors on v2 maps

╄→гoц情女王★ 提交于 2019-12-23 18:36:30
问题 I am drawing multiple polylines using for loop on version 2 google map. I am setting color to the polyline using the code. mMap.addPolyline(new PolylineOptions() .add(new LatLng(lats, lons), new LatLng(late,lone)) .width(5) .color(0xFFFF0000)); How to increment the RGB color dynamically for each for loop iteration. 回答1: Random rnd = new Random(); int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)); --- loop ---- mMap.addPolyline(new PolylineOptions() .add(new

How to convert RGB565 to YUV420SP faster on android?

一曲冷凌霜 提交于 2019-12-23 13:07:52
问题 I need display a jpeg picture, and convert it to YUV420SP. First I use SkBitmap to parse jpeg and display it, then I use the code below to convert RGB565 to YUV420SP on android, but it spend 75ms to convert a 640*480 RGB565 picture, so anybody know the faster way to convert RGB565 to YUV420SP on android? or faster way to convert jpeg file to YUV420SP on android? // Convert from RGB to YUV420 int RGB2YUV_YR[256], RGB2YUV_YG[256], RGB2YUV_YB[256]; int RGB2YUV_UR[256], RGB2YUV_UG[256], RGB2YUV

What is the meaning of a negative number when using getRGB()?

a 夏天 提交于 2019-12-23 12:44:18
问题 I am new to color stuff, rendering etc. and watching a couple tutorial videos about rendering etc. My question is, when I call a getRGB method on a pixel, it returns a negative int. what is the meaning of this negative number? For example, when i call getRGB on a color with r: 186, g: 186, b: 186, it returns -4539718. How is this number related to its rgb value? I've made a couple of google search but was not successful. 回答1: The getRGB method returns an int whose 4 bytes are the alpha, red,