pixel

Changing RGB color image to Grayscale image using Objective C

心不动则不痛 提交于 2019-12-04 04:57:50
I was developing a application that changes color image to gray image. However, some how the picture comes out wrong. I dont know what is wrong with the code. maybe the parameter that i put in is wrong please help. UIImage *c = [UIImage imageNamed:@"downRed.png"]; CGImageRef cRef = CGImageRetain(c.CGImage); NSData* pixelData = (NSData*) CGDataProviderCopyData(CGImageGetDataProvider(cRef)); size_t w = CGImageGetWidth(cRef); size_t h = CGImageGetHeight(cRef); unsigned char* pixelBytes = (unsigned char *)[pixelData bytes]; unsigned char* greyPixelData = (unsigned char*) malloc(w*h); for (int y =

Detecting a pixelated image in python

左心房为你撑大大i 提交于 2019-12-04 03:56:58
问题 I'm trying to determine if an image is squared(pixelated). I've heard of 2D fourrier transform with numpy or scipy but it is a bit complicated. The goal is to determine an amount of squared zone due to bad compression like this (img a): 回答1: I have no idea if this would work - but, something you could try is to get the nearest neighbors around a pixel. The pixellated squares will be a visible jump in RGB values around a region. You can find the nearest neighbors for every pixel in an image

How to convert pixel formats? From 32bppRGB to 16bpp grayscale in C#

本小妞迷上赌 提交于 2019-12-04 03:31:46
问题 I need to do some thresholding for my image. The threshold filter function just accepts 8-16bpp grayscale . My bitmap picture has the 32bppRGB pixelformat. Please suggest some code for the same. (I also want to know if it is possible without pixel by pixel operations) p.s. I am using the Aforge.NET for thresholding. Thanks -Sagar 回答1: Easiest way: public static Bitmap MakeGrayscale(Bitmap original) { //make an empty bitmap the same size as original Bitmap newBitmap = new Bitmap(original.Width

Per-pixel collision problem in C#

别来无恙 提交于 2019-12-04 02:01:22
问题 I am writing a small 2d game engine in C# for my own purposes, and it works fine except for the sprite collision detection. I've decided to make it a per-pixel detection (easiest for me to implement), but it is not working the way it's supposed to. The code detects a collision long before it happens. I've examined every component of the detection, but I can't find the problem. The collision detection method: public static bool CheckForCollision(Sprite s1, Sprite s2, bool perpixel) { if(

Checking image feature alignment

≡放荡痞女 提交于 2019-12-03 21:28:19
I have written my own software in C# for performing microscopy imaging. See this screenshot . The images that can be seen there are of the same sample but recorded through physically different detectors. It s crucial for my experiments that these images be exactly aligned. I thought the easiest would be to somehow blend/substract the two bitmaps but this doesn't give me good results. Therefore I am looking for a better way to do this. It might be useful to point out that the images exist as arrays of intensities in memory and are converted to bitmaps for on-screen painting to my self written

Commonly used pixel sizes for webpages and their pros/cons

∥☆過路亽.° 提交于 2019-12-03 20:35:10
问题 What are the most commonly used pixel sizes (primarily widths) and what are there advantages and disadvantages? How can I best find a happy medium to give a good experience to people with a wide variety of monitor sizes? An answer with an explanation rather than just the size would be greatly appreciated. 回答1: the most grids use a width of 960px. (When the design has a fixed width). When you take a look at global statistics 1024 range resolutions are still the most common: http://gs

OpenCV replacing specific pixel values with another value

帅比萌擦擦* 提交于 2019-12-03 20:09:47
问题 I want to detect a specific pixel value (let's say 128 in a unsigned 8 bit 1-channel image) in a cv::Mat image and replace the value of all the pixels with that specific value with another value (replacing each 128 with 120). Is there any efficient way of doing this? Or should I do the search and assertion operations pixel by pixel? I started coding but could not completed. Here is the part of my code: cv::Mat source; unsigned oldValue = 128; unsigned newValue = 120; cv::Mat temp = (source ==

Converting Pixel values to mm - Android

时光怂恿深爱的人放手 提交于 2019-12-03 16:49:52
Because of specific needs, in my android layout, I have used "mm" to provide size. In TextView also, I have provided sizes in "mm". When I do textView.getTextSize() , the size returned is always in pixel values. I want to convert that pixel value in "mm". For example, if I have set font size as "2mm", then on any device, when I do getTextSize() , I would like to get "2mm". Should I use any specific method for that? I could find answers to convert "mm" to "pixel" but could not find anything about converting vice-versa. Nimish Choudhary we use TypedValue.java float px = TypedValue.applyDimension

Help with the theory behind a pixelate algorithm?

你离开我真会死。 提交于 2019-12-03 15:34:43
So say I have an image that I want to "pixelate". I want this sharp image represented by a grid of, say, 100 x 100 squares. So if the original photo is 500 px X 500 px, each square is 5 px X 5 px. So each square would have a color corresponding to the 5 px X 5 px group of pixels it swaps in for... How do I figure out what this one color, which is best representative of the stuff it covers, is? Do I just take the R G and B numbers for each of the 25 pixels and average them? Or is there some obscure other way I should know about? What is conventionally used in "pixelation" functions, say like in

Working in a BufferedImage's int[] pixels array

穿精又带淫゛_ 提交于 2019-12-03 15:25:20
When working with BufferedImage using the setRGB and getRGB methods, I noticed two things: the setRGB and getRGB methods can be incredibly slow on some systems (as much as two orders of magnitude slower than modifiyng the int[] array). there are no guarantee that a getRGB following a setRGB will give back the same pixel you passed This last point is basically pretty clear from the JavaDoc of setRGB , which states: ...For images with an IndexColorModel, the index with the nearest color is chosen. Seen I can work directly in a BufferedImage's int[] pixels, which I can access to by doing, for