black task processing in an image
1 次查看(过去 30 天)
显示 更早的评论
Hello
I have a problem with the image display level, the problem is that I have black spots in the white part and I want to eliminate them
attaching the resulting image and the .mat file
thank you in advance![ask.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/207321/ask.jpeg)
![ask.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/207321/ask.jpeg)
0 个评论
采纳的回答
Image Analyst
2019-3-7
Threshold the image and then call imfill()
binaryImage = grayImage > someValue;
binaryImage = imfill(binaryImage, 'holes');
If you want only holes of a certain diameter filled, then it's a little trickier, so write back.
5 个评论
Image Analyst
2019-3-8
Then try this, if you want all black holes filled to white:
s = load('outputt.mat')
u = logical(s.u);
subplot(2, 1, 1);
imshow(u, 'InitialMagnification', 200);
axis('on', 'image');
% Fill in everything.
[rows, columns] = find(u);
boundaryIndexes = boundary(columns, rows);
hold on;
plot(columns(boundaryIndexes), rows(boundaryIndexes), 'r-', 'LineWidth', 2);
newImage = poly2mask(columns(boundaryIndexes), rows(boundaryIndexes), size(u, 1), size(u, 2));
subplot(2, 1, 2);
imshow(newImage, 'InitialMagnification', 200);
axis('on', 'image');
![0000 Screenshot.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/207444/0000%20Screenshot.png)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing and Computer Vision 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!