Revision: 56248
http://sourceforge.net/p/brlcad/code/56248
Author: mohitdaga
Date: 2013-07-27 01:08:55 +0000 (Sat, 27 Jul 2013)
Log Message:
-----------
Added file libicv/color_space.c . This will contain all the color_space
conversion api functions (currently rgb-gray and gray-rgb, later others like
hsv-rgb, cmyka-rgb etc..). Added gray2rgb api function. This does a simple gray
pixel copying at three places(r,g,b). This api function does an inplace
color_space change.
Modified Paths:
--------------
brlcad/trunk/include/icv.h
brlcad/trunk/src/libicv/CMakeLists.txt
Added Paths:
-----------
brlcad/trunk/src/libicv/color_space.c
Modified: brlcad/trunk/include/icv.h
===================================================================
--- brlcad/trunk/include/icv.h 2013-07-27 00:34:12 UTC (rev 56247)
+++ brlcad/trunk/include/icv.h 2013-07-27 01:08:55 UTC (rev 56248)
@@ -204,6 +204,24 @@
*/
ICV_EXPORT extern void icv_image_free(icv_image_t* bif);
+/** @file libicv/color_space.c
+ *
+ * This file contains routines to change the icv image from one
+ * colorspace to other.
+ *
+ */
+
+/**
+ * Converts a single channel image to three channel image.
+ * Replicates the pixel as done by bw-pix utility
+ * returns a three channel image.
+ * If a three channel image is passed, this function returns the same image.
+ */
+
+
+ICV_EXPORT int icv_image_gray2rgb(icv_image_t *img);
+
+
/** @} */
/* end image utilities */
Modified: brlcad/trunk/src/libicv/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/libicv/CMakeLists.txt 2013-07-27 00:34:12 UTC (rev
56247)
+++ brlcad/trunk/src/libicv/CMakeLists.txt 2013-07-27 01:08:55 UTC (rev
56248)
@@ -10,6 +10,7 @@
set(LIBICV_SOURCES
fileformat.c
rot.c
+ color_space.c
)
BRLCAD_ADDLIB(libicv "${LIBICV_SOURCES}" "libbu;libbn;${PNG_LIBRARY}")
Added: brlcad/trunk/src/libicv/color_space.c
===================================================================
--- brlcad/trunk/src/libicv/color_space.c (rev 0)
+++ brlcad/trunk/src/libicv/color_space.c 2013-07-27 01:08:55 UTC (rev
56248)
@@ -0,0 +1,82 @@
+/* C O L O R _ S P A C E . C
+ * BRL-CAD
+ *
+ * Copyright (c) 2013 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file libicv/color_space.c
+ *
+ * This file contains color_space conversion routines.
+ *
+ */
+#include "common.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "vmath.h"
+#include "bio.h"
+#include "bu.h"
+#include "icv.h"
+
+int
+icv_image_gray2rgb(icv_image_t *img)
+{
+ double *out_data,*op;
+ double *in_data;
+ long int size;
+ long int i = 0;
+ if (!ICV_IMAGE_IS_INITIALIZED(img)) {
+ bu_log("icv_image_gray2rgb : Unitialized Image argument\n");
+ return -1;
+ }
+
+ if (img->color_space == ICV_COLOR_SPACE_RGB) {
+ bu_log("icv_image_gray2rgb : already RGB");
+ return 0;
+ }
+ else if (img->color_space != ICV_COLOR_SPACE_GRAY) {
+ bu_log("icv_image_gray2rgb : color_space error");
+ return -1;
+ }
+ size = img->height*img->width;
+ op = out_data = (double *)bu_malloc(size*3*sizeof(double), "Out Image
Data");
+ in_data = img->data;
+ for (i =0 ; i < size; i++) {
+ *(out_data) = *in_data;
+ *(out_data+1) = *in_data;
+ *(out_data+2) = *in_data;
+ out_data+=3;
+ in_data++;
+ }
+
+ bu_free(img->data, "icv_image_gray2rgb : gray image data");
+ img->data = op;
+ img->color_space = ICV_COLOR_SPACE_RGB;
+ img->channels = 3;
+
+ return 0;
+}
+
+/*
+ * Local Variables:
+ * tab-width: 8
+ * mode: C
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */
Property changes on: brlcad/trunk/src/libicv/color_space.c
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits