Discussion:
Edge Enhancement
Sidnei Paciornik
2013-06-22 02:27:40 UTC
Permalink
Dear colleagues,

A simple need, but I could not find the right solution in ImageJ. I am
sorry if it is obvious.

Is there a filter to increase edge sharpness and reduce the effect known as
"halo effect" in optical microscopy?

At the edges of bright objects and a dark background (or vice-versa) there
are normally pixels with intermediate pixel values. If other objects in the
image have these pixel values, when they are segmented the edges of bright
objects will also appear.

Even though these fake edges can be corrected by a morphological open, it
is normally better to pre-process the image with an edge enhancement filter
(some times called delineate) to increase the edge sharpness and reduce the
amount of intermediate pixels.

Any hints?

Thank you!

Prof. Sidnei Paciornik
Grupo de Análise de Imagens e Microscopia Digital
DEMa <http://www.dema.puc-rio.br/> - Departamento de Engenharia de Materiais
PUC-Rio <http://www.puc-rio.br/>
Rua Marquês de São Vicente 225
Prédio Leme, Sala 501L
Gávea - Rio de Janeiro - RJ
22451-900 - Brasil
tel: (55)(21)3527-1243

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Jan Brocher - BioVoxxel
2013-06-22 07:23:46 UTC
Permalink
Hi Sidnei,

There is a plugin called Image Edges from Thomas Boudier (I think it is not included in Fiji by default but available on the following site: http://imagejdocu.tudor.lu/doku.php?id=plugin:filter:edge_detection:start).
Another possibility would be the "Edges" in FeatureJ from Eric Meijering which enables you to suppress "halo" effects. To my knowledge both plugins apply Canny edge detection based algorithms.

regards,
Jan

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Sidnei Paciornik
2013-06-22 14:50:55 UTC
Permalink
Hi Jan
I guess this is not quite the answer. I don't need edge detection, but
edge enhancement. I couldn't figure how either of your hints would do it.
The algorithm should be simple. Take a neighborhood, calculate min, max,
and range R.
Pick a threshold T.
If T>R it is not an edge, keep input pixel.
Else exchange pixel with max or min.

I just don't know how to program it.
Any other hints?
Thank you.
Post by Jan Brocher - BioVoxxel
Hi Sidnei,
There is a plugin called Image Edges from Thomas Boudier (I think it is
http://imagejdocu.tudor.lu/doku.php?id=plugin:filter:edge_detection:start
).
Another possibility would be the "Edges" in FeatureJ from Eric Meijering
which enables you to suppress "halo" effects. To my knowledge both plugins
apply Canny edge detection based algorithms.
regards,
Jan
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
BioVoxxel
2013-06-23 08:25:49 UTC
Permalink
Hi Sidnei,

I am not sure if this will be a solution you are looking for, but have you
considered unsharp masking (>Process > Filters > Unsharp Mask...).
Another possibility might be the "Contrast Detection from the BioVoxxel
Toolbox if you tick the option "enhance edges in original". This method
applied grayscale erosion and dilation to enhance edges and thereny might
lead to stronger edge enhancement than the unsharp mask but can also induce
artifacts if overdone.

kind regards,
Jan
Post by Sidnei Paciornik
Hi Jan
I guess this is not quite the answer. I don't need edge detection, but
edge enhancement. I couldn't figure how either of your hints would do it.
The algorithm should be simple. Take a neighborhood, calculate min, max,
and range R.
Pick a threshold T.
If T>R it is not an edge, keep input pixel.
Else exchange pixel with max or min.
I just don't know how to program it.
Any other hints?
Thank you.
Post by Jan Brocher - BioVoxxel
Hi Sidnei,
There is a plugin called Image Edges from Thomas Boudier (I think it is
http://imagejdocu.tudor.lu/doku.php?id=plugin:filter:edge_detection:start
).
Another possibility would be the "Edges" in FeatureJ from Eric Meijering
which enables you to suppress "halo" effects. To my knowledge both plugins
apply Canny edge detection based algorithms.
regards,
Jan
--
CEO: Dr. rer. nat. Jan Brocher
phone: +49 (0)6234 917 03 39
mobile: +49 (0)176 705 746 81
e-mail: jan.brocher-u5+***@public.gmane.org
info: info-u5+***@public.gmane.org
inquiries: inquiry-u5+***@public.gmane.org
web: www.biovoxxel.de

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Sidnei Paciornik
2013-06-23 19:11:30 UTC
Permalink
Hi Jan,

Thanks again for the hints, which I did test.

I guess the main drawaback is that these approaches tend to increase high
frequency and contrast everywhere, not only at edges. They give me part of
the improvemente I wanted, but also increasing noise within objects.

Let us see if some other colleague can add to the discussion.

Thank you!

Sidnei
Post by Jan Brocher - BioVoxxel
Hi Sidnei,
I am not sure if this will be a solution you are looking for, but have you
considered unsharp masking (>Process > Filters > Unsharp Mask...).
Another possibility might be the "Contrast Detection from the BioVoxxel
Toolbox if you tick the option "enhance edges in original". This method
applied grayscale erosion and dilation to enhance edges and thereny might
lead to stronger edge enhancement than the unsharp mask but can also induce
artifacts if overdone.
kind regards,
Jan
Post by Sidnei Paciornik
Hi Jan
I guess this is not quite the answer. I don't need edge detection, but
edge enhancement. I couldn't figure how either of your hints would do it.
The algorithm should be simple. Take a neighborhood, calculate min, max,
and range R.
Pick a threshold T.
If T>R it is not an edge, keep input pixel.
Else exchange pixel with max or min.
I just don't know how to program it.
Any other hints?
Thank you.
Post by Jan Brocher - BioVoxxel
Hi Sidnei,
There is a plugin called Image Edges from Thomas Boudier (I think it is
http://imagejdocu.tudor.lu/doku.php?id=plugin:filter:edge_detection:start
).
Another possibility would be the "Edges" in FeatureJ from Eric Meijering
which enables you to suppress "halo" effects. To my knowledge both plugins
apply Canny edge detection based algorithms.
regards,
Jan
--
CEO: Dr. rer. nat. Jan Brocher
phone: +49 (0)6234 917 03 39
mobile: +49 (0)176 705 746 81
web: www.biovoxxel.de
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Ben Tupper
2013-06-23 23:11:04 UTC
Permalink
Hi,
Post by Sidnei Paciornik
Hi Jan,
Thanks again for the hints, which I did test.
I guess the main drawaback is that these approaches tend to increase high
frequency and contrast everywhere, not only at edges. They give me part of
the improvemente I wanted, but also increasing noise within objects.
Let us see if some other colleague can add to the discussion.
Can you post a small example in a public place so we can see what you are describing?

Thanks,
Ben
Post by Sidnei Paciornik
Thank you!
Sidnei
Post by Jan Brocher - BioVoxxel
Hi Sidnei,
I am not sure if this will be a solution you are looking for, but have you
considered unsharp masking (>Process > Filters > Unsharp Mask...).
Another possibility might be the "Contrast Detection from the BioVoxxel
Toolbox if you tick the option "enhance edges in original". This method
applied grayscale erosion and dilation to enhance edges and thereny might
lead to stronger edge enhancement than the unsharp mask but can also induce
artifacts if overdone.
kind regards,
Jan
Post by Sidnei Paciornik
Hi Jan
I guess this is not quite the answer. I don't need edge detection, but
edge enhancement. I couldn't figure how either of your hints would do it.
The algorithm should be simple. Take a neighborhood, calculate min, max,
and range R.
Pick a threshold T.
If T>R it is not an edge, keep input pixel.
Else exchange pixel with max or min.
I just don't know how to program it.
Any other hints?
Thank you.
Post by Jan Brocher - BioVoxxel
Hi Sidnei,
There is a plugin called Image Edges from Thomas Boudier (I think it is
http://imagejdocu.tudor.lu/doku.php?id=plugin:filter:edge_detection:start
).
Another possibility would be the "Edges" in FeatureJ from Eric Meijering
which enables you to suppress "halo" effects. To my knowledge both plugins
apply Canny edge detection based algorithms.
regards,
Jan
--
CEO: Dr. rer. nat. Jan Brocher
phone: +49 (0)6234 917 03 39
mobile: +49 (0)176 705 746 81
web: www.biovoxxel.de
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Sidnei Paciornik
2013-06-24 02:14:08 UTC
Permalink
Hi Ben

Here is a link to a pdf that explains the point.

https://dl.dropboxusercontent.com/u/20667937/Halo%20effect.pdf

Regards,

Sidnei
Post by Ben Tupper
Hi,
Post by Sidnei Paciornik
Hi Jan,
Thanks again for the hints, which I did test.
I guess the main drawaback is that these approaches tend to increase high
frequency and contrast everywhere, not only at edges. They give me part
of
Post by Sidnei Paciornik
the improvemente I wanted, but also increasing noise within objects.
Let us see if some other colleague can add to the discussion.
Can you post a small example in a public place so we can see what you are describing?
Thanks,
Ben
Post by Sidnei Paciornik
Thank you!
Sidnei
Post by Jan Brocher - BioVoxxel
Hi Sidnei,
I am not sure if this will be a solution you are looking for, but have
you
Post by Sidnei Paciornik
Post by Jan Brocher - BioVoxxel
considered unsharp masking (>Process > Filters > Unsharp Mask...).
Another possibility might be the "Contrast Detection from the BioVoxxel
Toolbox if you tick the option "enhance edges in original". This method
applied grayscale erosion and dilation to enhance edges and thereny
might
Post by Sidnei Paciornik
Post by Jan Brocher - BioVoxxel
lead to stronger edge enhancement than the unsharp mask but can also
induce
Post by Sidnei Paciornik
Post by Jan Brocher - BioVoxxel
artifacts if overdone.
kind regards,
Jan
Post by Sidnei Paciornik
Hi Jan
I guess this is not quite the answer. I don't need edge detection, but
edge enhancement. I couldn't figure how either of your hints would do
it.
Post by Sidnei Paciornik
Post by Jan Brocher - BioVoxxel
Post by Sidnei Paciornik
The algorithm should be simple. Take a neighborhood, calculate min,
max,
Post by Sidnei Paciornik
Post by Jan Brocher - BioVoxxel
Post by Sidnei Paciornik
and range R.
Pick a threshold T.
If T>R it is not an edge, keep input pixel.
Else exchange pixel with max or min.
I just don't know how to program it.
Any other hints?
Thank you.
Em 22/06/2013 04:24, "Jan Brocher - BioVoxxel" <
Post by Jan Brocher - BioVoxxel
Hi Sidnei,
There is a plugin called Image Edges from Thomas Boudier (I think it
is
http://imagejdocu.tudor.lu/doku.php?id=plugin:filter:edge_detection:start
Post by Sidnei Paciornik
Post by Jan Brocher - BioVoxxel
Post by Sidnei Paciornik
Post by Jan Brocher - BioVoxxel
).
Another possibility would be the "Edges" in FeatureJ from Eric
Meijering
Post by Sidnei Paciornik
Post by Jan Brocher - BioVoxxel
Post by Sidnei Paciornik
Post by Jan Brocher - BioVoxxel
which enables you to suppress "halo" effects. To my knowledge both
plugins
Post by Sidnei Paciornik
Post by Jan Brocher - BioVoxxel
Post by Sidnei Paciornik
Post by Jan Brocher - BioVoxxel
apply Canny edge detection based algorithms.
regards,
Jan
--
CEO: Dr. rer. nat. Jan Brocher
phone: +49 (0)6234 917 03 39
mobile: +49 (0)176 705 746 81
web: www.biovoxxel.de
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Gabriel Landini
2013-06-24 09:27:29 UTC
Permalink
Post by Sidnei Paciornik
Here is a link to a pdf that explains the point.
https://dl.dropboxusercontent.com/u/20667937/Halo%20effect.pdf
I do not think this is a microscopy-only issue. Most digital images captured
with a camera or scanner, if enlarged, will show some blurring around edges.

There is a similar approach called Morphological Contrast or Toggle Contrast,
described in Soille's book Morphological Image analysis p. 259.
The procedure sets the pixel value to either Max or Min in a kernel, depending
on which one is the closest to the original and so you do not need to rely on
an arbitrary threshold. A macro to do this is in the Morphology zip file in my
page (called Morphological_contrast.txt).
However to modify this to do what you want is trivial. You do the above if the
difference of max-min is above a threshold t.
The original Morphological Contrast is the case when the threshold is 0.
Below is the macro modified to do this. Mind the line breaks.

Cheers
Gabriel

//---------------8<-----------------
// Morphological_contrast_Thr
// G. Landini 24/Jun/2013
// Sets the pixel value to either Max or Min, depending on which one is
// the closest and above a set threshold
// Similar to Toggle Contrast in Soille, Morphological Image Analysis (2004),
// p. 259.
// It can use operators other than Min and Max (ie Open and Close, etc)

setBatchMode(true);
if (bitDepth()!=24){
a=getTitle();
Dialog.create("Morphologica Contrast Thr");
Dialog.addNumber("Radius", 2);
Dialog.addNumber("Threshold", 25);
Dialog.show();
r=Dialog.getNumber();
t=Dialog.getNumber();

run("Duplicate...", "title=min");
run("Minimum...", "radius="+r);
selectWindow(a);
run("Duplicate...", "title=max");
run("Maximum...", "radius="+r);

selectWindow("max");
w=getWidth();
h=getHeight();
i=0;
max=newArray(w*h);
for (x=0;x<w;x++){
for (y=0;y<h;y++){
max[i]=getPixel(x,y);
i++;
}
}


selectWindow("min");
i=0;
min=newArray(w*h);
for (x=0;x<w;x++){
for (y=0;y<h;y++){
min[i]=getPixel(x,y);
i++;
}
}

selectWindow(a);
i=0;
for (x=0;x<w;x++){
for (y=0;y<h;y++){
c=getPixel(x,y);
if (max[i]-min[i]>t){
if((max[i]-c)<=(c-min[i])){
putPixel(x,y, max[i]);
}
else if ((max[i]-c)>(c-min[i])){
putPixel(x,y, min[i]);
}
}
i++;
}
}
updateDisplay();
selectWindow("min");
close();
selectWindow("max");
close();
}
else
showMessage("Error","Greyscale images only!\nConvert RGB to HSB and
process\nthe Brightness channel only.");

setBatchMode(false);

//---------------8<-----------------

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Michael Schmid
2013-06-24 11:20:06 UTC
Permalink
Hi Sidnei,

some edge-preserving blur operations can also sharpen edges. As an example, you could try the 'Thresholded Blur' filter:

http://imagejdocu.tudor.lu/doku.php?id=plugin:filter:thresholded_blur:start

Michael
________________________________________________________________
Post by Sidnei Paciornik
Dear colleagues,
A simple need, but I could not find the right solution in ImageJ. I am
sorry if it is obvious.
Is there a filter to increase edge sharpness and reduce the effect known as
"halo effect" in optical microscopy?
At the edges of bright objects and a dark background (or vice-versa) there
are normally pixels with intermediate pixel values. If other objects in the
image have these pixel values, when they are segmented the edges of bright
objects will also appear.
Even though these fake edges can be corrected by a morphological open, it
is normally better to pre-process the image with an edge enhancement filter
(some times called delineate) to increase the edge sharpness and reduce the
amount of intermediate pixels.
Any hints?
Thank you!
Prof. Sidnei Paciornik
Grupo de Análise de Imagens e Microscopia Digital
DEMa <http://www.dema.puc-rio.br/> - Departamento de Engenharia de Materiais
PUC-Rio <http://www.puc-rio.br/>
Rua Marquês de São Vicente 225
Prédio Leme, Sala 501L
Gávea - Rio de Janeiro - RJ
22451-900 - Brasil
tel: (55)(21)3527-1243
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

Loading...