User:Oleg Kobchenko/Background Removal

From J Wiki
Jump to navigation Jump to search
Unshadow.jpg
   load'media/platimg'               NB. image reader
   load'viewmat plot'
                                     NB. gray scale viewer
   viewgray=: (16b010101*i.256)&viewmat
   glwh=: 3 : 'wd''pmovex '',(+0 0,y-glqwh_jgl2_@$@#)&.".wd''qformx'''
   viewwh=: glwh@|.@$ [ viewgray

   $M=. 16bff (17 b.) readimg jpath'~temp\input.jpg'
1200 1600
   viewwh M

   $R=: |:_5(+/%#)\|: _5(+/%#)\ M    NB. reduced large image
240 320
   viewwh R
   'surface;mesh 0' plot R           NB. notice features below smooth light

   S=:  |: _10(>./)\|:  _10(>./)\ M  NB. so apply max filter to remove features

   Z=: 2#"1]2#S                      NB. restore size
   W=: |:8 (+/%#)\|:8 (+/%#)\ Z      NB. smooth with moving average
   viewwh W

   viewwh N=: (($W){.R) - W          NB. remove shadow

Polynomial surface subtraction

IGOR Pro from WaveMetrics suggests such background removal

  • manually selecting point using ROI (region of interest) tool
  • interpolate polynomial fit into point
  • subtract polynomial

Wavemetrics.png

Background could additive (for subtraction removal) or multiplicative (for division).

Removing Averages

Ebsd.png

Procedure for Electron Backscatter Diffraction (EBSD) of Oxford Instruments suggests that "the background can be measured by scanning the beam over many grains in the sample to average out the diffraction information. The background can be removed by subtraction from, or division into, the original pattern".

ImageJ Plugins

A number of ImageJ pluggins provide background correction.

Imagej.png

Base system itself has built-in support for subtracting background.