6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

IplImageとMatの型変換

Last updated at Posted at 2015-10-14

メディアンフィルタをかける場合を例として書いてみます


//main部分だけ
int _tmain(int argc, _TCHAR* argv[])
{
	IplImage *img;
	Mat dst; 

	img = cvLoadImage("ファイル名", CV_LOAD_IMAGE_GRAYSCALE); //グレースケールの部分は任意

   //IplImage型のimg -> Mat型のsrc
	Mat(src) = img;
   //srcにメディアンフィルタをかけてdstとして出力
	cv::medianBlur(src, dst, 3);
   //Mat型のdst -> IplImageのresult
	IplImage result = dst;

   //出力するときはこんな感じです
	cvShowImage("元画像", img);
	cvShowImage("処理後", &result);
   //保存する場合
	cvSaveImage("median.bmp", &result);
}

こんなに簡単なのに検索ですぐに見つからないので自分用にまとめてみました

6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?