logo       


Re: Quick Help? Pixel Subtraction: msg#00107

Subject: Re: Quick Help? Pixel Subtraction
On Monday 12 December 2005 20:54, Gary Laevsky wrote:
> Our homemade system has some inherent noise in the PMT, to the tune
> of about 1000 pixels out of 30,000 or so.  I'd like to "delete" the
> 255s.  In many cases, the next pixel value is about 150, so I'm also
> having some "stretch" issues.  If I could just delete the 255s....

Not sure if these 3 options would to what you want, but be aware that these 
methods "invent" values for the noisy pixels...

A) simplest:
* duplicate original and call it image1
* threshold the image1 at 255,255 
* subtract original-image1 (pixels at 255 will now be 0).


B) 8 bit & 24 bit image denoising 
////////////////////////////////////////////////////////////////////////////
// SaturatedSinglePixelDenoising.txt
// G. Landini 16/July/2005
// This macro detects saturated *single* pixels (8 connected) in the 
// image (grey=255) and replaces them with the pixel value of 
// either the mean or the median of the neighbours (choose which
// method one by  un-commenting the lines indicated below.
// Works with 8bit and 24 bit images only.
// Needs the Particles8 plugin available at: 
// http://www.dentistry.bham.ac.uk/landinig/software/software.html
run("Duplicate...", "title=Denoised");
setBatchMode(true);
run("Duplicate...", "title=pixels");
if (bitDepth==24) run("8-bit");
setThreshold(255, 255);
run("Threshold", "thresholded remaining");
//---
// if you want to denoise small clusters of pixels, rather than single pixels,
// then comment the following 5 lines, but be aware that the average 
// or median will not be correct as other pixels in the cluster may
// contribute to the corrected value:
run("Duplicate...", "title=non-single");
run("Particles8 ", "white show=Particles filter minimum=2 maximum=999999 
overwrite");
imageCalculator("Subtract", "pixels","non-single");
selectWindow("non-single");
close();
//---
selectWindow("Denoised");
run("Duplicate...", "title=median");
// use average of the 8 neighbours
run("Convolve...", "text1=[1 1 1 1 0 1 1 1 1] normalize");
// use median of the 3x3 neighbourhood
//run("Median...", "radius=1");
if (bitDepth==24){
  selectWindow("pixels");
  run("RGB Color");
}
imageCalculator("AND create", "pixels","median");
imageCalculator("Subtract", "Denoised","pixels");
imageCalculator("Add", "Denoised","Result of pixels");
selectWindow("median");
close();
selectWindow("Result of pixels");
close();
selectWindow("pixels");
close();
setBatchMode(false);
////////////////////////////////////////////////////////////////////////////


C) 8 bit images only denoising 
////////////////////////////////////////////////////////////////////////////
// SaturatedPixelsDenoising.txt
// G. Landini 16/July/2005
// This macro detects saturated  pixels (8 connected) in the 
// image (grey=255) and replaces them with the pixel value of 
// the mean of the neighbours which are not saturated..
// Works with 8bit images only.
// Needs the BinaryConnectivity plugin available at: 
// http://www.dentistry.bham.ac.uk/landinig/software/software.html
t=getTitle();
if (bitDepth()==24){ 
  run("RGB Stack");
  setSlice(1);
  denoiser();
  selectWindow("Denoised");
  rename("red");
  selectWindow(t);
  setSlice(2);
  denoiser();
  selectWindow("Denoised");
  rename("green");
  selectWindow(t);
  setSlice(3);
  denoiser();
  selectWindow("Denoised");
  rename("blue");
  run("RGB Merge...", "red=red green=green blue=blue");
  rename("Denoised");
  selectWindow(t);
  run("RGB Color");
}
else {
  if (bitDepth()==8) denoiser();
}

function denoiser () {
  run("Duplicate...", "title=Denoised");
  setBatchMode(true);
  xe=getWidth();
  ye=getHeight();
  cycle=true;

  while (cycle){
    selectWindow("Denoised");   
    run("Duplicate...", "title=pixels");
    setThreshold(255, 255);
    run("Threshold", "thresholded remaining");
    selectWindow("Denoised");
    run("Duplicate...", "title=median");
    // use average of the 8 neighbours
    run("Convolve...", "text1=[1 1 1 1 0 1 1 1 1] normalize");
    imageCalculator("AND create", "pixels","median");
    imageCalculator("Subtract", "Denoised","pixels");
    imageCalculator("Add", "Denoised","Result of pixels");
    selectWindow("median");
    close();
    selectWindow("Result of pixels");
    close();
    selectWindow("pixels");
    run("BinaryConnectivity ", "white");
    cycle=false;

    for (x=0;x<xe;x++){
      for (y=0;y<ye;y++){
        n=getPixel(x,y);        
        if (n>1){
          if(n<9){
            selectWindow("Denoised");
            putPixel(x,y,(getPixel(x,y)*8 - ((n-1)*255))/(9-n));
            updateDisplay();    
            selectWindow("pixels");
          }
          else cycle=true;
        }
      }
    }
    selectWindow("pixels");
    close();
  }
  setBatchMode(false);
  updateDisplay();
}
////////////////////////////////////////////////////////////////////////////

Cheers,

Gabriel



Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
Search:
Java, servers, webhosting, windows, cisco ...
more...
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
encryption.gpg....    ietf.rfc822/199...    freebsd.devel.i...    lang.haskell.li...    mail.squirrelma...    web.zope.plone....    yellowdog.gener...    text.xml.xalan....    recreation.phot...    kde.devel.educa...    hardware.bus.ca...    printing.ghosts...    voip.peering/20...    assembly/2006-0...    org.user-groups...    culture.interne...    network.i2p/200...    boot-loaders.ya...    xfree86.render/...    qnx.openqnx.dev...    jakarta.velocit...    user-groups.pal...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe