I want to smooth the boarder of all white areas in this Binary Image (even the tiny ones). Consider it like smoothing with your hand.
45 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Akzeptierte Antwort
KALYAN ACHARJYA
am 24 Aug. 2019
Bearbeitet: KALYAN ACHARJYA
am 24 Aug. 2019
In addition of the above links provided by @Walter morphological operations, imdilate and imclose, you may try with the following code also (@Image Analyst related answer, I cant find the link right now).
*Here image_binary is the input binary image, please note you have to manage the tradeoff between original shape changes vs. smoothness.
windowSize=12; % Decide as per your requirements
kernel=ones(windowSize)/windowSize^2;
result=conv2(single(image_binary),kernel,'same');
result=result>0.5;
image_binary(~result)=0;
figure, imshow(image_binary);
Hope it helps!
6 Kommentare
KALYAN ACHARJYA
am 26 Aug. 2019
Hi Saafan, as per my undestanding, all smothing operation, you bound to loose data, you have to trade off between how much smooth data vs. loss of original information.
For better smoth operartion, the resolutions / samples size should be more, so that proposed approach can follow the trend (fitting).
Weitere Antworten (2)
Walter Roberson
am 25 Aug. 2019
img = im2bw(imread('image.jpeg'));
subplot(1,2,1)
imshow(img);
subplot(1,2,2)
newimg = imdilate(img, ones(3));
imshow(newimg)
7 Kommentare
Bruno Luong
am 26 Aug. 2019
Still the smoothness is not limit by the pixel, otherwise Kalyan's image would not be smoother.
Walter Roberson
am 26 Aug. 2019
Bearbeitet: Walter Roberson
am 26 Aug. 2019
A relevant question would be whether black and white is to be retained or if grayscale could be used, as grayscale could permit some antialiasing.
Image Analyst
am 26 Aug. 2019
Just blur the image with conv2() like KALYAN showed.
blurredImage = conv2(double(binaryImage), ones(3)/9, 'same');
It won't be a binary/logical image anymore, but it will be smoother. You didn't say it had to stay a binary image.
And, it it's not already obvious, you cannot smooth a boundary without losing details. I know you said blurring will lose details, but losing details is EXACTLY what you want when you smooth boundaries. If you don't lose details, it's not smoother!
0 Kommentare
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!