matlab - 在 CT 图像中分割肺部和结节

标签 matlab image-processing

我是 Matlab 图像处理的新手,我正在尝试从 CT 图像中分割 LUNG 和结节。我已经完成了初始图像增强。

我在同一方面搜索了很多,但我没有找到任何相关 Material 。

尝试从给定图像中分割肺部;然后在肺部检测结节。

enter image description here

我在 Matlab 中试过的代码:

d1 = dicomread('000000.dcm'); 
d1ca = imadjust(d1); 

d1nF = wiener2(d1ca);

d1Level  = graythresh(d1nF);
d1sBW = im2bw(d1nF,d1Level); 
sed = strel('diamon',1); 
BWfinal = imerode(d1sBW,sed);
BWfinal = imerode(BWfinal,sed);

BWoutline = bwperim(BWfinal);
Segout = d1nF;
Segout(BWoutline) = 0; 

edgePrewitt = edge(d1nF,'prewitt'); 

以上代码的结果:

enter image description here

想要这样的结果:

http://oi41.tinypic.com/35me7pj.jpg

http://oi42.tinypic.com/2jbtk6p.jpg

http://oi44.tinypic.com/w0kthe.jpg

http://oi40.tinypic.com/nmfaio.jpg

http://oi41.tinypic.com/2nvdrie.jpg

http://oi43.tinypic.com/2nvdnhk.jpg

我知道这对专家来说可能很容易。请帮帮我。

谢谢!

最佳答案

以下不是 Matlab 答案!但是,OpenCVMatlab 有许多共同点,我相信您会能够毫无问题地将此 C++ 代码转换为 Matlab。

有关被调用方法的更多信息,请查看 OpenCV documentation .

#include <iostream>
#include <vector>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>    

int main(int argc, char* argv[])
{
// Load input image (colored, i.e. 3-channel)
cv::Mat input = cv::imread(argv[1]);
if (input.empty())
{
    std::cout << "!!! failed imread()" << std::endl;
    return -1;
}   

// Convert input image to grayscale (1-channel)
cv::Mat grayscale = input.clone();
cv::cvtColor(input, grayscale, cv::COLOR_BGR2GRAY);

什么是灰度:

// Erode & Dilate to remove noises and improve the result of the next operation (threshold)
int erosion_type = cv::MORPH_RECT; // MORPH_RECT, MORPH_CROSS, MORPH_ELLIPSE
int erosion_size = 3;
cv::Mat element = cv::getStructuringElement(erosion_type, 
                                            cv::Size(2 * erosion_size + 1, 2 * erosion_size + 1), 
                                            cv::Point(erosion_size, erosion_size));

cv::erode(grayscale, grayscale, element);
cv::dilate(grayscale, grayscale, element);

形态学操作后灰度的样子:

// Threshold to segment the area of the lungs
cv::Mat thres;
cv::threshold(grayscale, thres, 80, 150, cv::THRESH_BINARY);

什么是thres:

    // Find the contours of the lungs in the thresholded image
std::vector<std::vector<cv::Point> > contours;
cv::findContours(thres, contours, cv::RETR_LIST, cv::CHAIN_APPROX_SIMPLE);


// Fill the areas of the lungs with BLUE for better visualization   
cv::Mat lungs = input.clone();      
for (size_t i = 0; i < contours.size(); i++)
{
    std::vector<cv::Point> cnt = contours[i];
    double area = cv::contourArea(cv::Mat(cnt));        

    if (area > 15000 && area < 35000)
    {
        std::cout << "* Area: " << area << std::endl;
        cv::drawContours(lungs, contours, i, cv::Scalar(255, 0, 0), 
                         CV_FILLED, 8, std::vector<cv::Vec4i>(), 0, cv::Point() );
    }           
}

的样子:

// Using the image with blue lungs as a mask, we create a new image containing only the lungs
cv::Mat blue_mask = cv::Mat::zeros(input.size(), CV_8UC1);
cv::inRange(lungs, cv::Scalar(255, 0, 0), cv::Scalar(255, 0, 0), blue_mask);    
cv::Mat output;
input.copyTo(output, blue_mask);

什么是输出:

此时您已在图像中分离出肺部,可以继续执行其他过滤操作以分离出结节。

祝你好运。

关于matlab - 在 CT 图像中分割肺部和结节,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20285200/

相关文章:

matlab - 使用 MATLAB 进行简单的二元逻辑回归

matlab - 在Matlab中生成动画(AVI文件)而不显示图形

python - 如何在python中屏蔽对象的轮廓

c# - 两幅图像之间的差异

java - 尝试安装 Matlab Compiler Runtime 时出现 JRE 错误

excel - Matlab:默认打开文件 'outside Matlab'

python - 从 MATLAB 调用 Python 运算符错误 x**2

java - 读取所有输入流后,SkImageDecoder::Factory 仍然返回 null

c++ - 找到两个嘈杂的光照变体图像之间的差异(直方图对齐等)

c++ - 在 C++ 中计算相似图像的偏移/倾斜/旋转