how to create rounded edges of an irregular object? I want to smoothen the corners of this object.

조회 수: 2 (최근 30일)

채택된 답변

Image Analyst
Image Analyst 2020년 9월 8일
You can blur the image with imfilter() or conv2():
windowSize = 21; % Bigger for more blurring.
kernel = ones(windowSize) / windowSize^2;
output = imfilter(rgbImage, kernel);
  댓글 수: 7
Nabanita Roy
Nabanita Roy 2020년 9월 27일
I have multiple same images. Is it possible to crop all the binary images in such a way that the black object will take only 40 percent of the entire image and the rest 60 percent will remain white. Thats how I want to standardize the images.
Image Analyst
Image Analyst 2020년 9월 27일
Yes. First get the area, then divide by 0.4 to get the number of pixels in the cropped image. Then use indexing to crop it out.
mask = bwareafilt(mask, 1); % Take largest blob only.
props = regionprops(mask, 'area', 'Centroid');
imageArea = area / 0.4;
imageWidth = sqrt(imageArea);
xCentroid = props.Centroid(1);
yCentroid = props.Centroid(2);
xLeftCol = round(xCentroid - imageWidth/2);
xRightCol = round(xCentroid + imageWidth/2);
yTopRow = round(yCentroid - imageWidth/2);
yBottomRow = round(yCentroid + imageWidth/2);
output = mask(yTopRow : yBottomRow, xLeftCol : xRightCol);

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Image Processing Toolbox에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by