How do I repair noisy picture and invert the bw color?
조회 수: 6(최근 30일)
표시 이전 댓글
Hello, new to the matlab app, I'm trying to repair this image

to be like this picture (or close)

Any help would be much appreciated.
Thanks.
채택된 답변
DGM
2022년 11월 16일
편집: DGM
2022년 11월 16일
This is a very lazy answer. Consider this more a matter of cleanup than optimizing the object reconstruction. I'm not going to pretend that this is complete or robust.
img = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1195578/image.jpeg');
gray = rgb2gray(img); % convert to gray first; reduces cost of subsequent ops
gray = imrotate(gray,-90); % not every single output needs to be a unique variable
bw = ~imbinarize(gray); % equivalent to imcomplement(binaryimage)
se = strel('line',30,90); % idk why this was selected
bw = imopen(bw,se); % opening is equivalent to dilate(erode(x,se),se)
% opening with a fixed strel is idempotent
% i.e. opening again with the same strel does not change the result
% added
bw = imclose(bw,strel('disk',100,0)); % fills some holes and closes some gaps
bw = bwareaopen(bw,10000); % gets rid of small specks
bwoutline = bwperim(bw);
% that 1px outline won't show up when rescaled here
% due to display interpolation.
% fatten the line so it shows up
bwoutline = imdilate(bwoutline,strel('disk',7));
imshow(bwoutline);
Not really there, but it's ... what it is.
추가 답변(0개)
참고 항목
범주
Find more on Image Segmentation and Analysis 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!