how to store specific pixels after scanning the image with a mask
Show older comments
Hi, I am working on Diabetic retinopathy and have to find the vessel bifurcations. In order to do so, I am scanning the entire image with 5 different masks in a loop. If any of the pixels in the image satisfy either one of the 5 conditions, I have to store the corresponding pixel position for later use.
I am unable to store the pixel positions in an array. Please help me.
This is the code I am using to scan the image with different masks.
[nrows,ncols] = size(cmp);
count = 0;
m = 1;
n = 1;
for i = 2:nrows-1
for j = 2:ncols-1
if cmp(i,j)== 0 && cmp(i,j+1)==1 && cmp(i,j-1)==1 && cmp(i-1,j)==0 && cmp(i-1,j-1)==1 && cmp(i-1,j+1)==1 && cmp(i+1,j)==1 && cmp(i+1,j-1)==0 && cmp(i+1,j+1)==0
count = count+1;
elseif cmp(i,j)== 0 && cmp(i,j+1)==1 && cmp(i,j-1)==1 && cmp(i-1,j)==1 && cmp(i-1,j-1)==0 && cmp(i-1,j+1)==0 && cmp(i+1,j)==0 && cmp(i+1,j-1)==1 && cmp(i+1,j+1)==1
count = count+1;
elseif cmp(i,j)== 0 && cmp(i,j+1)==0 && cmp(i,j-1)==1 && cmp(i-1,j)==0 && cmp(i-1,j-1)==1 && cmp(i-1,j+1)==1 && cmp(i+1,j)==1 && cmp(i+1,j-1)==0 && cmp(i+1,j+1)==1
count = count+1;
elseif cmp(i,j)== 0 && cmp(i,j+1)==1 && cmp(i,j-1)==1 && cmp(i-1,j)==1 && cmp(i-1,j-1)==0 && cmp(i-1,j+1)==0 && cmp(i+1,j)==1 && cmp(i+1,j-1)==1 && cmp(i+1,j+1)==0
count = count+1;
else cmp(i,j)== 0 && cmp(i,j+1)==1 && cmp(i,j-1)==1 && cmp(i-1,j)==1 && cmp(i-1,j-1)==0 && cmp(i-1,j+1)==0 && cmp(i+1,j)==1 && cmp(i+1,j-1)==0 && cmp(i+1,j+1)==0
count = count+1;
end
end
end
Accepted Answer
More Answers (1)
Image Analyst
on 10 May 2012
0 votes
Why not just use the 'branchpoints' option of bwmorph() and replace all that code with just one simple call to bwmorph()?
Categories
Find more on Images in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!