1

我们尝试了用于伤口分割的局部直方图方法,该方法对于各种图像都不能很好地工作,然后我们教导使用小波变换进行伤口分割。在OpenCV中使用小波变换对伤口进行分割

哪个小波变换适合伤口分割和一些提示来实现它?

有没有比小波变换更好的方法来在所有光照条件下分割伤口?

我们也试过图像集群哪个没有那么好。

下面是我们使用的一些测试用例和聚类程序。

#include "cv.h" 
#include "highgui.h" 

#include <iostream> 
void show_result(const cv::Mat& labels, const cv::Mat& centers, int height, int width); 
int main(int argc, const char * argv[]) 
{  
     cv::Mat image = cv::imread("kmean.jpg"); 
     if (image.empty()) { 
       std::cout << "unable to load an input image\n"; 
       return 1; 
     } 
     //cv::cvtColor(image,image,CV_BGR2HSV); 
     std::cout << "image: " << image.rows << ", " << image.cols << std::endl; 
     assert(image.type() == CV_8UC3); 
     cv::imshow("image", image); 

     cv::Mat reshaped_image = image.reshape(1, image.cols * image.rows); 
     std::cout << "reshaped image: " << reshaped_image.rows << ", " << reshaped_image.cols << std::endl; 
     assert(reshaped_image.type() == CV_8UC1); 
     //check0(image, reshaped_image); 

     cv::Mat reshaped_image32f; 
     reshaped_image.convertTo(reshaped_image32f, CV_32FC1, 1.0/255.0); 
     std::cout << "reshaped image 32f: " << reshaped_image32f.rows << ", " << reshaped_image32f.cols << std::endl; 
     assert(reshaped_image32f.type() == CV_32FC1); 

     cv::Mat labels; 
     int cluster_number = 4; 
     cv::TermCriteria criteria(cv::TermCriteria::COUNT, 100, 1); 
     cv::Mat centers; 
     cv::kmeans(reshaped_image32f, cluster_number, labels, criteria, 1, cv::KMEANS_PP_CENTERS, centers); 

     show_result(labels, centers, image.rows,image.cols); 

     return 0; 
} 

void show_result(const cv::Mat& labels, const cv::Mat& centers, int height, int width) 
{ 
     std::cout << "===\n"; 
     std::cout << "labels: " << labels.rows << " " << labels.cols << std::endl; 
     std::cout << "centers: " << centers.rows << " " << centers.cols << std::endl; 
     assert(labels.type() == CV_32SC1); 
     assert(centers.type() == CV_32FC1); 

     cv::Mat rgb_image(height, width, CV_8UC3); 
     cv::MatIterator_<cv::Vec3b> rgb_first = rgb_image.begin<cv::Vec3b>(); 
     cv::MatIterator_<cv::Vec3b> rgb_last = rgb_image.end<cv::Vec3b>(); 
     cv::MatConstIterator_<int> label_first = labels.begin<int>(); 

     cv::Mat centers_u8; 
     centers.convertTo(centers_u8, CV_8UC1, 255.0); 
     cv::Mat centers_u8c3 = centers_u8.reshape(3); 

     while (rgb_first != rgb_last) { 
       const cv::Vec3b& rgb = centers_u8c3.ptr<cv::Vec3b>(*label_first)[0]; 
       *rgb_first = rgb; 
       ++rgb_first; 
       ++label_first; 
     } 
     cv::imshow("tmp", rgb_image); 


     cv::waitKey(); 
} 

将-1背景:(两个集群)

Would-1 with Background

请问-1出背景:

Would-1 with out Background

请问-2- w ^第i个背景:

Would-2 with Background

请问-2出背景:(三组)

Would-2 with out Background

当我们去除背景,我们得到一个好一点的分割,但取出背景我们正在使用手动操作的抓斗。因此,我们需要用kmean聚类替代分割图像(或)以上代码中的一些改进,以实现100%的成功案例。

那么有没有更好的方法来分割伤口?

+0

任何人都很难在没有看到一些图像的情况下帮助你,最好是伴随着迄今为止尝试的源代码提取。 – Zaphod 2015-02-07 07:10:46

+0

@Zaphod我添加了图片和代码。请立即检查。 – 2015-02-08 14:51:38

回答

1

您可能想要尝试使用类似于Viola Jones face detector中使用的积分图像的基础来调整用于物体检测任务的Haar-like小波,而不是尝试使用传统小波变换。用于通用对象检测的This paper by Lienhart et al将是一个好的开始。

从您的示例图像的外观来看,伤口小像素邻域内强度的变化要高得多,而未发亮的皮肤在小邻域看起来相当均匀。 Lienhart论文能够检测到这种变化 - 您可以将这些特征提供给机器学习设置,或者只是手动观察并定义搜索窗口和相关的启发式。

希望这会有所帮助。

+0

你有任何代码? – 2015-02-12 11:34:50

+0

我没有任何代码可以分享,但Lienhart论文非常详细,不应该很难编码。 – Zaphod 2015-02-13 02:49:35