Revision: 56324
http://sourceforge.net/p/brlcad/code/56324
Author: mohitdaga
Date: 2013-07-30 13:52:44 +0000 (Tue, 30 Jul 2013)
Log Message:
-----------
Adding new file libicv/crop.c. This will cropping functions. Adding icv_rect
api. This extracts any rectangular part of the image.
Modified Paths:
--------------
brlcad/trunk/include/icv.h
brlcad/trunk/src/libicv/CMakeLists.txt
Added Paths:
-----------
brlcad/trunk/src/libicv/crop.c
Modified: brlcad/trunk/include/icv.h
===================================================================
--- brlcad/trunk/include/icv.h 2013-07-30 11:32:08 UTC (rev 56323)
+++ brlcad/trunk/include/icv.h 2013-07-30 13:52:44 UTC (rev 56324)
@@ -145,8 +145,8 @@
/**
* Write an image line to the data of ICV struct. Can handle unsinged char
buffers.
*
- * Note : This function require memory allocation for ICV_UCHAR_DATA, which
inturn aquires
- * BU_SEM_SYSCALL semaphore.
+ * Note : This function require memory allocation for ICV_UCHAR_DATA, which
inturn aquires
+ * BU_SEM_SYSCALL semaphore.
*
* @param bif ICV struct where data is to be written
* @param y Index of the line at which data is to be written. 0 for the first
line
@@ -287,7 +287,29 @@
double gweight,
double bweight);
+/** @file libicv/crop.c
+ *
+ * This file contains functions for cropping images.
+ * There are two types of cropping rectangular and skeyed.
+ */
+/**
+ * This function crops an input image.
+ * Note : (0,0) corresponds to the Bottom Left of an Image.
+ *
+ * @param img Input image struct to be cropped.
+ * @param xorig X-Cordinate of offset of image to be extracted from.
+ * @param yorig Y-Cordinate of offset of image to be extracted from.
+ * @param xnum Legnth of the output image to be extracted from input
+ * data in horizontal direction.
+ * @param ynum Legnth of the output image to be extracted from input
+ * data in vertical direction.
+ * @return 0 on success.
+ */
+
+ICV_EXPORT extern int icv_rect(icv_image_t *img, int xorig, int yorig, int
xnum, int ynum);
+
+
/** @} */
/* end image utilities */
Modified: brlcad/trunk/src/libicv/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/libicv/CMakeLists.txt 2013-07-30 11:32:08 UTC (rev
56323)
+++ brlcad/trunk/src/libicv/CMakeLists.txt 2013-07-30 13:52:44 UTC (rev
56324)
@@ -11,6 +11,7 @@
fileformat.c
rot.c
color_space.c
+ crop.c
)
BRLCAD_ADDLIB(libicv "${LIBICV_SOURCES}" "libbu;libbn;${PNG_LIBRARY}")
Added: brlcad/trunk/src/libicv/crop.c
===================================================================
--- brlcad/trunk/src/libicv/crop.c (rev 0)
+++ brlcad/trunk/src/libicv/crop.c 2013-07-30 13:52:44 UTC (rev 56324)
@@ -0,0 +1,80 @@
+/* C R O P . 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/crop.c
+ *
+ * This file contains functions for cropping images.
+ * There are two types of cropping rectangular and skeyed.
+ *
+ */
+#include "bu.h"
+#include "icv.h"
+#include "vmath.h"
+
+int
+icv_rect(icv_image_t *img, int xorig, int yorig, int xnum, int ynum)
+{
+ int row;
+ double *p, *in_data, *out_data;
+ int widthstep_in, widthstep_out, bytes_row; /**< */
+
+ if (!ICV_IMAGE_IS_INITIALIZED(img)) {
+ bu_log("ERROR: trying to crop a null image\n");
+ return -1;
+ }
+
+ if (xorig < 0)
+ xorig = 0;
+
+ if (yorig < 0)
+ yorig = 0;
+
+ if (xnum <= 0)
+ bu_exit(1, "icv_rect : ERROR: Horizontal Cut Size\n");
+
+ if (ynum <= 0)
+ bu_exit(1, "icv_rect : ERROR: Horizontal Cut Size\n");
+
+ if (xorig+xnum > img->width)
+ bu_exit(1, "icv_rect : Cut not possible, Input parameters exceeds the
width\n");
+
+ if (yorig+ynum > img->height)
+ bu_exit(1, "icv_rect : Cut not possible, Input parameters exceeds the
height\n");
+
+ /* initialization of variables to insure cropping and copying */
+ widthstep_in = img->width*img->channels;
+ widthstep_out = xnum*img->channels;
+ bytes_row = widthstep_out*sizeof(double);
+ out_data = p = bu_malloc(ynum*bytes_row,"icv_rect : Cropped Image Data" );
+
+ /* Hopes to the initial point to be extracted on the first line */
+ in_data = img->data + xorig*img->channels;
+
+ for (row = yorig; row < yorig+ynum ;row++) {
+ VMOVEN(p,in_data,widthstep_out);
+ in_data += widthstep_in;
+ p += widthstep_out;
+ }
+
+ bu_free(img->data, "icv image input data");
+ img->width = xnum;
+ img->height = ynum;
+ img->data = out_data;
+ return 0;
+}
Property changes on: brlcad/trunk/src/libicv/crop.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.
------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent
caught up. So what steps can you take to put your SQL databases under
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits