Exemplo n.º 1
0
IppStatus PrintOutputImages(const Image2D &image_in, const Image2D &image_bpass, const Image2D &image_localmax,
							const Params &Parameters, const int framenumber, const int stacknumber,
							FIMULTIBITMAP *filt_imagestack, FIMULTIBITMAP *over_imagestack)
{
	IppStatus status;

	Image2D image_out(image_in.get_length(), image_in.get_width());
	Image2D image_overlay(image_in.get_length(), image_in.get_width());
	Image2D centerpoints(image_in.get_length(), image_in.get_width());

	Ipp32f brightness = 75;

	//scale points to brightness
	status = ippiMulC_32f_C1R(image_localmax.get_image2D(), image_localmax.get_stepsize(), brightness,
		centerpoints.get_image2D(), centerpoints.get_stepsize(), image_localmax.get_ROIfull());

	//convert and save files as TIFFs
	status = ippiAdd_32f_C1R(
		image_bpass.get_image2D(), image_bpass.get_stepsize(),
		centerpoints.get_image2D(), centerpoints.get_stepsize(),
		image_out.get_image2D(), image_out.get_stepsize(),
		image_out.get_ROIfull());

	status = ippiAdd_32f_C1R(
		image_in.get_image2D(), image_in.get_stepsize(),
		centerpoints.get_image2D(), centerpoints.get_stepsize(),
		image_overlay.get_image2D(), image_overlay.get_stepsize(),
		image_in.get_ROIfull());

	status = IPP_to_TIFF(image_overlay, over_imagestack);
	status = IPP_to_TIFF(image_out, filt_imagestack);
	return status;
}
Exemplo n.º 2
0
void DctEmbedWatermark(const cv::Mat& image, cv::Mat& output, long frame_num)
{
	output=image.clone();
	imwrite("./res/oringin.bmp", image);
	cv::Mat watermark = cv::imread("./res/name.bmp");
	int image_height = image.rows;
	int image_width = image.cols;
	int watermark_height = watermark.rows;
	int watermark_width = watermark.cols;
	double step_height = (double)image_height / watermark_height;
	double step_width = (double)image_width / watermark_width;
	int block_height = floor(step_height);
	int block_width = floor(step_width);
	printf("block_height%d\n",block_height); 
	printf("block_width%d\n", block_width);
	// Make sure the both image dimensions are a multiple of 2
	if (block_height % 2 == 0)
		block_height = block_height;
	else
		block_height = block_height - 1;
	if (block_width % 2 == 0)
		block_width = block_width;
	else
		block_width = block_width - 1;
	// Grayscale image is 8bits per pixel,
	// but dct() method wants float values!
	cv::Mat dct_image = cv::Mat(image.rows, image.cols, CV_64F);
	image.convertTo(dct_image, CV_64F);
	int index = 0;
	for (int i = 0; i<watermark_height; i++)
		for (int j = 0; j < watermark_width; j++)//watermark_height*watermark_widthµÄ´óÑ­»·
		{
			cv::Rect rect(floor(j*step_width), floor(i*step_height), block_width, block_height);
			printf("x%f  y%f\n", i*step_height, j*step_width);
			cv::Mat image_roi;
			// Let's do the DCT now: image => frequencies
			cv::dct(dct_image(rect), image_roi);
			image_roi.at<double>(1, 0) = 0.0;
			cv::Mat image_out(image_roi.size(), image_roi.type());
			cv::idct(image_roi, image_out);
			image_out.copyTo(output(rect));
		}
	// Save a visualization of the DCT coefficients
	imwrite("./res/dct.bmp", dct_image);
	output.convertTo(output, CV_8UC1);
	imshow("out", output);
	imwrite("./res/output.bmp", output);
}
Exemplo n.º 3
0
Mat Reprojector::remap(Mat* const image_in, const int x_offset, const int y_offset, const uchar side, Point& pt_offset)
{
	const int image_width_const = image_in->cols;
	const int image_height_const = image_in->rows;

	Mat image_out = Mat::zeros(HEIGHT_LARGE, WIDTH_LARGE, CV_8UC1);
	Point** rect_mat = NULL;

	if (side == 0)
		rect_mat = rect_mat0;
	else
		rect_mat = rect_mat1;

	Point pt_reprojected;
	uchar gray_reprojected;

	int x_min = 9999;
	int x_max = 0;
	int y_min = 9999;
	int y_max = 0;

	for (int i = 0; i < image_width_const; ++i)
	{
		const int i_x_offset = i + x_offset;
		for (int j = 0; j < image_height_const; ++j)
		{
			pt_reprojected = rect_mat[i_x_offset][j + y_offset];

			if (pt_reprojected.x < x_min)
				x_min = pt_reprojected.x;
			if (pt_reprojected.x > x_max)
				x_max = pt_reprojected.x;
			if (pt_reprojected.y < y_min)
				y_min = pt_reprojected.y;
			if (pt_reprojected.y > y_max)
				y_max = pt_reprojected.y;

			gray_reprojected = image_in->ptr<uchar>(j, i)[0];
			image_out.ptr<uchar>(pt_reprojected.y,  pt_reprojected.x)[0] = gray_reprojected;
		}
	}

	pt_offset = Point(x_min, y_min);
	image_out = image_out(Rect(x_min, y_min, x_max - x_min, y_max - y_min));
	return image_out;
}