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 ビュー (過去 30 日間)

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 8 月 24 日
編集済み: KALYAN ACHARJYA 2019 年 8 月 24 日
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 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 8 月 26 日
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).

サインインしてコメントする。

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2019 年 8 月 25 日
img = im2bw(imread('image.jpeg'));
subplot(1,2,1)
imshow(img);
subplot(1,2,2)
newimg = imdilate(img, ones(3));
imshow(newimg)
  7 件のコメント
Bruno Luong
Bruno Luong 2019 年 8 月 26 日
Still the smoothness is not limit by the pixel, otherwise Kalyan's image would not be smoother.
Walter Roberson
Walter Roberson 2019 年 8 月 26 日
編集済み: Walter Roberson 2019 年 8 月 26 日
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
Image Analyst 2019 年 8 月 26 日
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!

Community Treasure Hunt

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

Start Hunting!

Translated by