Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Algorithm for finding dead pixels in Javascript

I am trying to create an algorithm that detects and counts dead pixels from an intensity map in .csv format. My current approach is to divide the value of the pixel I am testing by the value of the pixel immediately to the right (or, if on the far right side, the one to the left). If the dividend is less than some threshold (currently .9), then I mark it as a dead pixel.

My question is, is there a better/more efficient way to calculate if a pixel is dead?

Sample csv output:

3183    3176    3207    3183    3212
3211    3197    3198    3183    3191
3193    3177    1135    3185    3176
3175    3184    3188    3179    3181
3181    3165    3184    3187    3183

In this example, the middle pixel would be a "dead" pixel.

like image 257
Louis Avatar asked Jul 30 '12 07:07

Louis


People also ask

How do you detect dead pixels?

The Difference Between Stuck and Dead Pixels Stuck pixels are usually red, green, blue, or yellow. Dead pixels are black. No matter how much your screen changes, those pixels will remain fixed in one spot and won't change their color. Keep in mind that stuck pixels can also be black or very dark in color.

Is there a solution for dead pixels?

Apply pressure to the area where the stuck pixel is. Try not to put pressure anywhere else, as this may trigger the creation of more stuck pixels. While applying pressure, turn on your computer and screen. Remove pressure, and the stuck pixel should be gone.

How long is JScreenFix?

JScreenFix claims it can repair most stuck pixels in under 10 minutes, but giving it plenty of time to work never hurts. Try using it several times if the first run wasn't successful.

How are dead pixels formed?

What causes dead pixels exactly? Most instances of dead pixels are the result of a failed power connection. Pixels require power to change color. If the power connection to a pixel is cut off, it will become a black and dead pixel.


1 Answers

Efficiency

You'll need to look at each pixel at least once so there's no way your running time can ever beat the current O(n), where n is the number of pixels. Your algorithm uses a constant amount of memory, which is also optimal.

However, I'm not sure your algorithm is always correct. Do you have a way of avoiding comparing consecutive dead pixels? Example input:

3183    3176    1135    1135    3212
                ^ Not detected

A More Accurate Way

I'm assuming you take the intensity of the neighboring pixel to avoid comparing pixels that are in different areas of the screen since the screen's brightness might not be evenly distributed.

One approach to avoiding false negatives is to take the average of several nearby pixels, but this might not work if there are a lot of dead pixels in the area. You might try taking the max value out of all of the pixels in a small area. This way as long as a single pixel in the entire area is not dead all of the dead pixels will be detected.

How many pixels you sample would be determined by your tolerance for false negatives.

like image 96
CgodLEY Avatar answered Oct 18 '22 11:10

CgodLEY