pixels

Java rotation of pixel array

天大地大妈咪最大 提交于 2019-12-19 04:18:19
问题 I have tried to make an algorithm in java to rotate a 2-d pixel array(Not restricted to 90 degrees), the only problem i have with this is: the end result leaves me with dots/holes within the image. Here is the code : for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { int xp = (int) (nx + Math.cos(rotation) * (x - width / 2) + Math .cos(rotation + Math.PI / 2) * (y - height / 2)); int yp = (int) (ny + Math.sin(rotation) * (x - width / 2) + Math .sin(rotation + Math.PI / 2) *

吴裕雄--天生自然 pythonTensorFlow图形数据处理:读取MNIST手写图片数据写入的TFRecord文件

送分小仙女□ 提交于 2019-12-19 02:38:39
import numpy as np import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data # 读取文件。 filename_queue = tf.train.string_input_producer(["F:\\output.tfrecords"]) reader = tf.TFRecordReader() _,serialized_example = reader.read(filename_queue) # 解析读取的样例。 features = tf.parse_single_example(serialized_example,features={'image_raw':tf.FixedLenFeature([],tf.string),'pixels':tf.FixedLenFeature([],tf.int64),'label':tf.FixedLenFeature([],tf.int64)}) images = tf.decode_raw(features['image_raw'],tf.uint8) labels = tf.cast(features['label'],tf.int32) pixels = tf.cast(features['pixels

WPF - canvas height in pixels

岁酱吖の 提交于 2019-12-18 01:32:10
问题 How can I determine the width in pixels for a canvas (which has a certain width)? I have a bitmap in an AnimatedImage control, and I know the bitmap's width in pixels, and I want to scale the bitmap so that it horizontally fits exactly the canvas. How can i determine this scale? Note: I do not need to use RenderTargetBitmap, because the bitmap is already loaded. 回答1: In WPF units are device independent. The formula to figure out the actual pixel size of a unit is: Pixels per WPF Unit =

int array to BufferedImage

淺唱寂寞╮ 提交于 2019-12-17 19:47:17
问题 I'm making with the Robot class a printscreen and I convert the BufferedImage into an int array. Then I want to convert the int array back to a bufferedimage but that gives an error. This is my code: Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); BufferedImage printscreen = robot.createScreenCapture(new Rectangle(screen)); int[] pixels = ((DataBufferInt) printscreen.getRaster().getDataBuffer()).getData(); BufferedImage image = new BufferedImage(screen.width, screen.height,

Why do I need @1x, @2x and @3x iOS images?

旧街凉风 提交于 2019-12-17 17:28:34
问题 Why do we need these 3 particular image types? If I have a button on my app with a background image say, 50 pixels x 50 pixels, why do I need 3 versions of this image? What's stopping me from just making one image that's much higher in res, say, 700x700 so when it shrinks down on any iPhone it won't fall under the max res the device would want? Only thing I can think of is it just takes up more space, but for simple apps / a simple button it seems like it wouldn't cause any issues. I've tried

C++ Pixels In Console Window

蓝咒 提交于 2019-12-17 15:38:14
问题 In C++ using Code::Blocks v10.05, how do I draw a single pixel on the console screen? Is this easy at all, or would it be easier to just draw a rectangle? How do I color it? I'm sorry, but I just can't get any code from SOF, HF, or even cplusplus.com to work. This is for a Super Mario World figure on the screen. The game I think is 16-bit, and is for the SNES system. C::B says I need SDK for C::B. It says "afxwin.h" doesn't exist. Download maybe? This is what I'm trying to make: 回答1: It

Does setWidth(int pixels) use dip or px?

自闭症网瘾萝莉.ら 提交于 2019-12-17 06:22:16
问题 Does setWidth(int pixels) use device independent pixel or physical pixel as unit? For example, does setWidth(100) set the a view's width to 100 dips or 100 pxs? Thanks. 回答1: It uses pixels, but I'm sure you're wondering how to use dips instead. The answer is in TypedValue.applyDimension(). Here's an example of how to convert dips to px in code: // Converts 14 dip into its equivalent px Resources r = getResources(); int px = Math.round(TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 14

How to render a pixel array most efficiently to a window in c++?

北战南征 提交于 2019-12-13 15:23:10
问题 So far i have been using SDL 2.0, copy my pixel array into a texture which then gets rendered on the screen. My render method looks like this: for (int i = 0; i < WIDTH*HEIGHT; i++){ pixels[i] = 0xFFFF0000; //pixel Format: AARRGGBB } SDL_UpdateTexture(sdlTexture, NULL, pixels, 800 * sizeof(Uint32)); SDL_RenderClear(renderer); SDL_RenderCopy(renderer, sdlTexture, NULL, NULL); SDL_RenderPresent(renderer); I then measured the time it takes to render it once in nanoseconds (via chrono) and

Repairing pixelated image using matlab Help needed

大憨熊 提交于 2019-12-13 08:57:19
问题 http://i.imgur.com/j7hStIG.png Hi I need help repairing this image using for loops. I know I have to identify the bad pixels first and fill them in. thanks. PS I am very new to matlab clear clc format compact filenameIN = uigetfile('.bmp','Picture'); noisyRGBarray = imread(filenameIN); figure(1) imshow(noisyRGBarray) y = noisyRGBarray; [m,n]=size(y) clean=[]; for i=2:m-1 for j=2:n-1 if y(i,j)% clean add new clean = [ clean, y(i,j) ] end end end Im pretty sure the for statemetn is wrong and I

Is there a general method of drawing 2d objects on a digital screen

自古美人都是妖i 提交于 2019-12-13 08:20:03
问题 Some context, I want to draw 2D objects by defining a set of pixels to change to a color which represents the shape. For example, if I wanted to draw a square I'd define a top left corner say (0,0), and a bottom right corner say (10,10). Then I'd change the color of all the pixels x values 0-10 with y values 0-10. Unfortunately I don't have a solid step by step method to complete this, and am only able to draw squares/rectangles due to how simple they are. Is there a method you can describe,