Login  Register

Re: Leveling Image

Posted by ashamim on Aug 24, 2011; 9:53am
URL: http://imagej.273.s1.nabble.com/Leveling-Image-tp3683357p3683359.html

Hello Gabriel And Michael

Thank you so much for your help and thanks for clarifying what difference does it make if I perform the line correction after the plane correction. I myself noticed that the only change comes in the mean value of the image and that might be because i was normalizing the image after subtracting the plane to get rid of the negative value. Other than that the images retains all its properties going any way around. Both the macro and the plugin are quiet useful for me. And subtracting the median line by line actually give me what I was looking for.

@ Michael Do u think there is some possible way to get rid of these steps from the base ? I mean so that they shouldn't even come from the AFM.

Regards
Ahsan


Gabriel Landini wrote
Here is the idea I was thinking of.
The first macro loads the Lena image and creates random offsets for the scan
lines to simulate a scan with artifacts.
//-----------8<---------------
run("Lena (68K)");
setBatchMode(true);
a="_test_";
run("Duplicate...", "title="+a);
run("8-bit");
run("Reslice [/]...", "output=1.000 start=Top");
selectWindow("Reslice of "+a);
for(i=1;i<=nSlices;i++){
  setSlice(i);
  r=random()*32;
  run("Add...", "value="+r+" slice");
}
run("Reslice [/]...", "output=1.000 start=Top");
setBatchMode(false);
//-----------8<---------------

This other macro creates a ROI over the more or less constant background (the
clear part on the left of the image) and compensates for a difference between
the average background and that of the individual lines.

//-----------8<---------------
makeRectangle(42, 0, 13, 512);// Lena's background
getRawStatistics(nPixels, mean);
run("Select None");
print(mean);
for (y=0;y<512;y++){
  tot=0;
  for (x=42;x<55;x++){
   tot=tot+getPixel(x,y);
  }
  tot=tot/13;
  offset=mean-tot;
  //print(offset);
  for (x=0;x<512;x++)
   putPixel(x, y, getPixel(x,y)+offset);
}
updateDisplay()
//-----------8<---------------

This works well if the background is constant. In the Lena image, the
background varies slightly so the result has a bright line relatively visible
because the background has a darker pixels in that particular region.

The problem is that the example given earlier does not have such a constant
background region for reference.
Cheers

Gabriel