Posted by
Sidnei Paciornik on
URL: http://imagej.273.s1.nabble.com/Edge-Enhancement-tp5003576p5014626.html
Hi Gabriel
I would like to refer to the message below, from 2013, in which you sent me the
code for an edge enhancement (or delineation) algorithm in ImageJ.
We have used it several times but recently, trying to apply it to a rather large
image (18kx15k pixels), we had a strange behavior. The plugin takes about 15
minutes running (on an i7 with 24 Gb RAM) and then apparently finishes. However,
the output image is the same as the input.
There is no error message.
Any suggestions?
Thank you very much for your attention.
Best regards. Sidnei
Prof. Sidnei Paciornik Grupo de Análise de Imagens e Microscopia Digital
DEQM - Departamento de Engenharia Química e de Materiais
PUC-Rio
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
On Mon, Jun 24, 2013 at 6:27 AM, Gabriel Landini <
[hidden email] > wrote:
On Monday 24 Jun 2013 03:14:08 Sidnei Paciornik wrote:
> 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
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html