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.
  댓글 수: 2
Dustkin Jou
Dustkin Jou 2022년 11월 16일
using this
close all;
img = imread('7.jpg');
rotated = imrotate(img,-90);
gray = rgb2gray(rotated);
bw = imbinarize(gray);
comp = imcomplement(bw);
se = strel('line',30,90);
erode = imerode(comp,se);
dil = imdilate(erode,se);
erode1 = imerode(dil,se);
dil1 = imdilate(erode1,se);
this is the output, im trying to get smoother in the tip and bottom

댓글을 달려면 로그인하십시오.

채택된 답변

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('');
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));
Not really there, but it's ... what it is.
  댓글 수: 3
Dustkin Jou
Dustkin Jou 2022년 11월 17일
Thank you. This is the output i was looking for, thank you so much

댓글을 달려면 로그인하십시오.

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by