Re: Background Subtraction: Coverting from Java to Matlab code



On Sep 25, 6:38 pm, Nathan <ngrec...@xxxxxxxxx> wrote:
I've been working (on and off) for months on a program and ways to
automate it as much as possible. What I need to do for better accuracy
when thresholding my images, is subtract the relatively noisy
background so the thresholding methods that I am using can catch all
of the particles I am looking for in my images. (Right now, the
methods either miss some or catch too much of the image).
The source code for such a method is open source from ImageJ. I have
used this method within ImageJ and it works wonderfully. My problem is
that I am trying to work entirely within Matlab for my procedures, and
do not know how to correctly covert the Java code to Matlab code.

Here's the link for the Java code:http://rsb.info.nih.gov/ij/developer/source/ij/plugin/filter/Backgrou...

Here's a link for what the code does (in wiki format):http://imagejdocu.tudor.lu/doku.php?id=gui:process:subtract_background

Looking over the FEX and through the newsgroup, I haven't found any
solutions to my problem. Some people have asked similar questions, but
no applicable solution has been found.

I've tried converting the applicable parts of the Java code to Matlab,
but I receive errors when trying to run it such as out of bound
indexing (probably due to the 0 and 1 based array differences, among
other things).

Here is a link to the code I've tried converting:http://docs.google.com/Doc?docid=0AakynObL-7fCZGhxajV2dDhfMjU3Z2ZtNnR...

Note: I did not convert classes and understand that the original code
also calls from libraries/packages that I do not know how to access
via matlab.

Here is an example image that I need to background subtract:http://lh3.ggpht.com/_-PiQE3WZBsQ/Sg3kTxC2HGI/AAAAAAAABLU/IsTMiEODHc4...

The differences in the background appear to be subtle, but they are
big enough that I need this background subtracting method (or
something similar, if anybody has an idea...)

I would appreciate any responses as well as help figuring this out.

-Nathan

----------------------------------------------------------------------------
Nathan:
I didn't look at your code, but this doesn't look like an image
(thanks for posting without being asked) that you'd want to do
background subtraction on (doesn't appear to be a radiograph) if you
want accuracy. It looks like a micrograph - transmitted light. For
these kinds of images you do background division. Think about the
math and you'll realize. If your corner has only 90% as many photons
as the center of your image, what would you want to do? Divide by
0.9? Of course. Now if you had x rays, you could do subtraction as
they do with Digital Subtraction Angiography. Subtraction is
appropriate there.

If you have a blank shot, with no particles, then I'd divide by that,
after some noise reduction of the blank shot first. If it's
impossible for you to get a blank shot for some reason, you'll have to
estimate the background from your sample image. You can try blurring
the image, using morphological operations, etc. You might have to do
it in two or more passes to get increasingly better estimates. Or you
could try modeling the background with a smooth function. Try to pick
training points from smooth areas (perhaps identified by a variance
filter or something like that), then fit some smooth function to it.
Maybe try interp2. Maybe John D'Errico will have some better ideas on
fitting a background to your training data picked from smooth areas.
He's very good on this subject. But once you have your background
estimate, by whatever method, then divide your sample image by it to
get a background-corrected image, then threshold, label, etc.
Regards,
ImageAnalyst
.



Relevant Pages

  • Re: background subtraction in x-rays
    ... i am working on MATLAB and am restricted to MATLAB as ... though background subtraction seems a very common topic ... image as my operating image which is a digital x-ray. ...
    (sci.image.processing)
  • Re: Vectorizing using arrayfun or feval?
    ... In Mathematica, this can be done in a single statement ... mathematica automatically vectorizes subtraction of a vector ... MATLAB seems to be a bit more explicit in this case, ...
    (comp.soft-sys.matlab)
  • Re: floating point calculation bug?
    ... Kyongje Sung wrote: ... I'm having a problem in doing simple addition and subtraction with ... floating numbers. ... It looks like MATLAB has a problem in dealing with decimal places. ...
    (comp.soft-sys.matlab)
  • floating point calculation bug?
    ... I'm having a problem in doing simple addition and subtraction with ... floating numbers. ... It looks like MATLAB has a problem in dealing with decimal places. ... I'm using Mac OS X (tiger) and MATLAB 7.1. ...
    (comp.soft-sys.matlab)

Loading