How can I use lorentzian norm in 2D gray scale image segmentation?

I'm working on 2D image segmentation & I want to refine the image with lorentz as a preprocessing operation.
lorentzian norm equation is:
f(x)= sum(log(1+0.5(x/T))), where "x" is a distance.
my problem is how can I calculate the distance "x".
is it the distance between center pixel and just one neighbor?
or it's the distance between this pixel and its 8-neighbors?
"or is it the maximum or minimum distance"?
thanks

 Accepted Answer

rasha
Lorentizian metric requires 4 dimensions x,y,z,t, but here for image processing the matrix is 2D so then where there is sum in your Function replicate it to 2 sums , try to discuss this prototype :
X=im2double(imread('circuit.tif'));
T=norm(X) ; % random number chosen here to be euclidean norm
FX=sum(sum(log(1+0.5*X/T)))

1 Comment

Youssef KHMOU, I'm so grateful for your addition,
in this prototype its suppose that X produce the whole image, but in my program X is a distance between two pixels.
I replicate the sum as your advice in my program, it produce the same result to me.
thanks

Sign in to comment.

More Answers (1)

I have no idea. If you don't either, then why are you so sure you want to do it?

17 Comments

I need it for my research as a kind of refinement step.
That didn't answer the question. So WHY do you think you need it? I guess that you're trying to follow some paper that uses it. If so, then doesn't the paper tell you what x and T are? And tell you why this operation is needed, and what you're supposed to do with f(x) once you've constructed it?
yes I saw it in a paper, but it takes it as a mathematical equation with no explanation.
I know that lorentzian used Instead of the mean square error equation to produce finer result image.
so f(x) will be the new input image with less high frequencies.
thank you for your interaction with my question and for the link :)
I wrote this code but it have error in summation step, could you help me on it?
if true
%
I = imread('cameraman.tif');
I = im2double(I);
J = zeros(size(I)); % Output
[m n] = size(I);
f = zeros(1,8);
T = 50;
for i = 2:m-1
for j = 2:n-1
cp=I(i,j);
np=I(i-1,j);
sp=I(i+1,j);
wp=I(i,j-1);
ep=I(i,j+1);
nwp=I(i-1,j-1);
nep=I(i-1,j+1);
swp=I(i+1,j-1);
sep=I(i+1,j+1);
x1 = (np-cp) ;
x2 = (nwp-cp)/1.4;
x3 = (nep-cp)/1.4 ;
x4 = (sp-cp);
x5 = (swp-cp)/1.4;
x6 = (sep-cp)/1.4;
x7 = (wp-cp);
x8 = (ep-cp);
for X = x1:x8
X = log(1+0.5*(X/T)^2);
f(X) = abs(X);
J(i,j) = sum(f(X));
end
end
end
imshow(J)
grayImage = imread('cameraman.tif');
grayImage = im2double(grayImage);
J = zeros(size(grayImage)); % Output
[rows, columns] = size(grayImage);
f = zeros(1,8);
T = 50;
for i = 2 : rows-1
for j = 2 : columns-1
cp=grayImage(i,j);
np=grayImage(i-1,j);
sp=grayImage(i+1,j);
wp=grayImage(i,j-1);
ep=grayImage(i,j+1);
nwp=grayImage(i-1,j-1);
nep=grayImage(i-1,j+1);
swp=grayImage(i+1,j-1);
sep=grayImage(i+1,j+1);
x(1) = (np-cp) ;
x(2) = (nwp-cp)/1.4;
x(3) = (nep-cp)/1.4 ;
x(4) = (sp-cp);
x(5) = (swp-cp)/1.4;
x(6) = (sep-cp)/1.4;
x(7) = (wp-cp);
x(8) = (ep-cp);
f = abs(log(1+0.5*(x/T) .^ 2));
J(i,j) = sum(f(:));
end
end
imshow(J, [])
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
thanks too much Image Analyst, finally it works :)
What does it do though? It looks like an edge detector. Is that what you wanted? You could probably speed it up even more though clever use of the conv2() function.
yes of course you are right;
but I have to try a lot of methods to compare between them,
I'm still studying it, and I'm not sure if this is the wanted result.
Please accept my answer since I finally got it working for you.
I wanted to accept the two answers, but when I make it for one, your accept disappear, I tried but I didn't find Retreat button.
tel me how and I will do it.
They don't have that functionality (yet), though many have been asking for it.
rasha, the problem is solved, if you posted the code at the first time it would easier to make suggestions. Unaccept my response and accept the other answer ,
good luck
they have to do it, please don't be Angry, I really apologize for this, its my first interaction in the site and I don't know the all Rules yet.
but of course it's a lesson to me.
No one is angry. Here's a good list of postings to get you up to speed on the forum: tutorials, and of course the FAQ. Welcome to the forum.
Youssef KHMOU, the both answers are helpful. and as I tell Image Analyst I wanted to accept both of them. next time I will post the code first. thanks
Image Analyst, all my regards to you and to Youssef KHMOU.
really it's a very good site and company.
thanks

Sign in to comment.

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!