From: <sha...@us...> - 2007-07-08 18:03:48
|
Revision: 2246 http://hugin.svn.sourceforge.net/hugin/?rev=2246&view=rev Author: shahid_du Date: 2007-07-08 11:03:45 -0700 (Sun, 08 Jul 2007) Log Message: ----------- Added missing files maskgen.c and maskgen.h. Added Paths: ----------- libpanorama/trunk/src/vips/maskgen.c libpanorama/trunk/src/vips/maskgen.h Added: libpanorama/trunk/src/vips/maskgen.c =================================================================== --- libpanorama/trunk/src/vips/maskgen.c (rev 0) +++ libpanorama/trunk/src/vips/maskgen.c 2007-07-08 18:03:45 UTC (rev 2246) @@ -0,0 +1,67 @@ +#include "stdio.h" +#include "stdlib.h" +#include <string.h> +#include <ctype.h> +#include <stdarg.h> +#include <assert.h> + +#include "maskgen.h" + + +int isFormat(IMAGE *out, const char *fileName, const char *format) +{ + /*printf("starting format chk with filename = %s, format = %s\n", fileName, format);*/ + char *ext, *substr; + int i; + + if(!(ext = IM_ARRAY(out, 10, char))) { + printf("memeroy allocation error\n"); + return -1; + } + substr = IM_ARRAY(out, 10, char); + + substr = strrchr(fileName, '.'); + for(i = 0; i < strlen(substr)-1; i++) { + ext[i] = tolower(substr[i+1]); + } + + ext[i] = '\0'; + + /*printf("in isFormat: format = %s, ext = %s\n", format, ext);*/ + i = strcmp(format, ext); + + return i; +} + + +int circle (IMAGE * out, int w, int h, double x, double y, double r) +{ + IMAGE *t[8]; + + if (im_open_local_array (out, t, 8, "circle", "p") || + /* Get x/y into t[1] and t[2] + */ + im_make_xy (t[0], w, h) || + im_extract_band (t[0], t[1], 0) || im_extract_band (t[0], t[2], 1) || + /* Shift origin + */ + im_lintra (1.0, t[1], -x, t[3]) || im_lintra (1.0, t[2], -y, t[4]) || + /* Square. + */ + im_multiply (t[3], t[3], t[5]) || im_multiply (t[4], t[4], t[6]) || + /* Add and threshold. + */ + im_add (t[5], t[6], t[7]) || im_lessconst (t[7], out, r * r)) + return (-1); + + return (0); +} + + +int makeCircularMask(IMAGE *out, int width, int height, double cx, double cy, double radius) +{ + if(circle(out, width, height, cx, cy, radius)) + return -1; + + return 0; +} Added: libpanorama/trunk/src/vips/maskgen.h =================================================================== --- libpanorama/trunk/src/vips/maskgen.h (rev 0) +++ libpanorama/trunk/src/vips/maskgen.h 2007-07-08 18:03:45 UTC (rev 2246) @@ -0,0 +1,27 @@ +#ifndef __MASKGEN_H__ +#define __MASKGEN_H__ + +#include <vips/vips.h> + +/* +Input mask checking procedure: +1. detect whether input image is tif or png (In this case they already +possess a mask.) +2. if condition 1 is true then extract band no. 4 (let the staring +band is numbered as 1) as initial input image mask. +3. if condition 1 is false then create a white image as initial mask +(by using im_black and im_invert). +4. Logically And the initial mask obtained either from step 2 or 3 +with the mask obtained from the panotools script - more specifically a +mask is available if circular crop is mentioned, i.e. if +pt_transform->crop_circular = 1, then extract crop parameters from +crop_circular_cx, crop_circular_cy, crop_circular_radius and create +the circle mask with these parameters using manual circle operation. +5. Pass the combined input mask to resample operation. +6. Check the mask along with input image boundary check during resampling. +*/ + +int isFormat(IMAGE *out, const char *fileName, const char *format); +int makeCircularMask(IMAGE *out, int widht, int height, double cx, double cy, double radius); + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |