# Image analysis problem

#### yuvalmaimona

##### Newbie
i'm trying to take a photo of blood cell and paint each one with a different grey level in Matlab.
Can you help me find out what's wrong my code?

Code:
global img1 A B;
A=size(img,1);
B=size(img,2);
c=gray(256);
img1=zeros (A,B)
val=0;

for x=1:A
for y=1:B
if img(x,y)==0 &&img1(x,y)==0
val=val+1;
seg(img,val,x,y)
end
end
end

max_val=val;
img1=abs(255-img1*(255/max_val));
figure(1)
subplot(2,1,1);
image(img1)
colormap(c)
subplot(2,1,2);
imhist(img1,c);

function seg(image, val, x, y)
global img1 A B;
img1(x,y)=val;
for i=-1:1
for j=-1:1
if (x > 1 && y > 1) && (x < A && y <B)
if img1(x+i,y+j)==0&&...
img1(x+i,y+i)==0
seg(img1,val,x+i,y+j)
end
end
end
end
end

Last edited by a moderator:

#### KlausST

##### Super Moderator
Staff member
Hi,

You give a riddle. We should try to find out what this undocumented code is supposed to do?

This takes much time and relies on guessing. So we may solve the riddle or not.
You have to prove our replies.

Why that much effort for us and for you? Why not simply give useful informations?

Klaus

Replies
2
Views
877
Replies
3
Views
1K
Replies
0
Views
979
Replies
0
Views
1K
Replies
0
Views
858