applying a binary as a selection

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

applying a binary as a selection

michael shaffer
For a specific task, I want to survey the variety of automatic binary
thresholding techniques available for ImageJ (e.g., Otsu, maximum entropy,
...).  However, I first need to threshold regions that are both darker and
brighter (step#1, e.g., other phases and surface defects) than what is to be
exposed to the binary thresholding (step#2).

Presumably, what is selected with ImageJ is only what is available to the
binary thresholding.  However, I cannot find a way to apply the step#1
thresholding to step#2 (e.g., similar to copying a binary to a Photoshop
alpha channel).

Preliminary work with another software has revealed "minimum error"
thresholding (e.g., Kittler) seems to work best for my task.  I would like
to find this technique available as a ImageJ plug-in.  "Maximum entropy"
thresholding works well too, but I am finding the method described by
Shannon to work Better than Johannsen.  Is there a specific reference for
the maximum entropy method available for ImageJ?

My references to thresholding methods are in the following paper:

B. Sankur, M. Sezgin, A Survey Over Image Thresholding Techniques And
Quantitative Performance Evaluation
http://www.busim.ee.boun.edu.tr/~sankur/SankurFolder/Threshold_survey.pdf

TIA, Michael Shaffer  :o)

SEM/MLA Research Coordinator
     (709) 737-6799 (ofc)
     (709) 737-6790 (lab)
     (709) 737-6193 (FAX)
     http://www.mun.ca/creait/maf/
     http://www.esd.mun.ca/epma/ 

Inco Innovation Centre
c/o Memorial University
230 Elizabeth Avenue
P.O. Box 4200
St. John's, NL A1C 5S7
Reply | Threaded
Open this post in threaded view
|

Re: applying a binary as a selection

Gabriel Landini
On Saturday 08 April 2006 13:52, michael shaffer wrote:

> Presumably, what is selected with ImageJ is only what is available to the
> binary thresholding.  However, I cannot find a way to apply the step#1
> thresholding to step#2 (e.g., similar to copying a binary to a Photoshop
> alpha channel).

You can use a different image to store the result, or use an array, or even
convert the greyscale to rgb (witthout weighting) and use another plane for
storing the results.

> Preliminary work with another sof e has revealed "minimum error"
> thresholding (e.g., Kittler) seems to work best for my task.  I would like
> to find this technique available as a ImageJ plug-in.

This site has  some C code for the kittler algorithm.
http://emre.uta.edu/ImageProcessingComputerVisionSoftware.htm
It should be posible to convert it to Java.

> "Maximum entropy"
> thresholding works well too, but I am finding the method described by
> Shannon to work Better than Johannsen.  Is there a specific reference for
> the maximum entropy method available for ImageJ?

Ask Jarek Sacha, I think he wrote the plugin. Perhaps it is this one (also
code in the same site):
Kapur J.N., Sahoo P.K., and Wong A.K.C. (1985) "A New Method for Gray-level
Picture Thresholding Using the Entropy of the Histogram" Graphical Models and
Image Processing, 29: 273-285

I hope it helps.
Cheers,

G.
Reply | Threaded
Open this post in threaded view
|

Re: applying a binary as a selection

michael shaffer
 Gabriel Landini writes ...

> On Saturday 08 April 2006 13:52, michael shaffer wrote:
>
> > Presumably, what is selected with ImageJ is only what is
> > available to the binary thresholding.  However, I cannot
> > find a way to apply the step#1 thresholding to step#2
> > (e.g., similar to copying a binary to a Photoshop alpha
> > channel).
>
> You can use a different image to store the result, or use an
> array, or even convert the greyscale to rgb (witthout
> weighting) and use another plane for storing the results.

  Pardon my ignorance, but I fail to see how these methods would expose to
the binary thresholding ONLY selected pixels.  For example, other softwares
have demonstrated that simply converting non-selected pixels to black or
white biases the histogram the thresholding works with(?)

  Thank you for your other references  :o)

Genuinely, Michael Shaffer  :o)

SEM/MLA Research Coordinator
     (709) 737-6799 (ofc)
     (709) 737-6790 (lab)
     (709) 737-6193 (FAX)
     http://www.mun.ca/creait/maf/
     http://www.esd.mun.ca/epma/ 

Inco Innovation Centre
c/o Memorial University
230 Elizabeth Avenue
P.O. Box 4200
St. John's, NL A1C 5S7



>
> > Preliminary work with another sof e has revealed "minimum error"
> > thresholding (e.g., Kittler) seems to work best for my
> task.  I would
> > like to find this technique available as a ImageJ plug-in.
>
> This site has  some C code for the kittler algorithm.
> http://emre.uta.edu/ImageProcessingComputerVisionSoftware.htm
> It should be posible to convert it to Java.
>
> > "Maximum entropy"
> > thresholding works well too, but I am finding the method
> described by
> > Shannon to work Better than Johannsen.  Is there a specific
> reference
> > for the maximum entropy method available for ImageJ?
>
> Ask Jarek Sacha, I think he wrote the plugin. Perhaps it is
> this one (also code in the same site):
> Kapur J.N., Sahoo P.K., and Wong A.K.C. (1985) "A New Method
> for Gray-level Picture Thresholding Using the Entropy of the
> Histogram" Graphical Models and Image Processing, 29: 273-285
>
> I hope it helps.
> Cheers,
>
> G.
>
> __________ NOD32 1.1477 (20060408) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.eset.com
>
>
Reply | Threaded
Open this post in threaded view
|

Re: applying a binary as a selection

Gabriel Landini
On Sunday 09 April 2006 12:23, michael shaffer wrote:
>   Pardon my ignorance, but I fail to see how these methods would expose to
> the binary thresholding ONLY selected pixels.  For example, other softwares
> have demonstrated that simply converting non-selected pixels to black or
> white biases the histogram the thresholding works with(?)

I probably misunderstood what you want to do.
Can you explain a bit better what do you mean by:

> However, I first need to threshold regions that are both darker and
> brighter (step#1, e.g., other phases and surface defects) than what is to be
> exposed to the binary thresholding (step#2).

Is it "masking"?
I do not think that IJ can do that straight away for thresholding (please
correct me if I am wrong).  

You can, however, divide the procedure into:
(assume white is "yes", black is "no")
threshold regions which are darker, save it to an image
threshold regions which are brighter, save it to another image

then:
darker ADD (or OR) brighter = regions which are brighter or darker.

and subtract it from the original image (so you are left with the areas which
are not-brighter-or-darker, i.e. the non-zero areas)

Now you want to threshold this result. Depending on the histogram method, you
may have to force the thresholding procedure to ignore the black pixels. (You
will have to include this in the code yourself).

BTW, this would be a handy option to have in the built-in threshold plugin
(Ignore black, and Ignore white check boxes which just set to 0 the histo[0]
and histo[255] before submitting the histogram to the thresholding routine.

I hope it helps,

G.
Reply | Threaded
Open this post in threaded view
|

Antwort: Re: applying a binary as a selection

Joachim Wesner
Hi,

I think what he is looking for, expressed in the most general way, would be
the possibilty to:

1) Generate a ROI mask from a binary image (this two-level image created
from any input image, using any algorithm that might create a two level
result)

2) Have the possibilty to apply/copy this mask to another image for use
with any arbitray analysis (The initial image contents in 1) and 2) might
be the same, but need not)

So basically a binary image -> ROI mask plugin, prcatically the opposite of
the "Edit/Selection/Create Mask", which converts a ROI to a black and white
image.

Joachim




                                                                                                                                       
                      Gabriel Landini                                                                                                  
                      <G.Landini@BHAM.         An:      [hidden email]                                                            
                      AC.UK>                   Kopie:   (Blindkopie: Joachim Wesner/DEWET/LMSCentral/Leica)                            
                      Gesendet von:            Thema:   Re: applying a binary as a selection                                          
                      ImageJ Interest                                                                                                  
                      Group                                                                                                            
                      <[hidden email]                                                                                                
                      .GOV>                                                                                                            
                                                                                                                                       
                                                                                                                                       
                      09.04.2006 14:13                                                                                                
                      Bitte antworten                                                                                                  
                      an ImageJ                                                                                                        
                      Interest Group                                                                                                  
                                                                                                                                       




On Sunday 09 April 2006 12:23, michael shaffer wrote:
>   Pardon my ignorance, but I fail to see how these methods would expose
to
> the binary thresholding ONLY selected pixels.  For example, other
softwares
> have demonstrated that simply converting non-selected pixels to black or
> white biases the histogram the thresholding works with(?)

I probably misunderstood what you want to do.
Can you explain a bit better what do you mean by:

> However, I first need to threshold regions that are both darker and
> brighter (step#1, e.g., other phases and surface defects) than what is to
be
> exposed to the binary thresholding (step#2).

Is it "masking"?
I do not think that IJ can do that straight away for thresholding (please
correct me if I am wrong).

You can, however, divide the procedure into:
(assume white is "yes", black is "no")
threshold regions which are darker, save it to an image
threshold regions which are brighter, save it to another image

then:
darker ADD (or OR) brighter = regions which are brighter or darker.

and subtract it from the original image (so you are left with the areas
which
are not-brighter-or-darker, i.e. the non-zero areas)

Now you want to threshold this result. Depending on the histogram method,
you
may have to force the thresholding procedure to ignore the black pixels.
(You
will have to include this in the code yourself).

BTW, this would be a handy option to have in the built-in threshold plugin
(Ignore black, and Ignore white check boxes which just set to 0 the
histo[0]
and histo[255] before submitting the histogram to the thresholding routine.

I hope it helps,

G.



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

Re: applying a binary as a selection

Gabriel Landini
In reply to this post by michael shaffer
Joachim Wesner wrote:

> 1) Generate a ROI mask from a binary image (this two-level image created
> from any input image, using any algorithm that might create a two level
> result)

One can already generate ROIs from binary objects (setting a threshold and
using the wand, or by extracting -with a macro- the starts of all the binary
objects and "wand" them in a loop).

The only problem is that for those ROIs, any holes will be processed as part
of the image. That is why I suggested to ignore one of the extremes of the
histogram.
I just tested, and the autothreshold procedure in IJ acts on ROIs if these
exist. The problem would be to make sure that all other thresholding plugins
do the same.

Cheers,

G.
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: Re: applying a binary as a selection

michael shaffer
In reply to this post by Joachim Wesner
 Joachim Wesner writes ...

> I think what he is looking for, expressed in the most general
> way, would be the possibility to:
>
> 1) Generate a ROI mask from a binary image (this two-level
> image created from any input image, using any algorithm that
> might create a two level result)
>
> 2) Have the possibility to apply/copy this mask to another
> image for use with any arbitrary analysis (The initial image
> contents in 1) and 2) might be the same, but need not)
>
> So basically a binary image -> ROI mask plugin, practically
> the opposite of the "Edit/Selection/Create Mask", which
> converts a ROI to a black and white image.

  That's pretty much it.  I'm a bit surprised this capability isn't in
ImageJ(?), and was sure I was asking a stupid question.  Given the following
task, let me ask if there isn't a different way ...

  Suppose I have an image that contains regions of 6 brightness levels
(including detector noise). But I am only interested in 2 phases that are
very close in brightness.  Furthermore, a number of bi-level thresholding
algorithms might work with separating these 2 important phases, so the
problem is to remove everything else and allow the bi-level thresholding to
"see" only the pixel values of concern.  What is more, I need to process
many of these images and a macro is therefore necessary.

  Am I correct is assuming the thresholding plug-in will work only with
pixels within a ROI?  If so, I then only need a versatile method of creating
this ROI.

  Thanx for your responses ...

michael shaffer  :o)

