[Jde-dev] #247 New Colortuner schema

Pablo Miangolarra Tejada p.miangolabra en alumnos.urjc.es
Vie Mayo 22 12:03:20 CEST 2009


Hola a todos,

En este mail adjunto un parche, que aumenta la funcionalidad del  
schema colortuner.

El parche se ha hecho contra la revisión 364, de jde4.3.

Attached to this email is a patch that improve colortuner sschema  
functionality.

- Now user can choose to view unfiltered pixels in grey, white or  
black, in that way will be easier to identify which color pixels are  
detected.

- YUV range values for filter have been modified to be more accurate.

https://trac.jde.gsyc.es/jde/trac.cgi/ticket/247

un saludo

Pablo

------------ próxima parte ------------
--- color364.c	2009-05-22 11:21:27.000000000 +0200
+++ colortuner.c	2009-05-18 20:08:44.000000000 +0200
@@ -22,7 +22,7 @@
 #include <jde.h>
 #include "colortuner.h"
 #include <graphics_gtk.h>
-#include <colorspaces.h>
+#include <libcolorspaces/colorspaces.h>
 #include <interfaces/varcolor.h>
 
 
@@ -77,6 +77,11 @@
 int radio_rgb 		= 0;
 int radio_hsv 		= 0;
 int radio_yuv 		= 0;
+
+int radio_grey 		= 1;
+int radio_white 	= 0;
+int radio_black		= 0;
+
 float 	threshold 	= 20.0;
 
 /*Option Parameters HSV*/
@@ -657,6 +662,30 @@
 	}
 }
 
+void on_active_grey_toggled (GtkCheckMenuItem *menu_item, gpointer user_data){
+	if(radio_grey){
+		radio_grey=0;
+	}else{ 
+		radio_grey=1;
+	}
+}
+
+void on_active_white_toggled (GtkCheckMenuItem *menu_item, gpointer user_data){
+	if(radio_white){
+		radio_white=0;
+	}else{ 
+		radio_white=1;
+	}
+}
+
+void on_active_black_toggled (GtkCheckMenuItem *menu_item, gpointer user_data){
+	if(radio_black){
+		radio_black=0;
+	}else{ 
+		radio_black=1;
+	}
+}
+
 //***********************************************************************************
 //
 //			Functions for YUV and HSV maps interaction
@@ -932,8 +961,8 @@
 	      	U =  0.436 - ((x_pulsada*0.436*2.0)/SMAX);
 		V = ((y_pulsada*0.615*2.0)/SMAX) - 0.615;
 
-	        umax=U+0.1;
-		umin=U-0.1;
+	        umax=U+0.05;
+		umin=U-0.05;
 		 if (umax>0.436){
 		    umax=0.436;
 		 }
@@ -941,8 +970,8 @@
 		    umin=-0.436;
 		 }
 
-		 vmax2=V+0.1;
-		 vmin2=V-0.1;
+		 vmax2=V+0.05;
+		 vmin2=V-0.05;
 		 if (vmax2>0.615){
 		    vmax2=0.615;
 		 }
@@ -1182,16 +1211,16 @@
 		 if (ymin<0){
 		    ymin=0.0;
 		 }
-		 umax=U+0.1;
-		 umin=U-0.1;
+		 umax=U+0.05;
+		 umin=U-0.05;
 		 if (umax>0.436){
 		    umax=0.436;
 		 }
 		 if (umin<-0.436){
 		    umin=-0.436;
 		 }
-		 vmax2=V+0.1;
-		 vmin2=V-0.1;
+		 vmax2=V+0.05;
+		 vmin2=V-0.05;
 		 if (vmax2>0.615){
 		    vmax2=0.615;
 		 }
