![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/296398/image.png)
Reduce loss of quality when using imfill and imfuse
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I have to fill some regions of a black and white map, whose regions are black and are delimited by white borders.
This is the code
fill_regions = [ 128 58
280 80
335 292
430 430
470 475
525 525
550 655
680 610
770 380
785 480];
I = imread('https://i.imgur.com/4kWRWDV.png'); % black italy with white borders
BW = imbinarize(I,.1); % turn I into a black-white image...I had to use .1 threshold to prevent the filling of multiple adiacent regions
T = imread('https://i.imgur.com/1QY6Qw0.png'); % transparent italy, has only the borders
for i = 1:size(fill_regions,1)
BW = imfill(BW,fill_regions(i,:));
end
imshow( imfuse(BW,T,'diff') ); % add the erased borders to BW
saveas(gcf, 'test.png')
and here is a comparison between original image (left) and filled one (right)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/290744/image.png)
as you can see, the filled image has poor quality (but also the original image has not the same quality as the source image...why this happens?).
Is there a way to preserve the same quality as the source image or, at least, to reduce the loss of quality?
2 Commenti
darova
il 21 Mag 2020
I saved your boundary image, it's poor quality. Look
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/296398/image.png)
You don't need for loop in this case, just imfill
I1 = imfill(BW,fill_regions);
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Convert Image Type in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!