[Insight-users] Clear image borders

Miller, James V (Research) millerjv at crd.ge.com
Tue, 30 Mar 2004 11:35:38 -0500


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C41674.79312F4A
Content-Type: text/plain;
	charset="iso-8859-1"

David, 
 
I checked in a new test that illustrates how to remove objects that touch
the boundaries.
 
Insight/Testing/Code/BasicFilters/itkRemoveBoundaryObjectsTest.cxx
 
It operates on the input image Insight/Testing/Data/Input/Spots.png and
produces the output
Insight/Testing/Data/Baseline/BasicFilters/RemoveBoundaryObjectsTest.png
 
I added a "Not" filter to ITK to simplify the test,
Insight/Code/BasicFilters/itkNotImageFilter.h
 
The test reads the input, runs the fill hole algorithm to fill in the dark
spots that are not connected to the boundary, xors the result with the
original image, and nots that result.  This may work for your application if
your spots are dark on a light background (you can invert the intensities to
get this if you need to).
 
Jim

-----Original Message-----
From: Miller, James V (Research) [mailto:millerjv at crd.ge.com]
Sent: Monday, March 29, 2004 3:07 PM
To: 'David Llanos'; insight-users at itk.org; Luis Ibanez (ITK); Julien
Subject: RE: [Insight-users] Clear image borders


David, 
 
There are some geodesic morphology techniques that will eliminate the
foreground objects that touch the borders of the image. The book
 
Pierre Soille. "Morphological Image Analysis: Principles and Applications",
Second Edition, Springer, 2003.
 
describes a number of geodesic morphology algorithms. ITK has several of
these algorithms:
 
GrayscaleGeodesicErodeImageFilter
GrayscaleGeodesicDilateImageFilter
GrayscaleFillholeImageFilter
GrayscaleConnectedOpeningImageFilter
GrayscaleConnectedClosingImageFilter
 
 
The Fillhole algorithm removes all local minima that are not connected to
the boundary.  In your case, you could flip the intensities of your
processed image (so the sperm are black on white).  Running the
GrayscaleGeodesicFillholeImageFilter will remove any of the sperm that are
not connected to the boundary.  So this will be a mask of the objects that
are connected to the boundary.  If you xor the input to the
GrayscaleGeodesicFillholeImageFilter with its output, you should be left
with the objects that do not touch the border.
 
Jim

-----Original Message-----
From: David Llanos [mailto:gva02 at elai.upm.es]
Sent: Monday, March 29, 2004 10:58 AM
To: insight-users at itk.org; Luis Ibanez (ITK); Julien
Subject: [Insight-users] Clear image borders



 
Hi all,
 
I am working in a project where I carry out processing of sperm. For they
give me to it pictures and I have to return characteristic as density, radio
of the halo, radio of the core, etc.. The problem this in that in the
pictures some sperms come cut, and these they should be eliminated.  
  
I wonder if in ITK some class exists with the one that can eliminate parts
of an image, in short those that are cut by the border of the image.  
  
To clarify my problem I attach you three images:
 
1. - original.jpg           The original image    
2. - process.jpg         The processing image    
3. - clearborder.jpg     The image without cut sperms  
 
 
 
Thanks in advange and regards.
 
David.
 
 
----------------------------------------------------------------------------
--------------------------------------------------------------------------
NOTA: in MATLAB the procedure that makes this function is "imgclearborder",
I attach you the example:
 
imgEspermasRGB = imread ( NomFichImg );
hist = imhist(imgEspermasRGB(:,:,2)); %Componente del verde
umbralEspermas =
BIN_EntropiaKSW(hist,size(imgEspermasRGB,1)*size(imgEspermasRGB,2)); 
seEspermas = strel('disk',20);
imgEsperBW = imclearborder(...
 
imopen((imgEspermasRGB(:,:,2)<umbralEspermas),seEspermas));
----------------------------------------------------------------------------
--------------------------------------------------------------------------
 
PD: if it interests you to some I send you the function BIN_EntropiaKSW,
necessary to run the application, in MATLAB or in C


------_=_NextPart_001_01C41674.79312F4A
Content-Type: text/html;
	charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 6.00.2800.1276" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><SPAN class=385373116-30032004><FONT color=#0000ff size=2>David, 
</FONT></SPAN></DIV>
<DIV><SPAN class=385373116-30032004><FONT color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=385373116-30032004><FONT color=#0000ff size=2>I checked in a 
new test that illustrates how to remove objects that touch the 
boundaries.</FONT></SPAN></DIV>
<DIV><SPAN class=385373116-30032004><FONT color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=385373116-30032004><FONT color=#0000ff 
size=2>Insight/Testing/Code/BasicFilters/itkRemoveBoundaryObjectsTest.cxx</FONT></SPAN></DIV>
<DIV><SPAN class=385373116-30032004><FONT color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=385373116-30032004><FONT color=#0000ff size=2>It operates on 
the input image Insight/Testing/Data/Input/Spots.png and produces the output 
Insight/Testing/Data/Baseline/BasicFilters/RemoveBoundaryObjectsTest.png</FONT></SPAN></DIV>
<DIV><SPAN class=385373116-30032004><FONT color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=385373116-30032004><FONT color=#0000ff size=2>I added a "Not" 
filter to ITK to simplify the test, 
Insight/Code/BasicFilters/itkNotImageFilter.h</FONT></SPAN></DIV>
<DIV><SPAN class=385373116-30032004><FONT color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=385373116-30032004><FONT color=#0000ff size=2>The test reads 
the input, runs the fill hole algorithm to fill in the dark spots that are not 
connected to the boundary, xors the result with the original image, and nots 
that result.&nbsp; This may work for your application if your spots are dark on 
a light background (you can invert the intensities to get this if you need 
to).</FONT></SPAN></DIV>
<DIV><SPAN class=385373116-30032004><FONT color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=385373116-30032004><FONT color=#0000ff 
size=2>Jim</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
  size=2>-----Original Message-----<BR><B>From:</B> Miller, James V (Research) 
  [mailto:millerjv at crd.ge.com]<BR><B>Sent:</B> Monday, March 29, 2004 3:07 
  PM<BR><B>To:</B> 'David Llanos'; insight-users at itk.org; Luis Ibanez (ITK); 
  Julien<BR><B>Subject:</B> RE: [Insight-users] Clear image 
  borders<BR><BR></FONT></DIV>
  <DIV><SPAN class=064065319-29032004><FONT color=#0000ff size=2>David, 
  </FONT></SPAN></DIV>
  <DIV><SPAN class=064065319-29032004><FONT color=#0000ff 
  size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=064065319-29032004><FONT color=#0000ff size=2>There are some 
  geodesic morphology techniques that will eliminate the foreground objects that 
  touch the borders of the image.&nbsp;The book</FONT></SPAN></DIV>
  <DIV><SPAN class=064065319-29032004><FONT color=#0000ff 
  size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=064065319-29032004><FONT color=#0000ff size=2>Pierre Soille. 
  "Morphological Image Analysis: Principles and Applications",&nbsp;Second 
  Edition, Springer, 2003.</FONT></SPAN></DIV>
  <DIV><SPAN class=064065319-29032004><FONT color=#0000ff 
  size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=064065319-29032004><FONT color=#0000ff size=2>describes a 
  number of geodesic morphology algorithms. ITK has several of these 
  algorithms:</FONT></SPAN></DIV>
  <DIV><SPAN class=064065319-29032004><FONT color=#0000ff 
  size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=064065319-29032004><FONT color=#0000ff 
  size=2>GrayscaleGeodesicErodeImageFilter</FONT></SPAN></DIV>
  <DIV><SPAN class=064065319-29032004><FONT color=#0000ff 
  size=2>GrayscaleGeodesicDilateImageFilter</FONT></SPAN></DIV>
  <DIV><SPAN class=064065319-29032004><FONT color=#0000ff 
  size=2>GrayscaleFillholeImageFilter</FONT></SPAN></DIV>
  <DIV><SPAN class=064065319-29032004><FONT color=#0000ff 
  size=2>GrayscaleConnectedOpeningImageFilter</FONT></SPAN></DIV>
  <DIV><SPAN class=064065319-29032004><FONT color=#0000ff 
  size=2>GrayscaleConnectedClosingImageFilter</FONT></SPAN></DIV>
  <DIV><SPAN class=064065319-29032004><FONT color=#0000ff 
  size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=064065319-29032004><FONT color=#0000ff 
  size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=064065319-29032004><FONT color=#0000ff size=2>The Fillhole 
  algorithm removes all local minima that are not connected to the 
  boundary.&nbsp; In your case, you could flip the intensities of your processed 
  image (so the sperm are black on white).&nbsp; Running the 
  GrayscaleGeodesicFillholeImageFilter will remove any of the sperm that are not 
  connected to the boundary.&nbsp; So this will be a mask of the objects that 
  are connected to the boundary.&nbsp; If you xor the input to the 
  GrayscaleGeodesicFillholeImageFilter with its output, you should be left with 
  the objects that do not touch the border.</FONT></SPAN></DIV>
  <DIV><SPAN class=064065319-29032004><FONT color=#0000ff 
  size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=064065319-29032004><FONT color=#0000ff 
  size=2>Jim</FONT></SPAN></DIV>
  <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
    <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
    size=2>-----Original Message-----<BR><B>From:</B> David Llanos 
    [mailto:gva02 at elai.upm.es]<BR><B>Sent:</B> Monday, March 29, 2004 10:58 
    AM<BR><B>To:</B> insight-users at itk.org; Luis Ibanez (ITK); 
    Julien<BR><B>Subject:</B> [Insight-users] Clear image 
    borders<BR><BR></FONT></DIV>
    <DIV><BR>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>Hi all,</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>I am working in a project where I carry out 
    processing of sperm. For they give me to it pictures and I have to return 
    characteristic as density, radio of the halo, radio of the core, etc.. The 
    problem this in that in the pictures some sperms come cut, and these they 
    should be eliminated.&nbsp; <BR>&nbsp; <BR>I wonder if in ITK some class 
    exists with the one that can eliminate parts of an image, in short those 
    that are cut by the border of the image.&nbsp; <BR>&nbsp; <BR>To clarify my 
    problem I attach you three images:</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>1. - original.jpg 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; The original 
    image&nbsp;&nbsp;&nbsp; <BR>2. - 
    process.jpg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The processing 
    image&nbsp;&nbsp;&nbsp; <BR>3. - 
    clearborder.jpg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The image without cut 
    sperms&nbsp; </FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>Thanks in advange and regards.</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>David.</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial 
    size=2>------------------------------------------------------------------------------------------------------------------------------------------------------</FONT></DIV>
    <DIV><FONT face=Arial size=2>NOTA: in MATLAB the procedure that makes this 
    function is "imgclearborder", I attach you the example:</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>imgEspermasRGB = imread ( NomFichImg 
    );</FONT><FONT face=Arial size=2><BR>hist = imhist(imgEspermasRGB(:,:,2)); 
    %Componente del verde<BR>umbralEspermas = 
    BIN_EntropiaKSW(hist,size(imgEspermasRGB,1)*size(imgEspermasRGB,2)); 
    </FONT></DIV>
    <DIV><FONT face=Arial size=2>seEspermas = strel('disk',20);</DIV>
    <DIV>imgEsperBW = 
    imclearborder(...<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    imopen((imgEspermasRGB(:,:,2)&lt;umbralEspermas),seEspermas));</DIV>
    <DIV>------------------------------------------------------------------------------------------------------------------------------------------------------</DIV>
    <DIV>&nbsp;</DIV>
    <DIV>PD: if it interests you to some I send you the function 
    BIN_EntropiaKSW, necessary to run the application, in MATLAB or in 
    C</FONT></DIV></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------_=_NextPart_001_01C41674.79312F4A--