@@ -1340,10 +1369,20 @@
 			image_aux[i*3+1] = image[i*3+1];
 			image_aux[i*3+2] = image[i*3+2];
 		}else{
-	   	/*Pixel does not get trought: Grey Scale */
-			image_aux[i*3] = (unsigned char) (myHSV->V*100/255);
-			image_aux[i*3+1] = (unsigned char) (myHSV->V*100/255);
-			image_aux[i*3+2] = (unsigned char) (myHSV->V*100/255);
+	   	/*Pixel does not get trought*/
+			if (radio_grey){
+				image_aux[i*3] = (unsigned char) ((int)b*100/255);
+				image_aux[i*3+1] = (unsigned char) ((int)b*100/255);
+				image_aux[i*3+2] = (unsigned char) ((int)b*100/255);
+			}else if(radio_black){
+				image_aux[i*3] = (unsigned char) ((int)0);
+				image_aux[i*3+1] = (unsigned char) ((int)0);
+				image_aux[i*3+2] = (unsigned char) ((int)0);
+			}else if(radio_white){
+				image_aux[i*3] = (unsigned char) ((int)255);
+				image_aux[i*3+1] = (unsigned char) ((int)255);
+				image_aux[i*3+2] = (unsigned char) ((int)255);
+			}
 		}
 
 		/*Save values in HSV mask*/
@@ -1386,10 +1425,20 @@
 			image_aux[i*3+1] = image[i*3+1];
 			image_aux[i*3+2] = image[i*3+2];
 		}  else {
-	   	/*Pixel does not get trought: Grey Scale */
-			image_aux[i*3] = (unsigned char) (b*100/255);
-			image_aux[i*3+1] = (unsigned char) (b*100/255);
-			image_aux[i*3+2] = (unsigned char) (b*100/255);
+	   	/*Pixel does not get trought*/
+			if (radio_grey){
+				image_aux[i*3] = (unsigned char) ((int)b*100/255);
+				image_aux[i*3+1] = (unsigned char) ((int)b*100/255);
+				image_aux[i*3+2] = (unsigned char) ((int)b*100/255);
+			}else if(radio_black){
+				image_aux[i*3] = (unsigned char) ((int)0);
+				image_aux[i*3+1] = (unsigned char) ((int)0);
+				image_aux[i*3+2] = (unsigned char) ((int)0);
+			}else if(radio_white){
+				image_aux[i*3] = (unsigned char) ((int)255);
+				image_aux[i*3+1] = (unsigned char) ((int)255);
+				image_aux[i*3+2] = (unsigned char) ((int)255);
+			}
 		}
 	}
 	
@@ -1451,10 +1500,20 @@
 			image_aux[i*3+1] = image[i*3+1];
 			image_aux[i*3+2] = image[i*3+2];
 		}  else {
-	   	/*Pixel does not get trought: Grey Scale */
-			image_aux[i*3] = (unsigned char) ((int)b*100/255);
-			image_aux[i*3+1] = (unsigned char) ((int)b*100/255);
-			image_aux[i*3+2] = (unsigned char) ((int)b*100/255);
+	   	/*Pixel does not get trought*/
+			if (radio_grey){
+				image_aux[i*3] = (unsigned char) ((int)b*100/255);
+				image_aux[i*3+1] = (unsigned char) ((int)b*100/255);
+				image_aux[i*3+2] = (unsigned char) ((int)b*100/255);
+			}else if(radio_black){
+				image_aux[i*3] = (unsigned char) ((int)0);
+				image_aux[i*3+1] = (unsigned char) ((int)0);
+				image_aux[i*3+2] = (unsigned char) ((int)0);
+			}else if(radio_white){
+				image_aux[i*3] = (unsigned char) ((int)255);
+				image_aux[i*3+1] = (unsigned char) ((int)255);
+				image_aux[i*3+2] = (unsigned char) ((int)255);
+			}
 		}
 		
 		/*Save values in HSV mask*/
@@ -1851,6 +1910,13 @@
          g_signal_connect(GTK_WIDGET(glade_xml_get_widget(xml, "radio_yuv")),
                           "toggled", G_CALLBACK(on_active_yub_toggled), NULL);
 
+	 g_signal_connect(GTK_WIDGET(glade_xml_get_widget(xml, "radio_grey")),
+                          "toggled", G_CALLBACK(on_active_grey_toggled), NULL);
+         g_signal_connect(GTK_WIDGET(glade_xml_get_widget(xml, "radio_white")),
+                          "toggled", G_CALLBACK(on_active_white_toggled), NULL);
+         g_signal_connect(GTK_WIDGET(glade_xml_get_widget(xml, "radio_black")),
+                          "toggled", G_CALLBACK(on_active_black_toggled), NULL);
+
      	
       }
 		/*Set values for HSV sliders*/


More information about the Jde-developers mailing list