Re: grouping pixels and counting groups



"Evan " <eetrocnative@xxxxxxxxx> wrote in message <gomn6r$c4o$1@xxxxxxxxxxxxxxxxxx>...
Jomar Bueyes <jomarbueyes@xxxxxxxxxxx> wrote in message <b58e5a77-f5ac-4299-810d-327a71a6c589@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>...
On Mar 4, 12:56=A0pm, "Evan " <eetrocnat...@xxxxxxxxx> wrote:
Hello.

I am trying to write a function which takes an image as its input, finds =
defective pixels, and then searches for and counts groups of defective pixe=
ls. The image is 480x752 pixels and is saved as a bitmap image. Defective p=
ixels are irregularities such as random white dots in an otherwise black im=
age. Groups are defective pixels adjacent to each other.

I already wrote code which finds defective pixels and records the locatio=
n as a '1' in a separate matrix which is initialized as all zeros.

Does anyone have any idea as to how I should proceed?

Hi,

One way to identify bad pixels is to look at the neighborhood of each
pixel (say a 5x5 or larger neighborhood) and calculate the mean and
std. deviation of the pixels in the neighborhood. If the pixel of
interest differs from the mean of the neighborhood by more than an
arbitrarily threshold (e.g. 2.5*std. dev), the pixel is likely to be
bad. The method is rather ad hoc, but we have successfully used it to
identify bad pixels of a CCD camera after an image has been collected
w/o the corresponding calibration image.

HTH

Jomar

Thanks for your reply. I actually use an 11x11 "box" around each pixel of interest to determine if it is sufficiently different enough from its neighbors to be labeled as bright/very bright or dark/very dark. Defective pixel locations are stored as a '1' in secondary matrices (darkcluster and brightcluster). My question is about the best way to find groups of defective pixels.

Currently, I am using my secondary matrices, to hold the location of defective pixels for me. I take each one as a vector and compare individual defect locations to their neighbors of higher index value (see the code slice below) and only increment a counter if a 1 is next to a 1. Whenever a 1 is next to another 1, both become 2s, which simply mean that they have already been counted once and won't be counted again. I doublecheck that darkcluster(n) == 1 inside of the nested if loop because once the code enters the first check, the value of darkcluster(n) gets changed and I want to prevent the same group from counting more than once.

**darkcluster is already loaded with a 1 in every defective pixel location**
for n = 481:360480; % skip the first and last columns
if(not(mod(n,480) == 1) && not(mod(n,480) == 0)) % skip rows 1 and 480
if(darkcluster(n) == 1) % unmodified since it was determined to be defective
if(darkcluster(n+1) == 1)
if(darkcluster(n) == 1) % to make sure I dont count the same group 2x
darkclustercount = darkclustercount + 1;
end
darkcluster(n) = 2;
darkcluster(n+1) = 2;
end
if(darkcluster(n+479) == 1)
if(darkcluster(n) == 1)
darkclustercount = darkclustercount + 1;
end
darkcluster(n) = 2;
darkcluster(n+479) = 2;
end
if(darkcluster(n+480) == 1) .....
.....

I think it may just be my brute force method, but the code takes almost 5 minutes to run. Does that seem reasonable, considering that I have to make so many millions of calculations to find the defects and then search for groups?

---------------------------------------------------------------------------------
Evan:
You posted this while I was composing my first reponse. What you are trying to do is your own labeling. Just dump all that code above, and call bwlabel(). It will do the job for you in a fraction of a second. You need the image processing toolbox to get the bwlabel() function.
Good luck,
ImageAnalyst
.



Relevant Pages

  • Re: Sensor cleaning mode maps out hot pixels
    ... That corresponds to 3.4 defects in every ... Good flat-panel monitors ... result in an *average* of 44 hot or cold pixels in each sensor produced. ... than defective sensors. ...
    (rec.photo.digital)
  • Re: grouping pixels and counting groups
    ... The image is 480x752 pixels and is saved as a bitmap image. ... One way to identify bad pixels is to look at the neighborhood of each ... darkclustercount = darkclustercount + 1; ... considering that I have to make so many millions of calculations to find the defects and then search for groups? ...
    (comp.soft-sys.matlab)
  • Re: "hot" pixel on CCD: what is it and should I be concerned?
    ... > 2) Are hot pixels just a one time event, or can more appear on the CCD ... which are warranted to have different levels of defects. ... A 'class 1' chip, must have no cluster or column ... Generally, most astronomical cameras, use 'Class 2' chips, unless you ...
    (sci.astro.amateur)
  • Re: flawed megapixel experiment
    ... printed / displayed a resolution that is high enough that the viewer ... cannot resolve the pixels in the image. ... If you try to get more resolution than the math allows, the artifacts are ... a matter of taste as to what defects are tolerated. ...
    (rec.photo.digital)
  • Re: Sensor cleaning mode maps out hot pixels
    ... That corresponds to 3.4 defects in every million units produced. ... In terms of sensor in digital cameras, six sigma is 3.4 defective pixels per megapixel. ... So in 12.8million pixels, best practice standards would result in an *average* of 44 hot or cold pixels in each sensor produced. ...
    (rec.photo.digital)