how to Remove pixels at the marker locations from A binary image?

Answers (1)

Just go down your list setting those pixels to false
for k = 1 : length(rows)
binaryImage(rows(k), columns(k)) = false;
end
where rows and columns are arrays with the locations of the red crosses.

11 Comments

thank you for your fast reply
can you tell me how can i put locations in arrays knowing that it's not mentioned priviously.
It is "mentioned previously." Otherwise you would not have been able to draw the red crosses. When you did this:
plot(columns, rows, 'r+', 'MarkerSize', 15);
you must have had them. Otherwise tell me how the red crosses GOT there.
Hello Analyst,
you have right thank you,i'm just starting with matlab .
i don't succed to show all patterns in one plot and when i set pixels to false i got a white plot, changes in the code below :
patterns = {[1 0 1; 0 1 0; 1 0 1]; ... % X
[1 0 1; 0 1 0; 1 0 0]; ... % Y
[-1 1-1; 1-1 1; -1 1-1]; ... % O
[0 0 0; 1 1 1; 0 0 0]; ... % -
[1 0 0; 1 0 0; 1 1 1] ;} ; % L
labels = {'X', 'Y', 'O', '-', 'L'} ;
matches = cell( size(labels )) ;
for pId = 1 : numel( patterns )
nel = numel( patterns{pId} ) ;
ker = 2*patterns{pId} - 1 ;
[r, c] = find( conv2(B, rot90(rot90(ker)), 'full') == nel ) ;
matches{pId} = [r, c] ;
figure(pId) ;
clf ;
hold on ;
spy(A) ;
plot( c, r, 'r+', 'MarkerSize', 2 ) ;
title( sprintf( 'Matches for "%s" pattern', labels{pId} )) ;
for pId = 1 : length(r)
binaryImage(r(pId), c(pId)) = false;
end
%set( gcf, 'Units', 'normalized' ) ;
%set( gcf, 'Position', [0 0 0.4 0.7] ) ;
end
figure(pId) ;
clf ;
hold on ;
Can you upload your image I.png. Also, why do you have a loop over pId inside a loop over pId??? Make the inner loop have some other iterator, like k. Also, you didn't create binaryImage. Where is the image that is the backgrounds and branches?
here is "i.png" :
but how to create a binary image?? i didn't get it
Where is i.png? The binary image is that blue and white thing - with the blue branches on the white background. Also, what is "A"? You call spy(A) but I don't see where A is defined or used other than there. I have doubt whether that code will even run and produce the image you gave.
here is "i.png" on the link below :
https://plus.google.com/photos/yourphotos?banner=pwa&pid=5951475143755957906&oid=109398178563710623613
here is the right code below i forget some changes about spy(A) :
t = imread('I.png');
A = squelette(t);
B = 2*A - 1 ;
patterns = {[1 0 1; 0 1 0; 1 0 1]; ... % X
[1 0 1; 0 1 0; 1 0 0]; ... % Y
[-1 1-1; 1-1 1; -1 1-1]; ... % O
[0 0 0; 1 1 1; 0 0 0]; ... % -
[1 0 0; 1 0 0; 1 1 1] ;} ; % L
labels = {'X', 'Y', 'O', '-', 'L'} ;
matches = cell( size(labels )) ;
for pId = 1 : numel( patterns )
nel = numel( patterns{pId} ) ;
ker = 2*patterns{pId} - 1 ;
[r, c] = find( conv2(B, rot90(rot90(ker)), 'full') == nel ) ;
matches{pId} = [r, c] ;
figure(pId) ; clf ; hold on ;
spy(A) ;
plot( c, r, 'r+', 'MarkerSize', 2 ) ;
title( sprintf( 'Matches for "%s" pattern', labels{pId} )) ;
for k = 1 : length(r)
binaryImage(r(k), c(k)) = false;
end
end
and squelette is the code that produce a skeleton as output on the link below : http://www.mathworks.com/matlabcentral/fileexchange/27543-skeletonization-using-voronoi
I'd have to download 4 things (image, your code, squelette, and some other code that it uses), and that's asking a lot. Maybe this weekend if I find the time.
thank you for your help
so grateful
I'm most likely not going to be able to carve enough time out of my day to do all that for you. Can't you find anyone else that you work with to help you?

Sign in to comment.

Categories

Find more on MATLAB in Help Center and File Exchange

Asked:

on 9 Jan 2014

Commented:

on 20 Jan 2014

Community Treasure Hunt

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

Start Hunting!