pixel

Detect black pixel in image iOS

走远了吗. 提交于 2019-11-29 02:44:15
As of now I am searching every pixel 1 by 1 checking the color and seeing if it's black... if it isn't I move on to the next pixel. This is taking forever as I can only check approx. 100 pixels per second (speeding up my NSTimer freezes the app because it can't check fast enough.) So is there anyway I can just have Xcode return all the pixels that are black and ignore everything else so I only have to check those pixels and not every pixel. I am trying to detect a black pixel furthest to the left on my image. Here is my current code. - (void)viewDidLoad { timer = [NSTimer

Line rasterisation: Cover all pixels, regardless of line gradient?

穿精又带淫゛_ 提交于 2019-11-28 22:49:44
问题 Basically, I want to use a line algo to determine which cells to check for collisions for my raycaster. Bresenham isn't great for this as it uses a unified-thickness approach, meaning that it ignores cells that aren't at least half-covering the line. Not great at all, because it means that some segments of my line aren't being checked for intersections with the cells, leading to errors. I can't seem to find any "thick-line" algorithms, can anyone help me find one? Green: What I would like.

What is the current state of sub-pixel accuracy in the major browsers?

∥☆過路亽.° 提交于 2019-11-28 22:26:34
I'm working on a drawing application which requires high levels of accuracy, and I'm wondering which of the major browser platforms (including the HTML Canvas element, and Flash) give the best sub-pixel layout accuracy, both for drawn elements (rectangles in the Canvas or Flash, absolutely positioned DIVs in the browser), and for text. There are a number of posts related to this, both on this site and others, (see list at bottom), but many are quite old, and none summarises the current situation. My understanding is that Flash has native support for sub-pixel positioning, using twips to

python tkinter: how to work with pixels?

荒凉一梦 提交于 2019-11-28 21:22:59
using google (and this site) i have seen some similar questions but my problem is still here: "i want to draw an image (without reading a file) , being able to manipulate every single pixel's colour in that image." i have seen another question where was suggested to do something like this: from tkinter import * A=Tk() B=Canvas(A) B.place(x=0,y=0,height=256,width=256) for a in range(256): for b in range(256): B.create_line(a,b,a+1,b+1,fill=pyList[a][b])#where pyList is a matrix of hexadecimal strings A.geometry("256x256") mainloop() in fact this answers my question but... it is extremely slow.

Position of Div in relation to the Top of the Viewport

纵饮孤独 提交于 2019-11-28 20:08:47
I am wondering how I can get the number of pixels (or measurement in general) from a div to the top of the window in Javascript. I am not looking for an offset y in relation to the document, simply to the top of where the browser is displaying. I tried the "answered" solution here: Is it possible to get the position of div within the browser viewport? Not within the document. Within the window , but at least in Safari, I am running into a problem where it returns the same number no matter where the div's really are. Thanks for any help! The existing answers are now outdated. The

Count all values in a matrix greater than a value

♀尐吖头ヾ 提交于 2019-11-28 20:01:51
I have to count all the values in a matrix (2-d array) that are greater than 200. The code I wrote down for this is: za=0 p31 = numpy.asarray(o31) for i in range(o31.size[0]): for j in range(o32.size[1]): if p31[i,j]<200: za=za+1 print za o31 is an image and I am converting it into a matrix and then finding the values. My question is, is there a simpler way to do this? The numpy.where function is your friend. Because it's implemented to take full advantage of the array datatype, for large images you should notice a speed improvement over the pure python solution you provide. Using numpy.where

Quickly getting the color of some pixels on the screen in Python on Windows 7

泄露秘密 提交于 2019-11-28 18:27:52
I need to get the color of some pixels on the screen or from the active window, and I need to do so quickly . I've tried using win32gui and ctypes/windll, but they're much too slow. Each of these programs gets the color of 100 pixels: import win32gui import time time.clock() for y in range(0, 100, 10): for x in range(0, 100, 10): color = win32gui.GetPixel(win32gui.GetDC(win32gui.GetActiveWindow()), x , y) print(time.clock()) and from ctypes import windll import time time.clock() hdc = windll.user32.GetDC(0) for y in range(0, 100, 10): for x in range(0, 100, 10): color = windll.gdi32.GetPixel

Pixel density, retina display and font-size in CSS

随声附和 提交于 2019-11-28 18:23:18
I don't have a Retina MacBook myself to test these things out, and there seems to be a lot of confusion on the internet about web design on high pixel density displays. Now, I assume that WebKit on a MacBook with Retina display scales the page about twice it's size as most web pages are not built to adapt to the higher pixel density? In my view the ideal case when designing for these, or actually any type of display is to use ems instead of pixels as you could just do; @media only screen and (-webkit-min-device-pixel-ratio : 1.5), only screen and (min-device-pixel-ratio : 1.5) { body { font

c++ and opencv get and set pixel color to Mat

我的未来我决定 提交于 2019-11-28 18:11:39
I'm trying to set a new color value to some pixel into a cv::Mat image my code is below: Mat image = img; for(int y=0;y<img.rows;y++) { for(int x=0;x<img.cols;x++) { Vec3b color = image.at<Vec3b>(Point(x,y)); if(color[0] > 150 && color[1] > 150 && color[2] > 150) { color[0] = 0; color[1] = 0; color[2] = 0; cout << "Pixel >200 :" << x << "," << y << endl; } else { color.val[0] = 255; color.val[1] = 255; color.val[2] = 255; } } imwrite("../images/imgopti"+to_string(i)+".tiff",image); It seems to get the good pixel in output (with cout) however in the output image (with imwrite) the pixel

How a CSS pixel size is calculated?

我只是一个虾纸丫 提交于 2019-11-28 15:21:04
While delving into CSS units I've encountered a definition of the reference pixel. However, I wasn't able to find a consistent and comprehensive description of its relation to the CSS pixel unit. I've done some research on this matter, yet it's still a little bit unclear to me. 1. Gathered information 1.1 A pixel definition There are two distinct types/definitions of a pixel: "Device pixel" — a single physical point on a display. And: CSS pixel — a unit most closely matching the reference pixel. [ 1 ] Two parallel concepts under the same name definitely don't clarify the confusion. I fully