Esempio n. 1
0
typename image<T, D>::create_new median_blur(const image<T, D>& a, int neighbourhood)
{
	IplImage* src = a.ipl();
	IplImage* dst = cvCreateImage(cvGetSize(src),
		image_details::ipl_depth<T>(), int(a.channels()));
	cvSmooth(src, dst, CV_MEDIAN, neighbourhood);
	typename image<T, D>::create_new r(dst);
	cvReleaseImage(&src);
	cvReleaseImage(&dst);
	return r;
}
Esempio n. 2
0
typename image<T, D>::create_new get_quadrange_sub_pix(const image<T, D>& a,
		const array_2d<double>& map_matrix, const size_array& dst_size)
{
	IplImage* src = a.ipl();
	IplImage* dst;

	if(dst_size[0] == 0 && dst_size[1] == 0) {
		dst = cvCreateImage(cvGetSize(src),
		image_details::ipl_depth<T>(), int(a.channels()));
	} else {
		dst = cvCreateImage(cvSize(dst_size[1], dst_size[0]),
		image_details::ipl_depth<T>(), int(a.channels()));
	}

	CHECK(map_matrix.rows() == 2, eshape);
	CHECK(map_matrix.columns() == 2, eshape);

	CvMat* cvmap_matrix = cvCreateMat(2, 3, image_details::cv_type<double>());
	cvmSet(cvmap_matrix, 0, 0, map_matrix(0, 0));
	cvmSet(cvmap_matrix, 0, 1, map_matrix(0, 1));
	cvmSet(cvmap_matrix, 0, 2, map_matrix(0, 2));
	cvmSet(cvmap_matrix, 1, 0, map_matrix(1, 0));
	cvmSet(cvmap_matrix, 1, 1, map_matrix(1, 1));
	cvmSet(cvmap_matrix, 1, 2, map_matrix(1, 2));

	/*cvmap_matrix->data.db[0] = map_matrix(0, 0);
	cvmap_matrix->data.db[1] = map_matrix(0, 1);
	cvmap_matrix->data.db[2] = map_matrix(0, 2);
	cvmap_matrix->data.db[3] = map_matrix(1, 0);
	cvmap_matrix->data.db[4] = map_matrix(1, 1);
	cvmap_matrix->data.db[5] = map_matrix(1, 2);*/

	cvGetQuadrangleSubPix(src, dst, cvmap_matrix);

	typename image<T, D>::create_new r(dst);

	cvReleaseMat(&cvmap_matrix);
	cvReleaseImage(&src);
	cvReleaseImage(&dst);
	return r;
}
Esempio n. 3
0
typename image<T, D>::create_new bilateral_blur(const image<T, D>& a, int color_sigma,
	int space_sigma)
{
	IplImage* src = a.ipl();
	IplImage* dst = cvCreateImage(cvGetSize(src),
		image_details::ipl_depth<T>(), int(a.channels()));
	cvSmooth(src, dst, CV_BILATERAL, color_sigma, space_sigma);
	typename image<T, D>::create_new r(dst);
	cvReleaseImage(&src);
	cvReleaseImage(&dst);
	return r;
}
Esempio n. 4
0
typename image<T, D>::create_new blur_no_scale(const image<T, D>& a, int neighbourhood_rows,
	int neighbourhood_cols)
{
	IplImage* src = a.ipl();
	IplImage* dst = cvCreateImage(cvGetSize(src),
		image_details::ipl_depth<T>(), int(a.channels()));
	cvSmooth(src, dst, CV_BLUR_NO_SCALE, neighbourhood_cols, neighbourhood_rows);
	typename image<T, D>::create_new r(dst);
	cvReleaseImage(&src);
	cvReleaseImage(&dst);
	return r;
}
Esempio n. 5
0
typename image<T, D>::create_new pyramid_down(const image<T, D>& a)
{
	IplImage* src = a.ipl();
	IplImage* dst = cvCreateImage(
		image_details::cv_size(a.width() / 2, a.height() / 2),
		image_details::ipl_depth<T>(), int(a.channels()));
	cvPyrDown(src, dst);
	typename image<T, D>::create_new r(dst);
	cvReleaseImage(&src);
	cvReleaseImage(&dst);
	return r;
}
Esempio n. 6
0
typename image<T, D>::create_new laplace(const image<T, D>& a,
	int aperture_size)
{
	IplImage* src = a.ipl();
	IplImage* dst = cvCreateImage(cvGetSize(src),
		image_details::ipl_depth<T>(), int(a.channels()));
	cvLaplace(src, dst, aperture_size);
	typename image<T, D>::create_new r(dst);
	cvReleaseImage(&src);
	cvReleaseImage(&dst);
	return r;
}
Esempio n. 7
0
typename image<T, D>::create_new sobel(const image<T, D>& a,
	int y_order, int x_order, int aperture_size)
{
	IplImage* src = a.ipl();
	IplImage* dst = cvCreateImage(cvGetSize(src),
		image_details::ipl_depth<T>(), (int)a.channels());
	cvSobel(src, dst, x_order, y_order, aperture_size);
	typename image<T, D>::create_new r(dst);
	cvReleaseImage(&src);
	cvReleaseImage(&dst);
	return r;
}
Esempio n. 8
0
typename image<T, D>::create_new gaussian_blur(const image<T, D>& a, int neighbourhood_rows,
	int neighbourhood_cols, int vertical_sigma, int horizontal_sigma)
{
	IplImage* src = a.ipl();
	IplImage* dst = cvCreateImage(cvGetSize(src), image_details::ipl_depth<T>(),
		int(a.channels()));
	cvSmooth(src, dst, CV_GAUSSIAN, neighbourhood_cols, neighbourhood_rows,
		horizontal_sigma, vertical_sigma);
	typename image<T, D>::create_new r(dst);
	cvReleaseImage(&src);
	cvReleaseImage(&dst);
	return r;
}
Esempio n. 9
0
typename image<T, D>::create_new resample(const image<T, D>& a, size_t rows, size_t cols,
	interpolation interp)
{
	IplImage* src = a.ipl();
	IplImage* dst = cvCreateImage(
		image_details::cv_size(cols, rows),
		image_details::ipl_depth<T>(), int(a.channels()));
	cvResize(src, dst, image_details::interpolation_map[interp]);
	typename image<T, D>::create_new r(dst);
	cvReleaseImage(&src);
	cvReleaseImage(&dst);
	return r;
}
Esempio n. 10
0
typename image<T, D>::create_similar grayscale(const image<T, D>& a)
{
	size_t ch = a.channels();
	CHECK(ch > 1, erange());
	size_t w = a.width();
	size_t h = a.height();
	typename types::promote<T>::type acc;
	typename image<T, D>::create_similar r(h, w, 1, 0);
	for(size_t i = 0; i < h; i++) {
		for(size_t j = 0; j < w; j++) {
			acc = a(i, j, 0);
			for(size_t col = 1; col < ch; col++)
				acc += a(i, j, col);
			acc /= typename types::promote<T>::type(ch);
			r(i, j) = T(acc);
		}
	}
	return r;
}
Esempio n. 11
0
typename image<T, D>::create_new rotate(const image<T, D>& a, double angle,
	const float_point<2>& center, double scale, interpolation interp,
	warp_method warp_m, color<T, D::Ch> fill_color)
{
	IplImage* src = a.ipl();
	IplImage* dst = cvCreateImage(cvGetSize(src),
		image_details::ipl_depth<T>(), int(a.channels()));
	CvPoint2D32f cvcenter;
	cvcenter.x = center.x;
	cvcenter.y = center.y;
	CvMat* map_matrix = cvCreateMat(2, 3, image_details::cv_type<double>());
	cv2DRotationMatrix(cvcenter, angle, scale, map_matrix );
	cvWarpAffine(src, dst, map_matrix,
		image_details::interpolation_map[interp]+
		image_details::warp_map[warp_m] ,
		image_details::to_cvscalar(fill_color));
	typename image<T, D>::create_new r(dst);
	cvReleaseMat(&map_matrix);
	cvReleaseImage(&src);
	cvReleaseImage(&dst);
	return r;
}