pixel

unsigned char pixel_intensity[] to image; C code, Linux

和自甴很熟 提交于 2019-12-13 09:28:55
问题 I have a data array of pixel intensity (e.g. unsigned char pixel_intensity[4] = {0, 255, 255, 0} ) and I need to create image in C code on Linux (Raspberry Pi). What is the easiest way to do it? 回答1: I would suggest using the netpbm format as it is very easy to program. It is documented here and here. I have written a little demonstration of how to write a simple greyscale ramp to a 100x256 image below. #include <stdio.h> #include <stdlib.h> int main(){ FILE *imageFile; int x,y,pixel,height

C++ how to shrink an image using a pointer array?

允我心安 提交于 2019-12-13 08:35:25
问题 I'm writing a c++ program that manipulates images, and this is the function to shrink it. There is a 'pixel' pointer array and a class that has the image colors defined. I cannot use any other library besides the ones included in Visual Studio for this image program. I'm having an issue with this function, I need to traverse the pixels in the image and split it into blocks; the user will enter the block width/height. After the blocks are created, the average RGB values need to be taken from

Finding pixel width in matlab

删除回忆录丶 提交于 2019-12-13 08:24:24
问题 In order to find the pixel width , how can I do that in matlab ? EDIT I need the width in say for example mm Thanks. 回答1: Try using the ScreenPixelsPerInch property of the root object. pixelsPerInch = get(0, 'ScreenPixelsPerInch'); mmPerInch = 25.4; mmPerPixel = mmPerInch / pixelsPerInch; 来源: https://stackoverflow.com/questions/13448615/finding-pixel-width-in-matlab

HTML5, rendering pixels to image on load for faster draw times

旧时模样 提交于 2019-12-13 05:19:50
问题 I have a map that is a per pixel terrain. If you draw these pixels individually, it takes a lot of render time. So my idea is to draw them in blocks of 100x100 images when the pixels are changed, and render those images. The pixels in "chunk" is stored in a 1D array in the form index = x+y*width. var img = game.c.createImageData(CHUNK_SIZE,CHUNK_SIZE); for (var i=0;i<chunk.map.length;i++){ var p = chunk.map[i]; if (p){ img.data[i*4] = 255; img.data[i*4+1] = 0; img.data[i*4+2] = 0; img.data[i

Giving specific pixels a certain colour

筅森魡賤 提交于 2019-12-13 04:38:04
问题 EDIT I have a grayscale image which contains pixel values of 300 , which I assigned manually to pixels that hold a specific criterion. The case is that the other values in the image are 1 and 2 . So, I will have three values now: 1 , 2 , and 300 . In order to display the image in a meaningful way, we can use thresholding . So, this is as for the pixels with values 1 and 2 . For the pixels with the value 300 , how can I assign it some colour to be able to discriminate it from other parts of

Pyplot imshow not showing square pixels when setting aspect ratio

ε祈祈猫儿з 提交于 2019-12-13 03:21:50
问题 I am having some trouble using Pyplot imshow to plot an image from a numpy ndarray called data keeping both its aspect ratio and square-shaped pixels. The shape of the ndarray is (112, 2182) . Here´s the code I´m using: import matplotlib as mpl from mpl_toolkits.axes_grid1 import make_axes_locatable import numpy as np mpl.use('Agg') import matplotlib.pyplot as plt data = np.random.random_sample((112, 2182)) plt.figure(figsize=(25, 3.5)) plt.subplots_adjust(left=0.1, right=0.9) ax = plt

Remove visible gaps between elements (possible Chrome defect)

浪子不回头ぞ 提交于 2019-12-13 02:36:25
问题 How can I remove the three labelled gaps in the image below? This code is available at http://jsfiddle.net/69zj6smo/ - resize the render area to see that some lines are typically present. What confuses me is that I think I've always created fluid/percentage layouts like this, and I don't remember this visual artifact (layout error, or possibly browser defect) in any browser previously. Regardless of whether fractional pixels exist (such as in a Zoom or High-DPI mode) or not (see: Is there

How to plot on grid with refinements?

徘徊边缘 提交于 2019-12-13 01:29:45
问题 Related question My data comes in the form of a (3 × N) array [[x_0, ..., x_N-1], [y_0, ..., y_N-1], [z_0, ..., z_N-1]] I want to plot it such that the first two lines code the X, Y position of a pixel and the third line sets the pixel's color. However, I do not want any interpolation to take place. Rather, the space is tiled by the fact that all points lie on a grid , with lower divisions being refinements of the original grid. Here is some dummy data [[4, 12, 24, 4, 12, 20, 28, 8, 18, 22,