如何使用 MATLAB 跟踪表面积以及平滑图像中的特定区域 [英] How to trace the surface area as well as smoothen a specific region in an image using MATLAB
问题描述
我有一张图片,有 6 种颜色,每种颜色表示一个值.我得到了如下图所示的图像.
I have an image with 6 colors each indicating a value. I had obtained an image as shown below.
我需要平滑边缘,然后找出该区域的面积和表面积.第二张图显示了在边缘绘制的黑线,这表明我需要以这种方式平滑边缘.
I need to smoothen the edges and then find out the area as well as the surface area of that region. The second image shows a black line drawn in the edges which indicates that I need to smoothen the edges in such a way.
我已经使用分割创建了一个如第三张图片所示的蒙版,然后使用图片后面的代码获得了一个分割的图片.
I had used segmentation to create a mask as shown in the third image, and then obtain a segmented image using the code following the image.
我使用以下代码生成蒙版图像.来源:如何分割
I have used the following code for generating till the masked image. Source : How to segment
imshow(Out1)
str = 'Click to select initial contour location. Double-click to confirm and proceed.';
title(str,'Color','b','FontSize',12);
disp(sprintf('\nNote: Click close to object boundaries for more accurate result.'));
mask = roipoly;
figure, imshow(mask)
title('Initial MASK');
maxIterations = 3000;
bw = activecontour(Out1, mask, maxIterations, 'Chan-Vese');
% Display segmented image
figure, imshow(bw)
title('Segmented Image');
为了使用activecontour"功能,我的图像需要是灰度图像,我无法将其转换为灰度并返回.还要找出该区域的表面积/面积是否有任何内置功能.请帮忙谢谢.
In order to use the 'activecontour' function my image needs to be a grey-scale image, which I'm not being able to convert to greyscale and back. Also to find out surface area/ area of the region is there any inbuilt function. Please help thanks.
推荐答案
use im2double
、im2uint8
等将二进制图像转换为灰度.
use im2double
, im2uint8
, etc. to convert binary image to grayscale.
使用 bwarea
或 regionprops
以查找区域区域.
use bwarea
or regionprops
to find the region area.
这篇关于如何使用 MATLAB 跟踪表面积以及平滑图像中的特定区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!