pixel

How does Robot's getPixelColor(int x, int y) method work?

廉价感情. 提交于 2019-11-28 05:09:02
问题 How exactly does the method getPixelColor(int x,int y) from the Robot class work? I tried this code fragment: try { Robot robos = new Robot(); } catch (AWTException e) { } for (int i = 0; i < 100; i++) robos.getPixelColor(0, 0); System.out.println("fsadf"); on my PC, which is a core 2 duo, and it took one second or less to execute the print statement. However, when I ran this same code on my laptop, which is a core i3, it took much more time (about 2-3 seconds). What is the reason behind this

Cycle through pixels with opencv

余生长醉 提交于 2019-11-28 03:59:28
How would I be able to cycle through an image using opencv as if it were a 2d array to get the rgb values of each pixel? Also, would a mat be preferable over an iplimage for this operation? If you use C++, use the C++ interface of opencv and then you can access the members via http://docs.opencv.org/2.4/doc/tutorials/core/how_to_scan_images/how_to_scan_images.html#the-efficient-way or using cv::Mat::at(), for example. cv::Mat is preferred over IplImage because it simplifies your code cv::Mat img = cv::imread("lenna.png"); for(int i=0; i<img.rows; i++) for(int j=0; j<img.cols; j++) // You can

Trouble reading .bmp header file properly

不问归期 提交于 2019-11-28 02:00:05
问题 I am trying to take in a .bmp file and eventually edit the pixels one by one but I am coming up with a problem with the width and height returned to me in the INFOHEADER struct. The width returned is 13107200 and the height is 65536. However, whenever I run through the program a total of only 60003 total pixels are counted. I have no idea why this is. Any help would be greatly appreciated. #include <stdio.h> #include <stdlib.h> int main( int argc, char *argv[] ){ //define structures typedef

Retrieving a pixel alpha value for a UIImage (MonoTouch)

巧了我就是萌 提交于 2019-11-28 01:54:19
问题 This question is a duplicate of 1042830, but MonoTouch-specific. Is there a way that's safer than allocating an IntPtr, drawing into it using CGBitmapContext and then reading bytes at the appropriate offset? 回答1: I don't know if it's kosher to answer your own question, but: protected CGBitmapContext CreateARGBBitmapContext(CGImage inImage) { var pixelsWide = inImage.Width; var pixelsHigh = inImage.Height; var bitmapBytesPerRow = pixelsWide * 4; var bitmapByteCount = bitmapBytesPerRow *

Getting Pixel Color from an Image using CGPoint in Swift 3

拈花ヽ惹草 提交于 2019-11-28 01:47:01
问题 I am try this PixelExtractor class in Swift 3, get a error; Cannot invoke initializer for type 'UnsafePointer' with an argument list of type '(UnsafeMutableRawPointer?)' class PixelExtractor: NSObject { let image: CGImage let context: CGContextRef? var width: Int { get { return CGImageGetWidth(image) } } var height: Int { get { return CGImageGetHeight(image) } } init(img: CGImage) { image = img context = PixelExtractor.createBitmapContext(img) } class func createBitmapContext(img: CGImage) ->

Getting pixel data from UIImageView — works on simulator, not device

旧巷老猫 提交于 2019-11-28 01:38:40
问题 Based on the responses to a previous question, I've created a category on UIImageView for extracting pixel data. This works fine in the simulator, but not when deployed to the device. I should say not always -- the odd thing is that it does fetch the correct pixel colour if point.x == point.y; otherwise, it gives me pixel data for a pixel on the other side of that line, as if mirrored. (So a tap on a pixel in the lower-right corner of the image gives me the pixel data for a corresponding

Size of zero pixels in CSS with or without 'px' suffix? [duplicate]

可紊 提交于 2019-11-27 21:54:23
This question already has an answer here: 'property: 0' or 'property: 0px' in CSS? 9 answers Googling for the answer to this question has proven difficult so I figured somebody here should know. Within CSS, I've seen zero pixels declared as simply '0' yet also as '0px'. mystyle { width: 0; } anotherstyle { width: 0px; } The minor problem with '0' is that if you change it to some non-zero value, you might forget to add the 'px'. And when making a value '0', you may forget to remove the 'px'. I want pure consistency in my code and little things like this drive me nuts. Does this really come down

How to get pixel data from an image using R

限于喜欢 提交于 2019-11-27 20:55:48
Can anyone help me on how to get the RGB pixel data from an image in R? I need this information to compare differences in bird plumage to aid in the understanding of a speciation event. My photos are taken by a digital camera and are now as a NEF-file. It doesn't matter which type of file that's needed, I have the possibility to convert the file to whatever I want. However, I would prefer to maintain as much information as possible in the file (i. e. PNG-files are good). I have tried many packages in R: Pixmap, Raster, ImageMetrics and browsed the internet, tested methods, asked co-students

Count all values in a matrix greater than a value

故事扮演 提交于 2019-11-27 20:41:44
问题 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? 回答1: The numpy.where function is your friend. Because it's implemented to take full advantage of the array datatype, for

jQuery/JavaScript: convert pixels to em in a easy way

两盒软妹~` 提交于 2019-11-27 20:06:41
I am looking for a easy way to add a line of code to a plugin of mine, to convert a couple of pixel values into em values, because the layout of my project needs to be in ems. Is there an easy way to do this, because I don't want to add a third-party plugin to the site. Won't post the code here, as it has nothing to do with the plugin it self. Thanks. Example: 13px -> ??em Aras I think your question is very important. Since the classes of display resolutions are rapidly increasing, using em positioning to support wide range of screen resolutions is a really appealing approach. But no matter