コード例 #1
0
ファイル: chroma.cpp プロジェクト: gstavrinos/ros_visual
/* Callback function to handle ros image messages
 * 
 * PARAMETERS:
 * 			-the pointer that contains the color image 
 * 			 and its metadata
 * 
 * RETURN: --
 */
void Chroma_processing::imageCb(const sensor_msgs::ImageConstPtr& msg)
{
	
	cv_bridge::CvImagePtr cv_ptr;
	int rows;
	int cols;
	int channels;
	int size;
	
	try
	{
	  cv_ptr = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::MONO8);	  
	}
	catch (cv_bridge::Exception& e)
	{
	  ROS_ERROR("cv_bridge exception: %s", e.what());
	  return;
	}

	cur_rgb = (cv_ptr->image).clone();
	
	// contrast fix
	cur_rgb.convertTo(cur_rgb, -1, 4, 0);
	
	// gamma correction
	gammaCorrection(cur_rgb);
	

	// First run variable initialization 
	if(frameCounter == -1 )
	{
		rows 	 = cur_rgb.rows;
		cols 	 = cur_rgb.cols;
		channels = cur_rgb.channels();
		size 	 = rows*cols*channels;
		ref_rgb  = cur_rgb.clone();
		
		frameCounter++;
	}
	
	//~ medianBlur(dif_rgb, dif_rgb, 3);
	frameDif(cur_rgb, ref_rgb, dif_rgb, 255*0.33);
	ref_rgb = cur_rgb.clone();

	
	//Display
	 
	//Blob detection
	if(display)
	{
		detectBlobs(dif_rgb, rgb_rects, 15);
		
		Mat temp = dif_rgb.clone();
	    for(Rect rect: rgb_rects)
			rectangle(temp, rect, 255, 1);
		rgb_rects.clear();
		
		imshow("dif_rgb", temp);
		moveWindow("dif_rgb", 0, 0);
		imshow("cur_rgb", cur_rgb);
		moveWindow("cur_rgb", 645, 0);
		waitKey(1);
	}
	
	///////////////////////////////
	///////////////////////////////

	/*  Image background estimation	
	 * 
	 * 
	cur_rgb = (cv_ptr->image).clone();
	
	// Edge detection and background estimation
	int kernel_size = 3;
	int scale = 1;
	int delta = 0;
	int ddepth = CV_16S;
	
	
	cur_rgb.convertTo(cur_rgb, -1, 2, 0);
    gammaCorrection(cur_rgb);
	//~ GaussianBlur( cur_rgb, cur_rgb, Size(3,3), 0, 0, BORDER_DEFAULT );

	medianBlur(cur_rgb, cur_rgb, 3);
	Laplacian( cur_rgb, cur_rgb, ddepth, kernel_size, scale, delta, BORDER_DEFAULT );
	convertScaleAbs( cur_rgb, cur_rgb );
	

    estimateBackground(cur_rgb, back_Mat, rgb_storage, 500, 0.04);
    Mat temp_Mat = cur_rgb.clone();
    estimateForeground(cur_rgb, back_Mat, temp_Mat);
    medianBlur(temp_Mat, temp_Mat, 7);
    adaptiveThreshold(temp_Mat, temp_Mat, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 9, -15);
    
    vector< Rect_<int> > back_rects;
    detectBlobs(temp_Mat, back_rects, 15);
	
    imshow("temp_Mat", temp_Mat);
	moveWindow("temp_Mat", 645, 0);
	*/
	
	has_image = true;
	waitKey(1);
	
	cv_ptr->image = cur_rgb;
	image_pub.publish(cv_ptr->toImageMsg());
	
	cv_ptr->image = dif_rgb;
	image_pub_dif.publish(cv_ptr->toImageMsg());
	
}
コード例 #2
0
ファイル: filter.c プロジェクト: 10045125/PhotoProcessing
void applyInstafix(Bitmap* bitmap) {
	//unsharpMask(bitmap, 3, 0.25f, 2);
	gammaCorrection(bitmap);
	normaliseColours(bitmap);
}
コード例 #3
0
ファイル: draw.c プロジェクト: LightYourselfUp/MG2
/* Draw point */
void drawPoint(unsigned char x, unsigned char y, unsigned char brightness){

	gPreBufferGreyscale[(x - 1) * 5 + y - 1] = gammaCorrection(brightness);
}