> On Sunday 09 April 2006 12:23, michael shaffer wrote:
> >   Pardon my ignorance, but I fail to see how these methods would
> > expose
> to
> > the binary thresholding ONLY selected pixels.  For example, other
> softwares
> > have demonstrated that simply converting non-selected
> pixels to black
> > or white biases the histogram the thresholding works with(?)
>
> I probably misunderstood what you want to do.
> Can you explain a bit better what do you mean by:
>
> > However, I first need to threshold regions that are both darker and
> > brighter (step#1, e.g., other phases and surface defects)
> than what is
> > to
> be
> > exposed to the binary thresholding (step#2).
>
> Is it "masking"?
> I do not think that IJ can do that straight away for
> thresholding (please correct me if I am wrong).
>
> You can, however, divide the procedure into:
> (assume white is "yes", black is "no")
> threshold regions which are darker, save it to an image
> threshold regions which are brighter, save it to another image
>
> then:
> darker ADD (or OR) brighter = regions which are brighter or darker.
>
> and subtract it from the original image (so you are left with
> the areas which are not-brighter-or-darker, i.e. the non-zero areas)
>
> Now you want to threshold this result. Depending on the
> histogram method, you may have to force the thresholding
> procedure to ignore the black pixels.
> (You
> will have to include this in the code yourself).
>
> BTW, this would be a handy option to have in the built-in
> threshold plugin (Ignore black, and Ignore white check boxes
> which just set to 0 the histo[0] and histo[255] before
> submitting the histogram to the thresholding routine.
>
> I hope it helps,
>
> G.
>
>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit
> http://www.messagelabs.com/email 
> ______________________________________________________________________
>
> __________ NOD32 1.1478 (20060409) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.eset.com
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: Re: applying a binary as a selection

Martin du Saire
If I understood correctly, you can create a composite ROI Mask as follows:

run("Set Measurements...", "area redirect=None decimal=3");
run("Analyze Particles...", "minimum=200 maximum=307201
circularity=0.0-1.0 show=Nothing record clear");
setKeyDown("shift");
for (i=0; i<nResults; i++) {
      x = getResult('XStart', i);
      y = getResult('YStart', i);
      doWand(x,y);
}
run("Selection...", "path="+path+"compositeMask.roi");
setKeyDown("none");

Then you can "apply" the ROI to any image by:

selectImage(workingImage);
open(path+"compositeMask.roi");

I think that when I fist wrote the macro, run("Restore Selection");
didn't give me the desired result in BatchMode, but that may have
changed since then.

Is this what you needed?

Martin

At 12:20 PM 4/9/2006, you wrote:

>  Joachim Wesner writes ...
>
> > I think what he is looking for, expressed in the most general
> > way, would be the possibility to:
> >
> > 1) Generate a ROI mask from a binary image (this two-level
> > image created from any input image, using any algorithm that
> > might create a two level result)
> >
> > 2) Have the possibility to apply/copy this mask to another
> > image for use with any arbitrary analysis (The initial image
> > contents in 1) and 2) might be the same, but need not)
> >
> > So basically a binary image -> ROI mask plugin, practically
> > the opposite of the "Edit/Selection/Create Mask", which
> > converts a ROI to a black and white image.
>
>   That's pretty much it.  I'm a bit surprised this capability isn't in
>ImageJ(?), and was sure I was asking a stupid question.  Given the following
>task, let me ask if there isn't a different way ...
>
>   Suppose I have an image that contains regions of 6 brightness levels
>(including detector noise). But I am only interested in 2 phases that are
>very close in brightness.  Furthermore, a number of bi-level thresholding
>algorithms might work with separating these 2 important phases, so the
>problem is to remove everything else and allow the bi-level thresholding to
>"see" only the pixel values of concern.  What is more, I need to process
>many of these images and a macro is therefore necessary.
>
>   Am I correct is assuming the thresholding plug-in will work only with
>pixels within a ROI?  If so, I then only need a versatile method of creating
>this ROI.
>
>   Thanx for your responses ...
>
>michael shaffer  :o)
>
> > On Sunday 09 April 2006 12:23, michael shaffer wrote:
> > >   Pardon my ignorance, but I fail to see how these methods would
> > > expose
> > to
> > > the binary thresholding ONLY selected pixels.  For example, other
> > softwares
> > > have demonstrated that simply converting non-selected
> > pixels to black
> > > or white biases the histogram the thresholding works with(?)
> >
> > I probably misunderstood what you want to do.
> > Can you explain a bit better what do you mean by:
> >
> > > However, I first need to threshold regions that are both darker and
> > > brighter (step#1, e.g., other phases and surface defects)
> > than what is
> > > to
> > be
> > > exposed to the binary thresholding (step#2).
> >
> > Is it "masking"?
> > I do not think that IJ can do that straight away for
> > thresholding (please correct me if I am wrong).
> >
> > You can, however, divide the procedure into:
> > (assume white is "yes", black is "no")
> > threshold regions which are darker, save it to an image
> > threshold regions which are brighter, save it to another image
> >
> > then:
> > darker ADD (or OR) brighter = regions which are brighter or darker.
> >
> > and subtract it from the original image (so you are left with
> > the areas which are not-brighter-or-darker, i.e. the non-zero areas)
> >
> > Now you want to threshold this result. Depending on the
> > histogram method, you may have to force the thresholding
> > procedure to ignore the black pixels.
> > (You
> > will have to include this in the code yourself).
> >
> > BTW, this would be a handy option to have in the built-in
> > threshold plugin (Ignore black, and Ignore white check boxes
> > which just set to 0 the histo[0] and histo[255] before
> > submitting the histogram to the thresholding routine.
> >
> > I hope it helps,
> >
> > G.
> >
> >
> >
> > ______________________________________________________________________
> > This email has been scanned by the MessageLabs Email Security System.
> > For more information please visit
> > http://www.messagelabs.com/email
> > ______________________________________________________________________
> >
> > __________ NOD32 1.1478 (20060409) Information __________
> >
> > This message was checked by NOD32 antivirus system.
> > http://www.eset.com
> >
> >