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