how to remove connectec components from original image?

I detected some connected components. I can plot on image but I wan to remove from original image. for example I want to remove viscircles from original image. when imwrite on image I cant see viscircles
imshow(image);
hold on;
title(['Tespit Edilen Delik Sayısı: ', num2str(numberOfHoles)]);
% Delik merkezlerine kırmızı çarpı işareti koy
viscircles(centroids,10)
imwrite(image,'dd.png')
hold off;

2 Commenti

now I am doing this but it gives me this error
Unable to perform assignment because the indices on the left side are not compatible with
the size of the right side.
Error in denemee (line 56)
mask(i)=createMask(h(i));
% Sonuçları görselleştir
imshow(image);hold on;title(['Delik Sayısı: ', num2str(length(stats))]);
%viscircles(centroids,8);
for i=1:length(centroids)
h(i)=drawcircle("Center",[centroids(i,1),centroids(i,2)],"Radius",10,'Color','r');
end
for i=1:length(centroids)
mask(i)=createMask(h(i));
end
I tried this one bu only one circle appears in maske. is there any method to remove circles
for i=1:length(centroids)
maske=createMask(drawcircle("Center",[centroids(i,1),centroids(i,2)],"Radius",10,'Color','r'));
end

Accedi per commentare.

 Risposta accettata

I don't believe imwrite will write the overlay objects, such as circles, into the image. Did yoiu recall dd.png to check if the circles are there? They should not be.
Don't use "image" as the name of your variable since it's the name of a built-in function. Maybe that's the problem. Try calling it rgbImage or something else instead.
To remove circles from the display you can do
handleToCircles = viscircles(centroids,10) % Create circles
delete(handleToCircles); % Delete circles

7 Commenti

Hey Image Analyst I haven't used Matlab much so I don't know if this is against community guidelines but I was wondering am I able to ask for your help or do you usually just answer questions as you see them?
@Bera you can ask me questions here. I check this forum several times a day.
@mehmet baki mask is not a vector. It needs to be an image so you'll have to use a 3-D array or a cell array and use size, not length.
for k = 1 : size(centroids, 1)
mask{k} = createMask(h(i));
end
How do you know it does not work? Is there an error message?
for k = 1 : size(centroids, 1)
mask{k} = createMask(h(i));
end
bi
I used this it works but I am getting error for
binaryImage(mask(1))=0
ı tried this but it gives me error
unable to use a value of type cell as an index.
Because you need to use braces, not parentheses. Please read the FAQ: What is a cell array
It will show you when to use braces {}, brackets [], and parentheses ().
it works now Thanks a lot!
for i=1:size(centroids,1)
h(i)=drawcircle("Center",[centroids(i,1),centroids(i,2)],"Radius",10,'Color','r');
maske{i} = createMask(h(i));
end
for j=1:size(maske,2)
binaryImage(maske{1,j})=0
end
imshow(binaryImage)
maske is a 1-D array so you don't need to do size(maske,2). Most people would probably just do numel(maske).
Did you notice I changed the loop iterator from i to k? This is because we discourage using i and j as loop iterators (even though they'll work) to avoid confusion with the imaginary constants i and j.
You don't need two indexes when referencing maske. So the last for loop would be
for k = 1 : numel(maske)
% Blacken our cumulative binary image where this mask is true.
binaryImage(maske{k}) = false;
end

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by